Tilt Five™ Unity API  1.4.1
TiltFive.TrackableCore< TSettings, TState > Class Template Referenceabstract

Protected Member Functions

void Reset (TSettings settings)
 
virtual void Update (TSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 
abstract void SetDefaultPoseGameboardSpace (TSettings settings)
 Gets the default pose of the tracked object. More...
 
abstract void SetPoseGameboardSpace (in TState state, TSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 Sets the pose values of the tracked object in Unity World Space More...
 
abstract void SetInvalidPoseGameboardSpace (in TState state, TSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 Sets the pose values of the tracked object in Unity World Space when we already know the pose is invalid. More...
 
abstract void SetPoseUnityWorldSpace (ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 Sets the pose values of the tracked object in Unity World Space More...
 
abstract bool TryCheckConnected (out bool connected)
 Determines whether the tracked object is still connected. More...
 
abstract bool TryGetStateFromPlugin (out TState state, out bool poseIsValid, GameBoardSettings gameboardSettings)
 Gets the latest pose for the tracked object from the native plugin. More...
 
abstract void SetDrivenObjectTransform (TSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 Sets the pose of the object(s) being driven by TrackableCore. More...
 

Static Protected Member Functions

static Vector3 ConvertPosGBDToUGBD (Vector3 pos_GBD)
 
static Pose GameboardToWorldSpace (Pose pose_GameboardSpace, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 
static Vector3 GameboardToWorldSpace (Vector3 pos_UGBD, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 
static Vector3 WorldToGameboardSpace (Vector3 pos_UWRLD, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 
static Quaternion GameboardToWorldSpace (Quaternion rotToUGBD_OBJ, GameBoardSettings gameboardSettings)
 
static Quaternion WorldToGameboardSpace (Quaternion rotToUWRLD_OBJ, GameBoardSettings gameboardSettings)
 

Protected Attributes

Pose pose_UGBD
 
Pose pose_UWRLD
 
bool isTracked = false
 
bool isConnected = false
 
Pose gameboardPos_UWRLD
 The pose of the gameboard reference frame w.r.t. the Unity world-space reference frame. More...
 

Properties

Pose Pose_GameboardSpace [get]
 The pose of the trackable w.r.t. the gameboard reference frame. More...
 
Pose Pose_UnityWorldSpace [get]
 The Pose of the trackable in Unity world space. More...
 
bool IsTracked [get]
 Whether or not the trackable is being tracked. More...
 
bool IsConnected [get]
 Whether or not the trackable is connected. More...
 

Detailed Description

Type Constraints
TSettings :TrackableSettings 

Definition at line 22 of file TrackableCore.cs.

Member Function Documentation

◆ ConvertPosGBDToUGBD()

static Vector3 TiltFive.TrackableCore< TSettings, TState >.ConvertPosGBDToUGBD ( Vector3  pos_GBD)
staticprotected

Definition at line 99 of file TrackableCore.cs.

100  {
101  // Swap Y and Z to change between GBD and UGBD
102  var pos_UGBD = new Vector3(pos_GBD.x, pos_GBD.z, pos_GBD.y);
103  return pos_UGBD;
104  }

◆ GameboardToWorldSpace() [1/3]

static Pose TiltFive.TrackableCore< TSettings, TState >.GameboardToWorldSpace ( Pose  pose_GameboardSpace,
ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
staticprotected

Definition at line 106 of file TrackableCore.cs.

108  {
109  float scaleToUWRLD_UGBD = scaleSettings.GetScaleToUWRLD_UGBD(gameboardSettings.gameBoardScale);
110 
111  Vector3 pos_UWRLD = gameboardSettings.currentGameBoard.rotation *
112  (scaleToUWRLD_UGBD * pose_GameboardSpace.position) + gameboardSettings.gameBoardCenter;
113 
114  Quaternion rotToUWRLD_OBJ = GameboardToWorldSpace(pose_GameboardSpace.rotation, gameboardSettings);
115 
116  return new Pose(pos_UWRLD, rotToUWRLD_OBJ);
117  }
static Pose GameboardToWorldSpace(Pose pose_GameboardSpace, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)

References TiltFive.GameBoardSettings.currentGameBoard, TiltFive.GameBoardSettings.gameBoardCenter, TiltFive.GameBoardSettings.gameBoardScale, TiltFive.ScaleSettings.GetScaleToUWRLD_UGBD(), and TiltFive.UniformScaleTransform.rotation.

◆ GameboardToWorldSpace() [2/3]

static Quaternion TiltFive.TrackableCore< TSettings, TState >.GameboardToWorldSpace ( Quaternion  rotToUGBD_OBJ,
GameBoardSettings  gameboardSettings 
)
staticprotected

Definition at line 140 of file TrackableCore.cs.

141  {
142  var rotToUWRLD_UGBD = gameboardSettings.currentGameBoard.rotation;
143  var rotToUWRLD_OBJ = rotToUWRLD_UGBD * rotToUGBD_OBJ;
144 
145  return rotToUWRLD_OBJ;
146  }

References TiltFive.GameBoardSettings.currentGameBoard, and TiltFive.UniformScaleTransform.rotation.

◆ GameboardToWorldSpace() [3/3]

static Vector3 TiltFive.TrackableCore< TSettings, TState >.GameboardToWorldSpace ( Vector3  pos_UGBD,
ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
staticprotected

Definition at line 119 of file TrackableCore.cs.

121  {
122  float scaleToUWRLD_UGBD = scaleSettings.GetScaleToUWRLD_UGBD(gameboardSettings.gameBoardScale);
123 
124  return gameboardSettings.currentGameBoard.rotation *
125  (scaleToUWRLD_UGBD * pos_UGBD) + gameboardSettings.gameBoardCenter;
126  }

References TiltFive.GameBoardSettings.currentGameBoard, TiltFive.GameBoardSettings.gameBoardCenter, TiltFive.GameBoardSettings.gameBoardScale, TiltFive.ScaleSettings.GetScaleToUWRLD_UGBD(), and TiltFive.UniformScaleTransform.rotation.

◆ Reset()

void TiltFive.TrackableCore< TSettings, TState >.Reset ( TSettings  settings)
protected

Definition at line 61 of file TrackableCore.cs.

62  {
64  isTracked = false;
65  }
abstract void SetDefaultPoseGameboardSpace(TSettings settings)
Gets the default pose of the tracked object.

References TiltFive.TrackableCore< TSettings, TState >.isTracked, and TiltFive.TrackableCore< TSettings, TState >.SetDefaultPoseGameboardSpace().

◆ SetDefaultPoseGameboardSpace()

abstract void TiltFive.TrackableCore< TSettings, TState >.SetDefaultPoseGameboardSpace ( TSettings  settings)
protectedpure virtual

Gets the default pose of the tracked object.

Parameters
settings
Returns

Referenced by TiltFive.TrackableCore< TSettings, TState >.Reset().

◆ SetDrivenObjectTransform()

abstract void TiltFive.TrackableCore< TSettings, TState >.SetDrivenObjectTransform ( TSettings  settings,
ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
protectedpure virtual

Sets the pose of the object(s) being driven by TrackableCore.

Parameters
settings
scaleSettings
gameboardSettings

Referenced by TiltFive.TrackableCore< TSettings, TState >.Update().

◆ SetInvalidPoseGameboardSpace()

abstract void TiltFive.TrackableCore< TSettings, TState >.SetInvalidPoseGameboardSpace ( in TState  state,
TSettings  settings,
ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
protectedpure virtual

Sets the pose values of the tracked object in Unity World Space when we already know the pose is invalid.

Parameters
state
settings
scaleSettings
gameboardSettings

Referenced by TiltFive.TrackableCore< TSettings, TState >.Update().

◆ SetPoseGameboardSpace()

abstract void TiltFive.TrackableCore< TSettings, TState >.SetPoseGameboardSpace ( in TState  state,
TSettings  settings,
ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
protectedpure virtual

Sets the pose values of the tracked object in Unity World Space

Parameters
state
settings
scaleSettings
gameboardSettings

Referenced by TiltFive.TrackableCore< TSettings, TState >.Update().

◆ SetPoseUnityWorldSpace()

abstract void TiltFive.TrackableCore< TSettings, TState >.SetPoseUnityWorldSpace ( ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
protectedpure virtual

Sets the pose values of the tracked object in Unity World Space

Parameters
scaleSettings
gameboardSettings

Implemented in TiltFive.Wand.WandCore, and TiltFive.Glasses.BaseGlassesCore.

Referenced by TiltFive.TrackableCore< TSettings, TState >.Update().

◆ TryCheckConnected()

abstract bool TiltFive.TrackableCore< TSettings, TState >.TryCheckConnected ( out bool  connected)
protectedpure virtual

Determines whether the tracked object is still connected.

Parameters
connected
Returns

Implemented in TiltFive.Wand.WandCore, and TiltFive.Glasses.BaseGlassesCore.

Referenced by TiltFive.TrackableCore< TSettings, TState >.Update().

◆ TryGetStateFromPlugin()

abstract bool TiltFive.TrackableCore< TSettings, TState >.TryGetStateFromPlugin ( out TState  state,
out bool  poseIsValid,
GameBoardSettings  gameboardSettings 
)
protectedpure virtual

Gets the latest pose for the tracked object from the native plugin.

Parameters
state
poseIsValid
gameboardSettings
Returns

Referenced by TiltFive.TrackableCore< TSettings, TState >.Update().

◆ Update()

virtual void TiltFive.TrackableCore< TSettings, TState >.Update ( TSettings  settings,
ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
protectedvirtual

Definition at line 68 of file TrackableCore.cs.

69  {
70  if(settings == null)
71  {
72  Log.Error("TrackableSettings configuration required for tracking updates.");
73  return;
74  }
75 
76  // Get the game board pose.
77  gameboardPos_UWRLD = new Pose(gameboardSettings.gameBoardCenter,
78  Quaternion.Inverse(gameboardSettings.currentGameBoard.rotation));
79 
80  var successfullyConnected = TryCheckConnected(out isConnected) && isConnected;
81  var successfullyGotState = TryGetStateFromPlugin(out var state, out bool poseIsValid, gameboardSettings);
82 
83  if (successfullyConnected && successfullyGotState && poseIsValid)
84  {
85  isTracked = true;
86  SetPoseGameboardSpace(state, settings, scaleSettings, gameboardSettings);
87  }
88  else
89  {
90  isTracked = false;
91  SetInvalidPoseGameboardSpace(state, settings, scaleSettings, gameboardSettings);
92  }
93 
94  SetPoseUnityWorldSpace(scaleSettings, gameboardSettings);
95 
96  SetDrivenObjectTransform(settings, scaleSettings, gameboardSettings);
97  }
The Logger.
Definition: Log.cs:42
static void Error(string m, params object[] list)
ERROR logging function call.
Definition: Log.cs:127
abstract bool TryCheckConnected(out bool connected)
Determines whether the tracked object is still connected.
abstract void SetInvalidPoseGameboardSpace(in TState state, TSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
Sets the pose values of the tracked object in Unity World Space when we already know the pose is inva...
Pose gameboardPos_UWRLD
The pose of the gameboard reference frame w.r.t. the Unity world-space reference frame.
abstract void SetDrivenObjectTransform(TSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
Sets the pose of the object(s) being driven by TrackableCore.
abstract bool TryGetStateFromPlugin(out TState state, out bool poseIsValid, GameBoardSettings gameboardSettings)
Gets the latest pose for the tracked object from the native plugin.
abstract void SetPoseUnityWorldSpace(ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
Sets the pose values of the tracked object in Unity World Space
abstract void SetPoseGameboardSpace(in TState state, TSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
Sets the pose values of the tracked object in Unity World Space

References TiltFive.GameBoardSettings.currentGameBoard, TiltFive.Logging.Log.Error(), TiltFive.GameBoardSettings.gameBoardCenter, TiltFive.TrackableCore< TSettings, TState >.gameboardPos_UWRLD, TiltFive.TrackableCore< TSettings, TState >.isConnected, TiltFive.TrackableCore< TSettings, TState >.isTracked, TiltFive.UniformScaleTransform.rotation, TiltFive.TrackableCore< TSettings, TState >.SetDrivenObjectTransform(), TiltFive.TrackableCore< TSettings, TState >.SetInvalidPoseGameboardSpace(), TiltFive.TrackableCore< TSettings, TState >.SetPoseGameboardSpace(), TiltFive.TrackableCore< TSettings, TState >.SetPoseUnityWorldSpace(), TiltFive.TrackableCore< TSettings, TState >.TryCheckConnected(), and TiltFive.TrackableCore< TSettings, TState >.TryGetStateFromPlugin().

◆ WorldToGameboardSpace() [1/2]

static Quaternion TiltFive.TrackableCore< TSettings, TState >.WorldToGameboardSpace ( Quaternion  rotToUWRLD_OBJ,
GameBoardSettings  gameboardSettings 
)
staticprotected

Definition at line 148 of file TrackableCore.cs.

149  {
150  var rotToUWRLD_UGBD = gameboardSettings.currentGameBoard.rotation;
151  var rotToUGBD_UWRLD = Quaternion.Inverse(rotToUWRLD_UGBD);
152  var rotToUGBD_OBJ = rotToUGBD_UWRLD * rotToUWRLD_OBJ;
153 
154  return rotToUGBD_OBJ;
155 
156  }

References TiltFive.GameBoardSettings.currentGameBoard, and TiltFive.UniformScaleTransform.rotation.

◆ WorldToGameboardSpace() [2/2]

static Vector3 TiltFive.TrackableCore< TSettings, TState >.WorldToGameboardSpace ( Vector3  pos_UWRLD,
ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
staticprotected

Definition at line 128 of file TrackableCore.cs.

130  {
131  float scaleToUWRLD_UGBD = scaleSettings.GetScaleToUWRLD_UGBD(gameboardSettings.gameBoardScale);
132  var rotToUWRLD_UGBD = gameboardSettings.currentGameBoard.rotation;
133  var pos_UGBD = pos_UWRLD - gameboardSettings.gameBoardCenter;
134  pos_UGBD = Quaternion.Inverse(rotToUWRLD_UGBD) * pos_UGBD;
135  pos_UGBD /= scaleToUWRLD_UGBD;
136 
137  return pos_UGBD;
138  }

References TiltFive.GameBoardSettings.currentGameBoard, TiltFive.GameBoardSettings.gameBoardCenter, TiltFive.GameBoardSettings.gameBoardScale, TiltFive.ScaleSettings.GetScaleToUWRLD_UGBD(), and TiltFive.UniformScaleTransform.rotation.

Member Data Documentation

◆ gameboardPos_UWRLD

Pose TiltFive.TrackableCore< TSettings, TState >.gameboardPos_UWRLD
protected

The pose of the gameboard reference frame w.r.t. the Unity world-space reference frame.

Definition at line 54 of file TrackableCore.cs.

Referenced by TiltFive.TrackableCore< TSettings, TState >.Update().

◆ isConnected

bool TiltFive.TrackableCore< TSettings, TState >.isConnected = false
protected

Definition at line 48 of file TrackableCore.cs.

Referenced by TiltFive.TrackableCore< TSettings, TState >.Update().

◆ isTracked

bool TiltFive.TrackableCore< TSettings, TState >.isTracked = false
protected

◆ pose_UGBD

Pose TiltFive.TrackableCore< TSettings, TState >.pose_UGBD
protected

Definition at line 30 of file TrackableCore.cs.

◆ pose_UWRLD

Pose TiltFive.TrackableCore< TSettings, TState >.pose_UWRLD
protected

Definition at line 36 of file TrackableCore.cs.

Property Documentation

◆ IsConnected

bool TiltFive.TrackableCore< TSettings, TState >.IsConnected
get

Whether or not the trackable is connected.

Definition at line 47 of file TrackableCore.cs.

47 { get => isConnected; }

◆ IsTracked

bool TiltFive.TrackableCore< TSettings, TState >.IsTracked
get

Whether or not the trackable is being tracked.

Definition at line 41 of file TrackableCore.cs.

41 { get => isTracked; }

◆ Pose_GameboardSpace

Pose TiltFive.TrackableCore< TSettings, TState >.Pose_GameboardSpace
get

The pose of the trackable w.r.t. the gameboard reference frame.

Definition at line 29 of file TrackableCore.cs.

29 { get => pose_UGBD; }

◆ Pose_UnityWorldSpace

Pose TiltFive.TrackableCore< TSettings, TState >.Pose_UnityWorldSpace
get

The Pose of the trackable in Unity world space.

Definition at line 35 of file TrackableCore.cs.

35 { get => pose_UWRLD; }

The documentation for this class was generated from the following file: