ยังไงเพื่อเข้าใช้งานแฟ้มใน Hololens 3D สิ่งโฟลเดอร์และเอามันไป apllication ที่วิ่งเวลา

0

คำถาม

ฉันกำลังมองหาข้อ SDK ที่สามารถเข้าถึงภายในโฟลเดอร์(3 มิติแบบโฟลเดอร์)ของ HoloLens และโหลดมันให้เป็นกำลังโปรแกรมและพวกเราเคยพยายามมากมายที่อยู่เชื่อมโยงที่ไม่มี avail. ใครก็ได้ช่วยเราแก้ปัญหานี้?

3d-model c# hololens internals
2021-11-24 06:35:33
1

คำตอบที่ดีที่สุด

0

ของคุณคำถามคือสวนเก่าแต่ด้วยความสัตย์จริง UWP ยุ่งยาเรื่อง ฉันพิมพ์นี้บนโทรศัพท์ของฉันแม้แต่หวังว่ามันจะช่วยคุณเริ่มเองนะ


อย่างแรก:ค Hololens ใช้ UWP.

สำหรับแฟ้มบ io ใน UWP โปรแกรมคุณต้องการที่จะใช้พิเศษซี#รูปแบบ api ซึ่งเดียวที่ทำงาน asynchronous! ดังนั้นทำตัวให้คุ้นเคยกับเรื่องนี้สงครามแย่งชิงยุทธศาสและคำค้น async, await แล้ว Task ก่อนที่คุณเริ่ม!

ไกลกว่านี้โปรดจำไว้ว่าส่วนใหญ่ของ sudan. kgm เป็นรูปแบบ api สามารถเดียวที่ถูกใช้บน sudan. kgm หลักเธรด! ดังนั้นคุณจะต้องการการอุทิศตนเรียนที่เปิดใช้ที่จะได้รับ asynchronous Actions และฆ่าพวกเขาสู่โลกถัดไป sudan. kgm หลักเธรด Update เรียกผ่านทาง ConcurrentQueue เหมือน e.g.

using System;
using System.Collections.Concurrent;
using UnityEngine;

public class MainThreadDispatcher : MonoBehaviour
{
    private static MainThreadDispatcher _instance;

    public static MainThreadDispatcher Instance
    {
        get
        {
            if (_instance) return _instance;

            _instance = FindObjectOfType<MainThreadDispatcher>();

            if (_instance) return _instance;

            _instance = new GameObject(nameof(MainThreadDispatcher)).AddComponent<MainThreadDispatcher>();

            return _instance;
        }
    }

    private readonly ConcurrentQueue<Action> _actions = new ConcurrentQueue<Action>();

    private void Awake()
    {
        if (_instance && _instance != this)
        {
            Destroy(gameObject);
            return;
        }

        _instance = this;
        DontDestroyOnLoad(gameObject);
    }

    public void DoInMainThread(Action action)
    {
        _actions.Enqueue(action);
    }

    private void Update()
    {
        while (_actions.TryDequeue(out var action))
        {
            action?.Invoke();
        }
    }
}

ตอนนี้บอกว่าคุณเป็นส่วนใหญ่อาจจะตามหา Windows.Storage.KnownFolders.Objects3D ซึ่งมัน Windows.Storage.StorageFolder.

นี่นายจะใช้ GetFileAsync เพื่อให้ได้เป็น Windows.Storage.StorageFile.

งั้นคุณใช้ Windows.Storage.FileIO.ReadBufferAsync เพื่อที่จะอ่านเนื้อหาของแฟ้มนี้ไปเป็น IBuffer.

และในที่สุดคุณสามารถใช้ ToArray เพื่อที่จะเอาแบบ raw byte[] ออกจากมัน

หลังจากเรื่องทั้งหมดนี้คุณต้องส่งผลลัพธ์กลับเข้าไปใน sudan. kgm เธรดหลักเพื่อที่จะสามารถใช้เวทมนตร์มันอยู่หรือไปต่อกับนำเข้าโพรเซสในอีก async ทาง).

คุณสามารถลองใช้บางอย่างอย่าง

using System;
using System.IO;
using System.Threading.Tasks;

#if WINDOWS_UWP // We only have these namespaces if on an UWP device
using Windows.Storage;
using System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions;
#endif

public static class Example
{
    // Instead of directly returning byte[] you will need to use a callback
    public static void GetFileContent(string filePath, Action<byte[]> onSuccess)
    {
        Task.Run(async () => await FileLoadingTask(filePath, onSuccess));
    }
    
    private static async Task FileLoadingTask(string filePath, Action<byte[]> onSuccess)
    {
#if WINDOWS_UWP
        // Get the 3D Objects folder
        var folder = Windows.Storage.KnownFolders.Objects3D;
        // get a file within it
        var file = await folder.GetFileAsync(filePath);

        // read the content into a buffer
        var buffer = await Windows.Storage.FileIO.ReadBufferAsync(file);
        // get a raw byte[]
        var bytes = buffer.ToArray();
#else
        // as a fallback and for testing in the Editor use he normal FileIO
        var folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "3D Objects");
        var fullFilePath = Path.Combine(folderPath, filePath);
        var bytes = await File.ReadAllBytesAsync(fullFilePath);
#endif

        // finally dispatch the callback action into the Unity main thread
        MainThreadDispatcher.Instance.DoInMainThread(() => onSuccess?.Invoke(bytes));
    }
}

สิ่งที่คุณทำกับคนกลับมา byte[] ขึ้นอยู่กับคุณ! มันอยู่รอบตัวข้าเต็มไปหมวโหลด implementations และบรรณารักษ์แบบออนไลน์สำหรับความแตกต่างระเภทของแฟ้ม.


การอ่าน:

2021-11-24 09:34:08

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่