共用方式為


感知模擬

您要為您的應用程式建置自動化測試嗎? 您要讓測試超越元件層級單元測試,並真正練習應用程式端對端? 感知仿真是您要尋找的內容。 Perception Simulation 連結庫會將人力和世界輸入數據傳送至您的應用程式,以便您將測試自動化。 例如,您可以模擬人類對特定可重複位置的輸入,然後使用手勢或運動控制器。

Perception Simulation 可以將這類模擬輸入傳送至實體 HoloLens、HoloLens 模擬器(第一代)、HoloLens 2 模擬器,或已安裝混合實境入口網站的計算機。 Perception Simulation 會略過混合實境裝置上的即時感測器,並將仿真的輸入傳送至裝置上執行的應用程式。 應用程式會透過它們一律使用的相同 API 接收這些輸入事件,而且無法分辨使用實際感測器與 Perception Simulation 執行之間的差異。 Perception Simulation 是 HoloLens 模擬器用來將模擬輸入傳送至 HoloLens 虛擬機的相同技術。

若要開始在您的程序代碼中使用模擬,請先建立 IPerceptionSimulationManager 物件。 您可以從該對象發出命令來控制模擬「人類」的屬性,包括頭部位置、手部位置和手勢。 您也可以啟用及操作動作控制器。

設定 Visual Studio 專案以進行感知模擬

  1. 在開發電腦上安裝 HoloLens 模擬器 。 模擬器包含您用於 Perception Simulation 的連結庫。

  2. 建立新的 Visual Studio C# 桌面專案(主控台專案很適合開始使用)。

  3. 將下列二進位檔新增至您的專案作為參考(Project-Add-Reference>>...)。您可以在 %ProgramFiles(x86)%\Microsoft XDE\(version)中找到它們,例如 %ProgramFiles(x86)%\Microsoft XDE\10.0.18362.0

    注意

    雖然二進位檔是 HoloLens 2 模擬器的一部分,但它們也適用於桌面上的 Windows Mixed Reality。

    a. PerceptionSimulationManager.Interop.dll - Perception Simulation 的 Managed C# 包裝函式。
    b. PerceptionSimulationRest.dll - 用來設定 HoloLens 或模擬器之 Web 套接字通道的連結庫。
    c. SimulationStream.Interop.dll - 用於仿真的共享類型。

  4. 將實作二進位PerceptionSimulationManager.dll新增至專案

    a. 首先,將它當做二進位檔新增至專案 (Project-Add-Existing>> Item...)。將它儲存為連結,使其不會複製到您的專案源資料夾。
    將PerceptionSimulationManager.dll新增至專案作為連結

    b. 然後確定它會在組建時複製到您的輸出資料夾。 這在二進位檔的屬性表中。
    標示要複製到輸出目錄的PerceptionSimulationManager.dll

  5. 將您的使用中解決方案平臺設定為 x64。 (如果尚未存在,請使用 Configuration Manager 建立 x64 的平台專案。

建立 IPerceptionSimulation Manager 物件

若要控制模擬,您將對從 IPerceptionSimulationManager 物件擷取的對象發出更新。 第一個步驟是取得該物件,並將其連線到您的目標裝置或模擬器。 按兩下工具列中的 [裝置入口網站] 按鈕,即可取得模擬器的IP位址

開啟裝置入口網站圖示開啟裝置入口網站:在模擬器中開啟 HoloLens OS 的 Windows 裝置入口網站。 針對 Windows Mixed Reality,這可以在 [設定] 應用程式的 [更新與安全性] 下擷取,然後在 [啟用裝置入口網站] 下的 [連線使用:] 區段中的 [適用於開發人員]。請務必同時記下IP位址和埠。

首先,您將呼叫 RestSimulationStreamSink.Create 以取得 RestSimulationStreamSink 物件。 這是您將控制 HTTP 連線的目標裝置或模擬器。 您的命令將會由在裝置或模擬器上執行的 Windows 裝置入口網站傳遞及處理。 您需要建立物件的四個參數如下:

  • URI URI - 目標裝置的IP位址(例如,“https://123.123.123.123"或 「https://123.123.123.123:50080")
  • System.Net.NetworkCredential 認證 - 用於連線到 目標裝置或模擬器上 Windows 裝置入口網站 的使用者名稱/密碼。 如果您要透過其本機位址連線到模擬器(例如 168..*) 在同一部計算機上,將接受任何認證。
  • bool normal - 如果為標準優先順序,則為 false 表示低優先順序。 針對測試案例,您通常想要將此設定為 true ,讓測試能夠控制。 模擬器和 Windows Mixed Reality 模擬會使用低優先順序連線。 如果您的測試也使用低優先順序連線,則最近建立的連線將會處於控制狀態。
  • System.Threading.CancellationToken 令牌 - 取消異步作業的令牌。

其次,您將建立 IPerceptionSimulationManager。 這是您用來控制仿真的物件。 這也必須在異步方法中完成。

控制仿真的 Human

IPerceptionSimulationManager 具有會傳回 ISimulatedHuman 物件的 Human 属性。 若要控制仿真的人,請在此對象上執行作業。 例如:

manager.Human.Move(new Vector3(0.1f, 0.0f, 0.0f))

基本範例 C# 主控台應用程式

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.PerceptionSimulation;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Task.Run(async () =>
            {
                RestSimulationStreamSink sink = null;
                CancellationToken token = new System.Threading.CancellationToken();

                try
                {
                    sink = await RestSimulationStreamSink.Create(
                        // use the IP address for your device/emulator
                        new Uri("https://169.254.227.115"),
                        // no credentials are needed for the emulator
                        new System.Net.NetworkCredential("", ""),
                        // normal priorty
                        true,
                        // cancel token
                        token);

                    IPerceptionSimulationManager manager = PerceptionSimulationManager.CreatePerceptionSimulationManager(sink);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                // Always close the sink to return control to the previous application.
                if (sink != null)
                {
                    await sink.Close(token);
                }
            });

            // If main exits, the process exits.  
            Console.WriteLine("Press any key to exit...");
            Console.ReadLine();
        }
    }
}

擴充範例 C# 主控台應用程式

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.PerceptionSimulation;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            RestSimulationStreamSink sink = null;
            CancellationToken token = new System.Threading.CancellationToken();

            Task.Run(async () =>
            {
                try
                {
                    sink = await RestSimulationStreamSink.Create(
                        // use the IP address for your device/emulator
                        new Uri("https://169.254.227.115"),
                        // no credentials are needed for the emulator
                        new System.Net.NetworkCredential("", ""),
                        // normal priorty
                        true,
                        // cancel token
                        token);

                    IPerceptionSimulationManager manager = PerceptionSimulationManager.CreatePerceptionSimulationManager(sink);

                    // Now, we'll simulate a sequence of actions.
                    // Sleeps in-between each action give time to the system
                    // to be able to properly react.
                    // This is just an example. A proper automated test should verify
                    // that the app has behaved correctly
                    // before proceeding to the next step, instead of using Sleeps.

                    // Activate the right hand
                    manager.Human.RightHand.Activated = true;

                    // Simulate Bloom gesture, which should cause Shell to disappear
                    manager.Human.RightHand.PerformGesture(SimulatedGesture.Home);
                    Thread.Sleep(2000);

                    // Simulate Bloom gesture again... this time, Shell should reappear
                    manager.Human.RightHand.PerformGesture(SimulatedGesture.Home);
                    Thread.Sleep(2000);

                    // Simulate a Head rotation down around the X axis
                    // This should cause gaze to aim about the center of the screen
                    manager.Human.Head.Rotate(new Rotation3(0.04f, 0.0f, 0.0f));
                    Thread.Sleep(300);

                    // Simulate a finger press & release
                    // Should cause a tap on the center tile, thus launching it
                    manager.Human.RightHand.PerformGesture(SimulatedGesture.FingerPressed);
                    Thread.Sleep(300);
                    manager.Human.RightHand.PerformGesture(SimulatedGesture.FingerReleased);
                    Thread.Sleep(2000);

                    // Simulate a second finger press & release
                    // Should activate the app that was launched when the center tile was clicked
                    manager.Human.RightHand.PerformGesture(SimulatedGesture.FingerPressed);
                    Thread.Sleep(300);
                    manager.Human.RightHand.PerformGesture(SimulatedGesture.FingerReleased);
                    Thread.Sleep(5000);

                    // Simulate a Head rotation towards the upper right corner
                    manager.Human.Head.Rotate(new Rotation3(-0.14f, 0.17f, 0.0f));
                    Thread.Sleep(300);

                    // Simulate a third finger press & release
                    // Should press the Remove button on the app
                    manager.Human.RightHand.PerformGesture(SimulatedGesture.FingerPressed);
                    Thread.Sleep(300);
                    manager.Human.RightHand.PerformGesture(SimulatedGesture.FingerReleased);
                    Thread.Sleep(2000);

                    // Simulate Bloom gesture again... bringing the Shell back once more
                    manager.Human.RightHand.PerformGesture(SimulatedGesture.Home);
                    Thread.Sleep(2000);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            });

            // If main exits, the process exits.  
            Console.WriteLine("Press any key to exit...");
            Console.ReadLine();

            // Always close the sink to return control to the previous application.
            if (sink != null)
            {
                sink.Close(token);
            }
        }
    }
}

6-DOF 控制器上的注意事項

在模擬 6-DOF 控制器上呼叫方法的任何屬性之前,您必須先啟動控制器。 這樣做會導致例外狀況。 從 Windows 10 2019 年 5 月更新 開始,您可以將 ISimulatedSixDofController 物件的 Status 屬性設定為 SimulatedSixDofControllerStatus.Active,以安裝並啟動仿真的 6-DOF 控制器。 在 Windows 10 2018 年 10 月更新 和更早版本中,您必須先呼叫位於 \Windows\System32 資料夾中的 PerceptionSimulationDevice 工具,以個別安裝仿真的 6-DOF 控制器。 此工具的使用方式如下:

    PerceptionSimulationDevice.exe <action> 6dof <instance>

例如:

    PerceptionSimulationDevice.exe i 6dof 1

支援的動作如下:

  • i = 安裝
  • q = query
  • r = remove

支援的實例包括:

  • 1 = 左側 6-DOF 控制器
  • 2 = 正確的 6-DOF 控制器

進程的結束代碼會指出成功(零傳回值)或失敗(非零傳回值)。 使用 'q' 動作來查詢控制器是否已安裝時,如果尚未安裝控制器,則傳回值會是零 (0),如果已安裝控制器,則傳回值會是 1。如果已安裝控制器,則傳回值會是 0。

移除 Windows 10 2018 年 10 月更新 或更早版本上的控制器時,請先透過 API 將其狀態設定為 [關閉],然後呼叫 PerceptionSimulationDevice 工具。

此工具必須以系統管理員身分執行。

API 參考

Microsoft.PerceptionSimulation.SimulatedDeviceType

描述模擬裝置類型

public enum SimulatedDeviceType
{
    Reference = 0
}

Microsoft.PerceptionSimulation.SimulatedDeviceType.Reference

虛構參考裝置,PerceptionSimulationManager 的預設值

Microsoft.PerceptionSimulation.HeadTrackerMode

描述頭部追蹤器模式

public enum HeadTrackerMode
{
    Default = 0,
    Orientation = 1,
    Position = 2
}

Microsoft.PerceptionSimulation.HeadTrackerMode.Default

默認頭部追蹤。 這表示系統可以根據運行時間條件選取最佳頭部追蹤模式。

Microsoft.PerceptionSimulation.HeadTrackerMode.Orientation

只有頭部追蹤的方向。 這表示追蹤的位置可能不可靠,而且某些相依於頭部位置的功能可能無法使用。

Microsoft.PerceptionSimulation.HeadTrackerMode.Position

位置頭部追蹤。 這表示追蹤的頭部位置和方向都是可靠的

Microsoft.PerceptionSimulation.SimulatedGesture

描述模擬手勢

public enum SimulatedGesture
{
    None = 0,
    FingerPressed = 1,
    FingerReleased = 2,
    Home = 4,
    Max = Home
}

Microsoft.PerceptionSimulation.SimulatedGesture.None

Sentinel 值,用來表示沒有手勢。

Microsoft.PerceptionSimulation.SimulatedGesture.FingerPressed

手指按下手勢。

Microsoft.PerceptionSimulation.SimulatedGesture.FingerReleased

手指釋放手勢。

Microsoft.PerceptionSimulation.SimulatedGesture.Home

主/系統手勢。

Microsoft.PerceptionSimulation.SimulatedGesture.Max

有效筆勢上限。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerStatus

模擬 6-DOF 控制器的可能狀態。

public enum SimulatedSixDofControllerStatus
{
    Off = 0,
    Active = 1,
    TrackingLost = 2,
}

Microsoft.PerceptionSimulation.SimulatedSixDofControllerStatus.Off

6-DOF 控制器已關閉。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerStatus.Active

6-DOF 控制器已開啟並追蹤。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerStatus.TrackingLost

6-DOF 控制器已開啟,但無法追蹤。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerButton

模擬 6-DOF 控制器上支援的按鈕。

public enum SimulatedSixDofControllerButton
{
    None = 0,
    Home = 1,
    Menu = 2,
    Grip = 4,
    TouchpadPress = 8,
    Select = 16,
    TouchpadTouch = 32,
    Thumbstick = 64,
    Max = Thumbstick
}

Microsoft.PerceptionSimulation.SimulatedSixDofControllerButton.None

Sentinel 值,用來表示沒有按鈕。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerButton.Home

按下 [首頁] 按鈕。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerButton.Menu

按下 [功能表] 按鈕。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerButton.Grip

按下 [夾上] 按鈕。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerButton.TouchpadPress

按下 TouchPad。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerButton.Select

按下 [選取] 按鈕。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerButton.TouchpadTouch

觸控式觸控板。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerButton.Thumbstick

按下遊戲桿。

Microsoft.PerceptionSimulation.SimulatedSixDofControllerButton.Max

有效按鈕上限。

Microsoft.PerceptionSimulation.SimulatedEyesCalibrationState

模擬眼睛的校正狀態

public enum SimulatedGesture
{
    Unavailable = 0,
    Ready = 1,
    Configuring = 2,
    UserCalibrationNeeded = 3
}

Microsoft.PerceptionSimulation.SimulatedEyesCalibrationState.Unavailable

眼睛校正無法使用。

Microsoft.PerceptionSimulation.SimulatedEyesCalibrationState.Ready

眼睛已經校正了。 這是預設值。

Microsoft.PerceptionSimulation.SimulatedEyesCalibrationState.Configuring

眼睛正在校正。

Microsoft.PerceptionSimulation.SimulatedEyesCalibrationState.UserCalibrationNeeded

眼睛需要校正。

Microsoft.PerceptionSimulation.SimulatedHandJointTrackingAccuracy

手部關節的追蹤精確度。

public enum SimulatedHandJointTrackingAccuracy
{
    Unavailable = 0,
    Approximate = 1,
    Visible = 2
}

Microsoft.PerceptionSimulation.SimulatedHandJointTrackingAccuracy.Unavailable

未追蹤關節。

Microsoft.PerceptionSimulation.SimulatedHandJointTrackingAccuracy.Approximate

推斷關節位置。

Microsoft.PerceptionSimulation.SimulatedHandJointTrackingAccuracy.Visible

關節已完全追蹤。

Microsoft.PerceptionSimulation.SimulatedHandPose

手部關節的追蹤精確度。

public enum SimulatedHandPose
{
    Closed = 0,
    Open = 1,
    Point = 2,
    Pinch = 3,
    Max = Pinch
}

Microsoft.PerceptionSimulation.SimulatedHandPose.Closed

手的手指關節設定為反映封閉姿勢。

Microsoft.PerceptionSimulation.SimulatedHandPose.Open

手的手指關節已設定為反映開放式姿勢。

Microsoft.PerceptionSimulation.SimulatedHandPose.Point

手的手指關節已設定為反映指點姿勢。

Microsoft.PerceptionSimulation.SimulatedHandPose.Pinch

手的手指關節被設定為反映捏合姿勢。

Microsoft.PerceptionSimulation.SimulatedHandPose.Max

SimulatedHandPose 的最大有效值。

Microsoft.PerceptionSimulation.PlaybackState

描述播放的狀態。

public enum PlaybackState
{
    Stopped = 0,
    Playing = 1,
    Paused = 2,
    End = 3,
}

Microsoft.PerceptionSimulation.PlaybackState.Stopped

錄製目前已停止,且已準備好播放。

Microsoft.PerceptionSimulation.PlaybackState.Playing

錄製目前正在播放中。

Microsoft.PerceptionSimulation.PlaybackState.Paused

錄製目前已暫停。

Microsoft.PerceptionSimulation.PlaybackState.End

錄音已經結束。

Microsoft.PerceptionSimulation.Vector3

描述三個元件向量,這可能描述 3D 空間中的點或向量。

public struct Vector3
{
    public float X;
    public float Y;
    public float Z;
    public Vector3(float x, float y, float z);
}

Microsoft.PerceptionSimulation.Vector3.X

此向量的 X 元件。

Microsoft.PerceptionSimulation.Vector3.Y

此向量的 Y 元件。

Microsoft.PerceptionSimulation.Vector3.Z

此向量的 Z 元件。

Microsoft.PerceptionSimulation.Vector3.#ctor(System.Single,System.Single,System.Single)

建構新的 Vector3。

參數

  • x - 向量的 x 元件。
  • y - 向量的 y 元件。
  • z - 向量的 z 元件。

Microsoft.PerceptionSimulation.Rotation3

描述三個元件輪替。

public struct Rotation3
{
    public float Pitch;
    public float Yaw;
    public float Roll;
    public Rotation3(float pitch, float yaw, float roll);
}

Microsoft.PerceptionSimulation.Rotation3.Pitch

旋轉的 [傾斜] 元件,在 X 軸周圍向下。

Microsoft.PerceptionSimulation.Rotation3.Yaw

Rotation 的 Yaw 元件,右繞 Y 軸。

Microsoft.PerceptionSimulation.Rotation3.Roll

Rotation 的 Roll 元件,靠右繞 Z 軸。

Microsoft.PerceptionSimulation.Rotation3.#ctor(System.Single,System.Single,System.Single)

建構新的 Rotation3。

參數

  • 間距 - 旋轉的音調元件。
  • yaw - 旋轉的 yaw 元件。
  • roll - Rotation 的滾動元件。

Microsoft.PerceptionSimulation.SimulatedHandJointConfiguration

描述模擬手上聯結的組態。

public struct SimulatedHandJointConfiguration
{
    public Vector3 Position;
    public Rotation3 Rotation;
    public SimulatedHandJointTrackingAccuracy TrackingAccuracy;
}

Microsoft.PerceptionSimulation.SimulatedHandJointConfiguration.Position

關節的位置。

Microsoft.PerceptionSimulation.SimulatedHandJointConfiguration.Rotation

關節的旋轉。

Microsoft.PerceptionSimulation.SimulatedHandJointConfiguration.TrackingAccuracy

關節的追蹤精確度。

Microsoft.PerceptionSimulation.Frustum

描述相機通常使用的檢視 frustum。

public struct Frustum
{
    float Near;
    float Far;
    float FieldOfView;
    float AspectRatio;
}

Microsoft.PerceptionSimulation.Frustum.Near

frustum 中包含的最小距離。

Microsoft.PerceptionSimulation.Frustum.Far

frustum 中包含的最大距離。

Microsoft.PerceptionSimulation.Frustum.FieldOfView

frustum 的水平檢視字段,以弧度為單位(小於 PI)。

Microsoft.PerceptionSimulation.Frustum.AspectRatio

水平檢視欄位與垂直檢視欄位的比例。

Microsoft.PerceptionSimulation.SimulatedDisplayConfiguration

描述模擬頭戴式裝置顯示器的設定。

public struct SimulatedDisplayConfiguration
{
    public Vector3 LeftEyePosition;
    public Rotation3 LeftEyeRotation;
    public Vector3 RightEyePosition;
    public Rotation3 RightEyeRotation;
    public float Ipd;
    public bool ApplyEyeTransforms;
    public bool ApplyIpd;
}

Microsoft.PerceptionSimulation.SimulatedDisplayConfiguration.LeftEyePosition

從頭部中心到左眼的轉換,用於立體轉譯。

Microsoft.PerceptionSimulation.SimulatedDisplayConfiguration.LeftEyeRotation

為了立體轉譯的目的,左眼旋轉。

Microsoft.PerceptionSimulation.SimulatedDisplayConfiguration.RightEyePosition

從頭部中心到右眼的轉換,以便進行立體轉譯。

Microsoft.PerceptionSimulation.SimulatedDisplayConfiguration.RightEyeRotation

為了立體轉譯的目的,右眼旋轉。

Microsoft.PerceptionSimulation.SimulatedDisplayConfiguration.Ipd

系統針對立體轉譯所報告的 Ipd 值。

Microsoft.PerceptionSimulation.SimulatedDisplayConfiguration.ApplyEyeTransforms

提供給左右眼轉換的值是否應該視為有效,並套用至執行中的系統。

Microsoft.PerceptionSimulation.SimulatedDisplayConfiguration.ApplyIpd

是否應將提供給 Ipd 的值視為有效,並套用至執行中的系統。

Microsoft.PerceptionSimulation.IPerceptionSimulationManager

用來產生用來控制裝置之封包的根目錄。

public interface IPerceptionSimulationManager
{   
    ISimulatedDevice Device { get; }
    ISimulatedHuman Human { get; }
    void Reset();
}

Microsoft.PerceptionSimulation.IPerceptionSimulationManager.Device

擷取模擬裝置物件,以解譯仿真的人和模擬世界。

Microsoft.PerceptionSimulation.IPerceptionSimulationManager.Human

擷取控制模擬人類的物件。

Microsoft.PerceptionSimulation.IPerceptionSimulationManager.Reset

將模擬重設為其默認狀態。

Microsoft.PerceptionSimulation.ISimulatedDevice

描述裝置的介面,可解譯模擬世界和仿真的人

public interface ISimulatedDevice
{
    ISimulatedHeadTracker HeadTracker { get; }
    ISimulatedHandTracker HandTracker { get; }
    void SetSimulatedDeviceType(SimulatedDeviceType type);
}

Microsoft.PerceptionSimulation.ISimulatedDevice.HeadTracker

從模擬裝置擷取前端追蹤器。

Microsoft.PerceptionSimulation.ISimulatedDevice.HandTracker

從模擬裝置擷取手部追蹤器。

Microsoft.PerceptionSimulation.ISimulatedDevice.SetSimulatedDeviceType(Microsoft.PerceptionSimulation.SimulatedDeviceType)

設定模擬裝置的屬性,以符合提供的裝置類型。

參數

  • type - 新類型的模擬裝置

Microsoft.PerceptionSimulation.ISimulatedDevice2

將 ISimulatedDevice 轉換成 ISimulatedDevice2 即可取得其他屬性

public interface ISimulatedDevice2
{
    bool IsUserPresent { [return: MarshalAs(UnmanagedType.Bool)] get; [param: MarshalAs(UnmanagedType.Bool)] set; }
    SimulatedDisplayConfiguration DisplayConfiguration { get; set; }

};

Microsoft.PerceptionSimulation.ISimulatedDevice2.IsUserPresent

擷取或設定仿真的人是否正在主動佩戴頭戴式裝置。

Microsoft.PerceptionSimulation.ISimulatedDevice2.DisplayConfiguration

擷取或設定模擬顯示的屬性。

Microsoft.PerceptionSimulation.ISimulatedHeadTracker

介面,描述追蹤模擬人類頭部的模擬裝置部分。

public interface ISimulatedHeadTracker
{
    HeadTrackerMode HeadTrackerMode { get; set; }
};

Microsoft.PerceptionSimulation.ISimulatedHeadTracker.HeadTrackerMode

擷取並設定目前的前端追蹤器模式。

Microsoft.PerceptionSimulation.ISimulatedHandTracker

介面,描述追蹤模擬人類之手的模擬裝置部分

public interface ISimulatedHandTracker
{
    Vector3 WorldPosition { get; }
    Vector3 Position { get; set; }
    float Pitch { get; set; }
    bool FrustumIgnored { [return: MarshalAs(UnmanagedType.Bool)] get; [param: MarshalAs(UnmanagedType.Bool)] set; }
    Frustum Frustum { get; set; }
}

Microsoft.PerceptionSimulation.ISimulatedHandTracker.WorldPosition

以公尺為單位,擷取與世界相關的節點位置。

Microsoft.PerceptionSimulation.ISimulatedHandTracker.Position

擷取並設定模擬手部追蹤器的位置,相對於頭部的中心。

Microsoft.PerceptionSimulation.ISimulatedHandTracker.Pitch

擷取並設定模擬手部追蹤器的向下間距。

Microsoft.PerceptionSimulation.ISimulatedHandTracker.FrustumIgnored

擷取並設定是否忽略模擬手部追蹤器的 frustum。 忽略時,一律會顯示雙手。 當未忽略時(預設)手部只有在手部追蹤器的正向內時才會顯示。

Microsoft.PerceptionSimulation.ISimulatedHandTracker.Frustum

擷取並設定用來判斷模擬手部追蹤器是否可以看到手部的 frustum 屬性。

Microsoft.PerceptionSimulation.ISimulatedHuman

控制模擬人類的最上層介面。

public interface ISimulatedHuman 
{
    Vector3 WorldPosition { get; set; }
    float Direction { get; set; }
    float Height { get; set; }
    ISimulatedHand LeftHand { get; }
    ISimulatedHand RightHand { get; }
    ISimulatedHead Head { get; }s
    void Move(Vector3 translation);
    void Rotate(float radians);
}

Microsoft.PerceptionSimulation.ISimulatedHuman.WorldPosition

以公尺為單位,擷取並設定與世界相關的節點位置。 位置會對應到人類腳的中心點。

Microsoft.PerceptionSimulation.ISimulatedHuman.Direction

擷取並設定模擬人類臉部在世界上的方向。 0 弧度朝負 Z 軸向下。 正弧度繞 Y 軸順時針旋轉。

Microsoft.PerceptionSimulation.ISimulatedHuman.Height

擷取並設定模擬人類的高度,以公尺為單位。

Microsoft.PerceptionSimulation.ISimulatedHuman.LeftHand

擷取模擬人的左手。

Microsoft.PerceptionSimulation.ISimulatedHuman.RightHand

擷取模擬人的右手。

Microsoft.PerceptionSimulation.ISimulatedHuman.Head

擷取模擬人類頭部。

Microsoft.PerceptionSimulation.ISimulatedHuman.Move(Microsoft.PerceptionSimulation.Vector3)

以公尺為單位,將仿真的人類相對於其目前位置移動。

參數

  • translation - 要移動的翻譯,相對於目前位置。

Microsoft.PerceptionSimulation.ISimulatedHuman.Rotate(System.Single)

將仿真的人相對於其目前方向旋轉,順時針旋轉 Y 軸

參數

  • 弧度 - 繞 Y 軸旋轉的數量。

Microsoft.PerceptionSimulation.ISimulatedHuman2

藉由將 ISimulatedHuman 轉換成 ISimulatedHuman2,即可取得其他屬性

public interface ISimulatedHuman2
{
    /* New members in addition to those available on ISimulatedHuman */
    ISimulatedSixDofController LeftController { get; }
    ISimulatedSixDofController RightController { get; }
}

Microsoft.PerceptionSimulation.ISimulatedHuman2.LeftController

擷取左側 6-DOF 控制器。

Microsoft.PerceptionSimulation.ISimulatedHuman2.RightController

擷取正確的 6-DOF 控制器。

Microsoft.PerceptionSimulation.ISimulatedHand

描述模擬人類之手的介面

public interface ISimulatedHand
{
    Vector3 WorldPosition { get; }
    Vector3 Position { get; set; }
    bool Activated { [return: MarshalAs(UnmanagedType.Bool)] get; [param: MarshalAs(UnmanagedType.Bool)] set; }
    bool Visible { [return: MarshalAs(UnmanagedType.Bool)] get; }
    void EnsureVisible();
    void Move(Vector3 translation);
    void PerformGesture(SimulatedGesture gesture);
}

Microsoft.PerceptionSimulation.ISimulatedHand.WorldPosition

以公尺為單位,擷取與世界相關的節點位置。

Microsoft.PerceptionSimulation.ISimulatedHand.Position

擷取並設定模擬手相對於人類的位置,以公尺為單位。

Microsoft.PerceptionSimulation.ISimulatedHand.Activated

擷取並設定目前是否啟動手部。

Microsoft.PerceptionSimulation.ISimulatedHand.Visible

擷取 SimulatedDevice 目前是否可以看到手部(也就是說,它是否位於 HandTracker 偵測的位置)。

Microsoft.PerceptionSimulation.ISimulatedHand.EnsureVisible

移動手部,讓 SimulatedDevice 可見。

Microsoft.PerceptionSimulation.ISimulatedHand.Move(Microsoft.PerceptionSimulation.Vector3)

以公尺為單位移動模擬手部相對於其目前位置的位置。

參數

  • translation - 要翻譯模擬手部的數量。

Microsoft.PerceptionSimulation.ISimulatedHand.PerformGesture(Microsoft.PerceptionSimulation.SimulatedGesture)

使用模擬手部執行手勢。 只有在啟用手部時,系統才會偵測到它。

參數

  • 手勢 - 要執行的手勢。

Microsoft.PerceptionSimulation.ISimulatedHand2

藉由將 ISimulatedHand 轉換成 ISimulatedHand2,即可取得其他屬性。

public interface ISimulatedHand2
{
    /* New members in addition to those available on ISimulatedHand */
    Rotation3 Orientation { get; set; }
}

Microsoft.PerceptionSimulation.ISimulatedHand2.Orientation

擷取或設定模擬手部的旋轉。 正弧度會在沿著座標軸時順時針旋轉。

Microsoft.PerceptionSimulation.ISimulatedHand3

將 ISimulatedHand 轉換成 ISimulatedHand3 即可取得其他屬性

public interface ISimulatedHand3
{
    /* New members in addition to those available on ISimulatedHand and ISimulatedHand2 */
    GetJointConfiguration(SimulatedHandJoint joint, out SimulatedHandJointConfiguration jointConfiguration);
    SetJointConfiguration(SimulatedHandJoint joint, SimulatedHandJointConfiguration jointConfiguration);
    SetHandPose(SimulatedHandPose pose, bool animate);
}

Microsoft.PerceptionSimulation.ISimulatedHand3.GetJointConfiguration

取得指定關節的聯結組態。

Microsoft.PerceptionSimulation.ISimulatedHand3.SetJointConfiguration

設定指定聯結的聯結組態。

Microsoft.PerceptionSimulation.ISimulatedHand3.SetHandPose

將手設定為具有選擇性旗標的已知姿勢,以產生動畫效果。 注意:動畫不會立即反映其最終的聯結組態。

Microsoft.PerceptionSimulation.ISimulatedHead

描述模擬人類頭部的介面。

public interface ISimulatedHead
{
    Vector3 WorldPosition { get; }
    Rotation3 Rotation { get; set; }
    float Diameter { get; set; }
    void Rotate(Rotation3 rotation);
}

Microsoft.PerceptionSimulation.ISimulatedHead.WorldPosition

以公尺為單位,擷取與世界相關的節點位置。

Microsoft.PerceptionSimulation.ISimulatedHead.Rotation

擷取模擬前端的旋轉。 正弧度會在沿著座標軸時順時針旋轉。

Microsoft.PerceptionSimulation.ISimulatedHead.Diameter

擷取模擬頭部直徑。 這個值是用來判斷頭部中心(旋轉點)。

Microsoft.PerceptionSimulation.ISimulatedHead.Rotate(Microsoft.PerceptionSimulation.Rotation3)

相對於其目前的旋轉,旋轉仿真的頭部。 正弧度會在沿著座標軸時順時針旋轉。

參數

  • rotation - 要旋轉的數量。

Microsoft.PerceptionSimulation.ISimulatedHead2

將 ISimulatedHead 轉換成 ISimulatedHead2 即可取得其他屬性

public interface ISimulatedHead2
{
    /* New members in addition to those available on ISimulatedHead */
    ISimulatedEyes Eyes { get; }
}

Microsoft.PerceptionSimulation.ISimulatedHead2.Eyes

擷取模擬人的眼睛。

Microsoft.PerceptionSimulation.ISimulatedSixDofController

介面,描述與模擬人類相關聯的 6-DOF 控制器。

public interface ISimulatedSixDofController
{
    Vector3 WorldPosition { get; }
    SimulatedSixDofControllerStatus Status { get; set; }
    Vector3 Position { get; }
    Rotation3 Orientation { get; set; }
    void Move(Vector3 translation);
    void PressButton(SimulatedSixDofControllerButton button);
    void ReleaseButton(SimulatedSixDofControllerButton button);
    void GetTouchpadPosition(out float x, out float y);
    void SetTouchpadPosition(float x, float y);
}

Microsoft.PerceptionSimulation.ISimulatedSixDofController.WorldPosition

以公尺為單位,擷取與世界相關的節點位置。

Microsoft.PerceptionSimulation.ISimulatedSixDofController.Status

擷取或設定控制器的目前狀態。 控制器狀態必須設定為 [關閉] 以外的值,才能成功移動、旋轉或按下按鈕的任何呼叫。

Microsoft.PerceptionSimulation.ISimulatedSixDofController.Position

擷取或設定模擬控制器相對於人類的位置,以公尺為單位。

Microsoft.PerceptionSimulation.ISimulatedSixDofController.Orientation

擷取或設定模擬控制器的方向。

Microsoft.PerceptionSimulation.ISimulatedSixDofController.Move(Microsoft.PerceptionSimulation.Vector3)

以公尺為單位,將模擬控制器的位置相對於其目前位置移動。

參數

  • translation - 轉譯模擬控制器的數量。

Microsoft.PerceptionSimulation.ISimulatedSixDofController.PressButton(SimulatedSixDofControllerButton)

按下模擬控制器上的按鈕。 只有在啟用控制器時,系統才會偵測到它。

參數

  • button - 要按下的按鈕。

Microsoft.PerceptionSimulation.ISimulatedSixDofController.ReleaseButton(SimulatedSixDofControllerButton)

釋放模擬控制器上的按鈕。 只有在啟用控制器時,系統才會偵測到它。

參數

  • button - 要釋放的按鈕。

Microsoft.PerceptionSimulation.ISimulatedSixDofController.GetTouchpadPosition(out float, out float)

取得模擬控制器觸控板上模擬手指的位置。

參數

  • x - 手指的水準位置。
  • y - 手指的垂直位置。

Microsoft.PerceptionSimulation.ISimulatedSixDofController.SetTouchpadPosition(float, float)

設定模擬控制器觸控板上模擬手指的位置。

參數

  • x - 手指的水準位置。
  • y - 手指的垂直位置。

Microsoft.PerceptionSimulation.ISimulatedSixDofController2

將 ISimulatedSixDofController 轉換成 ISimulatedSixDofController2 即可取得其他屬性和方法

public interface ISimulatedSixDofController2
{
    /* New members in addition to those available on ISimulatedSixDofController */
    void GetThumbstickPosition(out float x, out float y);
    void SetThumbstickPosition(float x, float y);
    float BatteryLevel { get; set; }
}

Microsoft.PerceptionSimulation.ISimulatedSixDofController2.GetThumbstickPosition(out float, out float)

取得模擬控制器上模擬遊戲桿的位置。

參數

  • x - 遊戲桿的水準位置。
  • y - 遊戲桿的垂直位置。

Microsoft.PerceptionSimulation.ISimulatedSixDofController2.SetThumbstickPosition(float, float)

設定模擬控制器上模擬遊戲桿的位置。

參數

  • x - 遊戲桿的水準位置。
  • y - 遊戲桿的垂直位置。

Microsoft.PerceptionSimulation.ISimulatedSixDofController2.BatteryLevel

擷取或設定模擬控制器的電池電量。 值必須大於 0.0,且小於或等於 100.0。

Microsoft.PerceptionSimulation.ISimulatedEyes

描述模擬人類眼睛的介面。

public interface ISimulatedEyes
{
    Rotation3 Rotation { get; set; }
    void Rotate(Rotation3 rotation);
    SimulatedEyesCalibrationState CalibrationState { get; set; }
    Vector3 WorldPosition { get; }
}

Microsoft.PerceptionSimulation.ISimulatedEyes.Rotation

擷取模擬眼睛的旋轉。 正弧度會在沿著座標軸時順時針旋轉。

Microsoft.PerceptionSimulation.ISimulatedEyes.Rotate(Microsoft.PerceptionSimulation.Rotation3)

相對於其目前的旋轉,旋轉仿真的眼睛。 正弧度會在沿著座標軸時順時針旋轉。

參數

  • rotation - 要旋轉的數量。

Microsoft.PerceptionSimulation.ISimulatedEyes.CalibrationState

擷取或設定模擬眼睛的校正狀態。

Microsoft.PerceptionSimulation.ISimulatedEyes.WorldPosition

以公尺為單位,擷取與世界相關的節點位置。

Microsoft.PerceptionSimulation.ISimulationRecording

介面,用於與載入以進行播放的單一錄製互動。

public interface ISimulationRecording
{
    StreamDataTypes DataTypes { get; }
    PlaybackState State { get; }
    void Play();
    void Pause();
    void Seek(UInt64 ticks);
    void Stop();
};

Microsoft.PerceptionSimulation.ISimulationRecording.DataTypes

擷取錄製中的數據類型清單。

Microsoft.PerceptionSimulation.ISimulationRecording.State

擷取錄製的目前狀態。

Microsoft.PerceptionSimulation.ISimulationRecording.Play

啟動播放。 如果錄製暫停,播放會從暫停的位置繼續播放;如果已停止,則播放會在開頭開始。 如果已經播放,則會忽略此呼叫。

Microsoft.PerceptionSimulation.ISimulationRecording.Pause

暫停其目前位置的播放。 如果錄製停止,則會忽略呼叫。

Microsoft.PerceptionSimulation.ISimulationRecording.Seek(System.UInt64)

搜尋錄製到指定的時間(從開頭開始的 100 奈秒間隔中),並在該位置暫停。 如果時間超出錄製的結尾,則會在最後一個畫面暫停。

參數

  • ticks - 要搜尋的時間。

Microsoft.PerceptionSimulation.ISimulationRecording.Stop

停止播放,並將位置重設為開頭。

Microsoft.PerceptionSimulation.ISimulationRecordingCallback

用於在播放期間接收狀態變更的介面。

public interface ISimulationRecordingCallback
{
    void PlaybackStateChanged(PlaybackState newState);
};

Microsoft.PerceptionSimulation.ISimulationRecordingCallback.PlaybackStateChanged(Microsoft.PerceptionSimulation.PlaybackState)

當 ISimulationRecording 的播放狀態變更時呼叫。

參數

  • newState - 錄製的新狀態。

Microsoft.PerceptionSimulation.PerceptionSimulationManager

用於建立 Perception Simulation 物件的根物件。

public static class PerceptionSimulationManager
{
    public static IPerceptionSimulationManager CreatePerceptionSimulationManager(ISimulationStreamSink sink);
    public static ISimulationStreamSink CreatePerceptionSimulationRecording(string path);
    public static ISimulationRecording LoadPerceptionSimulationRecording(string path, ISimulationStreamSinkFactory factory);
    public static ISimulationRecording LoadPerceptionSimulationRecording(string path, ISimulationStreamSinkFactory factory, ISimulationRecordingCallback callback);

Microsoft.PerceptionSimulation.PerceptionSimulationManager.CreatePerceptionSimulationManager(Microsoft.PerceptionSimulation.ISimulationStreamSink)

在物件上建立 ,以產生模擬封包,並將其傳遞至提供的接收。

參數

  • 接收 - 接收將接收所有產生的封包的接收。

傳回值

建立的管理員。

Microsoft.PerceptionSimulation.PerceptionSimulationManager.CreatePerceptionSimulationRecording(System.String)

建立接收,以將所有接收的封包儲存在指定路徑的檔案中。

參數

  • path - 要建立之檔案的路徑。

傳回值

建立的接收。

Microsoft.PerceptionSimulation.PerceptionSimulationManager.LoadPerceptionSimulationRecording(System.String,Microsoft.PerceptionSimulation.ISimulationStreamSinkFactory)

從指定的檔案載入錄製。

參數

  • path - 要載入之檔案的路徑。
  • factory - 記錄在必要時用來建立 ISimulationStreamSink 的處理站。

傳回值

載入的錄製。

Microsoft.PerceptionSimulation.PerceptionSimulationManager.LoadPerceptionSimulationRecording(System.String,Microsoft.PerceptionSimulation.ISimulationStreamSinkFactory,Microsoft.PerceptionSimulation.ISimulationRecordingCallback)

從指定的檔案載入錄製。

參數

  • path - 要載入之檔案的路徑。
  • factory - 記錄在必要時用來建立 ISimulationStreamSink 的處理站。
  • callback - 回呼,接收重新降級錄製狀態的更新。

傳回值

載入的錄製。

Microsoft.PerceptionSimulation.StreamDataTypes

描述不同類型的數據流數據。

public enum StreamDataTypes
{
    None = 0x00,
    Head = 0x01,
    Hands = 0x02,
    SpatialMapping = 0x08,
    Calibration = 0x10,
    Environment = 0x20,
    SixDofControllers = 0x40,
    Eyes = 0x80,
    DisplayConfiguration = 0x100
    All = None | Head | Hands | SpatialMapping | Calibration | Environment | SixDofControllers | Eyes | DisplayConfiguration
}

Microsoft.PerceptionSimulation.StreamDataTypes.None

Sentinel 值,用來指出沒有數據流數據類型。

Microsoft.PerceptionSimulation.StreamDataTypes.Head

頭部位置和方向的數據串流。

Microsoft.PerceptionSimulation.StreamDataTypes.Hands

手部位置和手勢的數據串流。

Microsoft.PerceptionSimulation.StreamDataTypes.SpatialMapping

環境空間對應的數據流。

Microsoft.PerceptionSimulation.StreamDataTypes.校正

用於校正裝置的數據串流。 校正封包只會由遠端模式中的系統接受。

Microsoft.PerceptionSimulation.StreamDataTypes.Environment

裝置環境的數據串流。

Microsoft.PerceptionSimulation.StreamDataTypes.SixDofControllers

運動控制器的數據串流。

Microsoft.PerceptionSimulation.StreamDataTypes.Eyes

具有模擬人類眼睛的數據串流。

Microsoft.PerceptionSimulation.StreamDataTypes.DisplayConfiguration

具有裝置顯示組態的數據串流。

Microsoft.PerceptionSimulation.StreamDataTypes.All

Sentinel 值,用來指出所有記錄的數據類型。

Microsoft.PerceptionSimulation.ISimulationStreamSink

物件,從模擬數據流接收數據封包。

public interface ISimulationStreamSink
{
    void OnPacketReceived(uint length, byte[] packet);
}

Microsoft.PerceptionSimulation.ISimulationStreamSink.OnPacketReceived(uint length, byte[] packet)

接收單一封包,這是內部型別和版本設定。

參數

  • length - 封包的長度。
  • packet - 封包的數據。

Microsoft.PerceptionSimulation.ISimulationStreamSinkFactory

建立 ISimulationStreamSink 的物件。

public interface ISimulationStreamSinkFactory
{
    ISimulationStreamSink CreateSimulationStreamSink();
}

Microsoft.PerceptionSimulation.ISimulationStreamSinkFactory.CreateSimulationStreamSink()

建立 ISimulationStreamSink 的單一實例。

傳回值

建立的接收。