홀로그램 원격 및 Windows Mixed Reality API를 사용하여 시스템 동기화 조정

Windows Mixed Reality API를 사용하면 사용자 좌표계가 SpatialStationaryFrameOfReference로 래핑됩니다.

간단한 예제는 홀로그램 원격 샘플 github 리포지토리 내의 원격 및 플레이어 샘플에서 찾을 수 있습니다. 샘플 코드를 사용하도록 설정하려면 SampleRemoteApp.h 및 SamplePlayerMain.h 파일 내에서 주석 #define ENABLE_USER_COORDINATE_SYSTEM_SAMPLE 처리를 제거합니다.

플레이어 앱에서 사용자 좌표계 설정 및 업데이트

사용자 좌표계를 설정하고 업데이트하려면 플레이어 컨텍스트에서 를 호출 UpdateUserSpatialFrameOfReference 하고 SpatialCoordinateSystem을 전달합니다. SpatialCoordinateSystem은 예를 들어 SpatialStationaryFrameOfReference, SpatialLocatorAttachedFrameOfReference 또는 SpatialAnchor일 수 있습니다.

// In the Player app:

// Create a stationary frame of reference
winrt::Windows::Perception::Spatial::SpatialStationaryFrameOfReference spatialFrameOfReference = nullptr;
winrt::Windows::Perception::Spatial::SpatialLocator spatialLocator = winrt::Windows::Perception::Spatial::SpatialLocator::GetDefault();
if (spatialLocator != nullptr)
{
    spatialFrameOfReference = spatialLocator.CreateStationaryFrameOfReferenceAtCurrentLocation(float3(0.0f, 0.0f, 0.0f), quaternion(0, 0, 0, 1), 0.0);
}

...

// Update the user coordinate system with the coordinate system of the spatial frame of reference
try
{
    SpatialCoordinateSystem userCoordinateSystem = spatialFrameOfReference.CoordinateSystem();
    m_playerContext.UpdateUserSpatialFrameOfReference(userCoordinateSystem);
}
catch (...)
{
}

참고

샘플 SpatialStationaryFrameOfReferenceUpdateUserSpatialFrameOfReference를 사용하면 사용자 좌표계가 변경되지 않더라도 디바이스 추적이 손실된 후 표류하지 않도록 정기적인 간격으로 호출해야 합니다.

원격 앱에서 사용자 좌표계 가져오기

사용자 좌표계에 액세스하려면 원격 컨텍스트에서 를 호출 GetUserSpatialFrameOfReference 합니다. GetUserSpatialFrameOfReference 는 사용자 좌표계를 나타내는 SpatialStationaryFrameOfReference를 반환합니다.

// In the Remote app:
winrt::Windows::Perception::Spatial::SpatialStationaryFrameOfReference spatialUserFrameOfReference = m_remoteContext.GetUserSpatialFrameOfReference();

참고 항목