Coordinare la sincronizzazione del sistema con la comunicazione remota holographic e l'API Windows Mixed Reality

Con l'API Windows Mixed Reality, il sistema di coordinate utente viene eseguito il wrapping in un oggetto SpatialStationaryFrameOfReference.

Suggerimento

Un semplice esempio può essere trovato negli esempi di lettore e remoti all'interno del repository github di esempi di Holographic Remoting. Annullare ilcomment #define ENABLE_USER_COORDINATE_SYSTEM_SAMPLE all'interno dei file SampleRemoteApp.h e SamplePlayerMain.h per abilitare il codice di esempio.

Impostare e aggiornare il sistema di coordinate utente nell'app Player

Per impostare e aggiornare il sistema di coordinate utente, chiamare UpdateUserSpatialFrameOfReference il contesto del lettore e passare un sistema SpatialCoordinateSystem . Un sistema SpatialCoordinate può, ad esempio, essere un SpatialStationaryFrameOfReference, SpatialLocatorAttachedFrameOfReference o un Oggetto 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 (...)
{
}

Nota

Con l'esempio SpatialStationaryFrameOfReference, deve essere chiamato in un intervallo regolare per evitare la deriva dopo la perdita del rilevamento dei dispositivi, UpdateUserSpatialFrameOfReference anche se il sistema di coordinate utente non è cambiato!

Ottenere il sistema di coordinate utente nell'app remota

Per accedere al sistema di coordinate utente, chiamare GetUserSpatialFrameOfReference nel contesto remoto. GetUserSpatialFrameOfReference restituisce un oggetto SpatialStationaryFrameOfReference, che rappresenta il sistema di coordinate utente.

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

Vedere anche