Class SpacePin
Component helper for pinning the world locked space at a single reference point.
Namespace: Microsoft.MixedReality.WorldLocking.Core
Assembly: cs.temp.dll.dll
Syntax
public class SpacePin : MonoBehaviour
Remarks
This component captures the initial pose of its gameObject, and then a second pose. It then adds that pair to the WorldLocking Alignment Manager. The manager then negotiates between all such added pins, based on the current head pose, to generate a frame-to-frame mapping aligning the Frozen Space, i.e. Unity's Global Space, such that the pins match up as well as possible. Another way to phrase this is: Given an arbitrary pose (the "modeling pose"), and a pose aligned somehow to the real world (the "world locked pose"), apply a correction to the camera such that a virtual object with coordinates of the modeling pose will appear overlaid on the real world at the position and orientation described by the locked pose. For this component, the locked pose must come in via one of the following three APIs: SetFrozenPose(Pose) with input pose in Frozen Space, which includes pinning. SetSpongyPose(Pose) with input pose in Spongy Space, which is the space of the camera's parent, and is the same space the camera moves in, and that native APIs return values in (e.g. XR). SetLockedPose(Pose) with input pose in Locked Space, which is the space stabilized by the Frozen World engine DLL but excluding pinning. Note that since the Frozen Space is shifted by the AlignmentManager, calling SetFrozenPose(p) with the same Pose p twice is probably an error, since the Pose p would refer to different a location after the first call.
Properties
AlignmentManager
Accessor for overriding the AlignmentManager from script.
Declaration
public IAlignmentManager AlignmentManager { get; set; }
Property Value
| Type | Description |
|---|---|
| IAlignmentManager |
AnchorId
This wrapper for the anchorId is because the anchorId has to be stored as a ulong, which is the base class for the AnchorId enum. Unity only supports int-based enums, so will complain on serialization etc. for the ulong based AnchorId.
Declaration
public AnchorId AnchorId { get; }
Property Value
| Type | Description |
|---|---|
| AnchorId |
AnchorName
Provide a unique anchor name. This is used for persistence.
Declaration
protected virtual string AnchorName { get; }
Property Value
| Type | Description |
|---|---|
| String |
FragmentId
Id for fragment this pin belongs in.
Declaration
public FragmentId FragmentId { get; }
Property Value
| Type | Description |
|---|---|
| FragmentId |
GlobalFromParent
Return the Pose transforming from parent space to global space.
Declaration
protected Pose GlobalFromParent { get; }
Property Value
| Type | Description |
|---|---|
| Pose |
Remarks
If the SpacePin has no parent, this will be the identity Pose.
LockedPose
Accessor for world locked pose for derived classes.
Declaration
public Pose LockedPose { get; protected set; }
Property Value
| Type | Description |
|---|---|
| Pose |
Manager
Read only access to manager dependency from derived classes.
Declaration
protected WorldLockingManager Manager { get; }
Property Value
| Type | Description |
|---|---|
| WorldLockingManager |
ModelingPoseGlobal
First of the pair of poses submitted to alignment manager for alignment.
Declaration
public Pose ModelingPoseGlobal { get; }
Property Value
| Type | Description |
|---|---|
| Pose |
ModelPositionSource
Where to find model space position on target. Transform is preferable, but if transforms are baked in, renderer or collider may be more appropriate.
Declaration
public SpacePin.ModelPositionSourceEnum ModelPositionSource { get; set; }
Property Value
| Type | Description |
|---|---|
| SpacePin.ModelPositionSourceEnum |
Remarks
Note that orientation always comes from transform, as renderer and collider bounds have no orientation.
ParentFromGlobal
Return the Pose transforming from global space to the parent's space.
Declaration
protected Pose ParentFromGlobal { get; }
Property Value
| Type | Description |
|---|---|
| Pose |
PinActive
Whether this space pin is in active use pinning space
Declaration
public bool PinActive { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
RestorePoseLocal
Pose to restore after manipulation (if any).
Declaration
protected Pose RestorePoseLocal { get; }
Property Value
| Type | Description |
|---|---|
| Pose |
Methods
ExtractModelPose()
Declaration
protected Pose ExtractModelPose()
Returns
| Type | Description |
|---|---|
| Pose |
ExtractModelPoseFromCollider()
Declaration
protected Pose ExtractModelPoseFromCollider()
Returns
| Type | Description |
|---|---|
| Pose |
ExtractModelPoseFromRenderer()
Declaration
protected Pose ExtractModelPoseFromRenderer()
Returns
| Type | Description |
|---|---|
| Pose |
ExtractModelPoseFromTransform()
Declaration
protected Pose ExtractModelPoseFromTransform()
Returns
| Type | Description |
|---|---|
| Pose |
ForceAttachment()
Ensure that there is an attachment, and it is positioned up to date.
Declaration
protected void ForceAttachment()
GetModelPoseFromGlobalPosition(Vector3)
Declaration
protected Pose GetModelPoseFromGlobalPosition(Vector3 globalPosition)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | globalPosition |
Returns
| Type | Description |
|---|---|
| Pose |
OnDestroy()
On destroy, unregister for the loaded event.
Declaration
protected virtual void OnDestroy()
OnLocationUpdate(Pose)
Callback for refit operations. Apply adjustment transform to locked pose.
Declaration
protected virtual void OnLocationUpdate(Pose adjustment)
Parameters
| Type | Name | Description |
|---|---|---|
| Pose | adjustment | Adjustment to apply. |
PushAlignmentData(IAlignmentManager)
Communicate the data from this point to the alignment manager.
Declaration
protected void PushAlignmentData(IAlignmentManager mgr)
Parameters
| Type | Name | Description |
|---|---|---|
| IAlignmentManager | mgr |
ReleaseAttachment()
Dispose of any previously created attachment point.
Declaration
protected void ReleaseAttachment()
Reset()
Go back to initial state, including removal of self-artifacts from alignment manager.
Declaration
public virtual void Reset()
ResetModelingPose()
Reset the modeling pose to the current transform.
Declaration
public virtual void ResetModelingPose()
Remarks
In normal usage, the modeling pose is the transform as set in Unity and as cached at start. In some circumstances, such as creation of pins from script, it may be convenient to set the transform after Start(). In this case, the change of transform should be recorded by a call to ResetModelingPose(). This must happen before the modeling pose is used implicitly by a call to set the virtual pose, via SetFrozenPose, SetSpongyPose, or SetLockedPose.
RestoreOnLoad()
Callback on notification of the alignment manager's database to check if this preset has been persisted, and restore it to operation if it has.
Declaration
protected virtual void RestoreOnLoad()
SendAlignmentData(IAlignmentManager)
Notify the manager that all necessary updates have been submitted and are ready for processing.
Declaration
protected void SendAlignmentData(IAlignmentManager mgr)
Parameters
| Type | Name | Description |
|---|---|---|
| IAlignmentManager | mgr |
SetFrozenPose(Pose)
Transform pose to Locked Space and pass through.
Declaration
public void SetFrozenPose(Pose frozenPose)
Parameters
| Type | Name | Description |
|---|---|---|
| Pose | frozenPose | Pose in frozen space. |
SetLockedPose(Pose)
Record the locked pose and push data to the manager.
Declaration
public virtual void SetLockedPose(Pose lockedPose)
Parameters
| Type | Name | Description |
|---|---|---|
| Pose | lockedPose |
SetSpongyPose(Pose)
Transform pose to Locked Space and pass through.
Declaration
public void SetSpongyPose(Pose spongyPose)
Parameters
| Type | Name | Description |
|---|---|---|
| Pose | spongyPose | Pose in spongy space. |
Start()
Declaration
protected virtual void Start()