Tilt Five™ Unity API  1.3.0
 
Loading...
Searching...
No Matches
TiltFive.Wand.WandCore Class Reference

Internal Wand core runtime. More...

Inheritance diagram for TiltFive.Wand.WandCore:
TiltFive.TrackableCore< WandSettings, T5_ControllerState >

Public Member Functions

 WandCore (GlassesHandle glassesHandle, ControllerIndex controllerIndex)
 
virtual void GetLatestInputs ()
 
bool GetButton (WandButton button)
 
bool TryGetButton (WandButton button, out bool pressed)
 
bool GetButtonDown (WandButton button)
 
bool TryGetButtonDown (WandButton button, out bool buttonDown)
 
bool GetButtonUp (WandButton button)
 
bool TryGetButtonUp (WandButton button, out bool buttonUp)
 
Vector2 GetStickTilt ()
 
bool TryGetStickTilt (out Vector2 stickTilt)
 
float GetTrigger ()
 
bool TryGetTrigger (out float triggerDisplacement)
 
new void Reset (WandSettings wandSettings)
 
virtual new void Update (WandSettings wandSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
 
virtual void Dispose ()
 

Public Attributes

readonly GlassesHandle glassesHandle
 
readonly ControllerIndex controllerIndex
 
Pose fingertipsPose_GameboardSpace = new Pose(DEFAULT_WAND_POSITION_GAME_BOARD_SPACE, Quaternion.identity)
 
Pose aimPose_GameboardSpace = new Pose(DEFAULT_WAND_POSITION_GAME_BOARD_SPACE, Quaternion.identity)
 
Pose fingertipsPose_UnityWorldSpace
 
Pose aimPose_UnityWorldSpace
 

Protected Member Functions

override void SetDefaultPoseGameboardSpace (WandSettings settings)
 
override void SetPoseUnityWorldSpace (ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
 Sets the pose values of the tracked object in Unity World Space.
 
override bool TryCheckConnected (out bool connected)
 Determines whether the tracked object is still connected.
 
override bool TryGetStateFromPlugin (out T5_ControllerState controllerState, out bool poseIsValid, GameBoardSettings gameBoardSettings)
 
override void SetPoseGameboardSpace (in T5_ControllerState controllerState, WandSettings wandSettings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 
override void SetInvalidPoseGameboardSpace (in T5_ControllerState t5_ControllerState, WandSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 Handle setting the wand pose when we know the controller state isn't valid.
 
override void SetDrivenObjectTransform (WandSettings wandSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
 
Quaternion CalculateRotation (Quaternion rotToWND_GBD)
 
void ProcessTrackingData (Vector3 gripPosition_UGBD, Vector3 fingertipsPosition_UGBD, Vector3 aimPosition_UGBD, Quaternion rotToUGBD_WND, WandSettings wandSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings, out Pose gripPose_UGBD, out Pose fingertipsPose_UGBD, out Pose aimPose_UGBD)
 
Pose FilterTrackingPointPose (Pose staleGripPointPose, Pose staleTrackingPointPose, Pose newTrackingPointPose, float trackingPointOffsetDistance, WandSettings settings)
 
- Protected Member Functions inherited from TiltFive.TrackableCore< WandSettings, T5_ControllerState >
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.
 
abstract void SetPoseGameboardSpace (in TState state, TSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 Sets the pose values of the tracked object in Unity World Space.
 
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.
 
abstract void SetPoseUnityWorldSpace (ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 Sets the pose values of the tracked object in Unity World Space.
 
abstract bool TryCheckConnected (out bool connected)
 Determines whether the tracked object is still connected.
 
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 SetDrivenObjectTransform (TSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 Sets the pose of the object(s) being driven by TrackableCore.
 

Static Protected Member Functions

static Pose GetDefaultPoseGameboardSpace (WandSettings settings)
 
- Static Protected Member Functions inherited from TiltFive.TrackableCore< WandSettings, T5_ControllerState >
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 Quaternion GameboardToWorldSpace (Quaternion rotToUGBD_OBJ, GameBoardSettings gameboardSettings)
 
static Vector3 WorldToGameboardSpace (Vector3 pos_UWRLD, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
 
static Quaternion WorldToGameboardSpace (Quaternion rotToUWRLD_OBJ, GameBoardSettings gameboardSettings)
 

Protected Attributes

T5_ControllerStatecurrentState
 
T5_ControllerStatepreviousState
 
- Protected Attributes inherited from TiltFive.TrackableCore< WandSettings, T5_ControllerState >
Pose pose_UGBD
 
Pose pose_UWRLD
 
bool isTracked
 
bool isConnected
 
Pose gameboardPos_UWRLD
 The pose of the gameboard reference frame w.r.t. the Unity world-space reference frame.
 

Properties

Pose gripPose_UnityWorldSpace [get]
 
- Properties inherited from TiltFive.TrackableCore< WandSettings, T5_ControllerState >
Pose Pose_GameboardSpace [get]
 The pose of the trackable w.r.t. the gameboard reference frame.
 
Pose Pose_UnityWorldSpace [get]
 The Pose of the trackable in Unity world space.
 
bool IsTracked [get]
 Whether or not the trackable is being tracked.
 
bool IsConnected [get]
 Whether or not the trackable is connected.
 

Detailed Description

Internal Wand core runtime.

Definition at line 640 of file Wand.cs.

Constructor & Destructor Documentation

◆ WandCore()

TiltFive.Wand.WandCore.WandCore ( GlassesHandle  glassesHandle,
ControllerIndex  controllerIndex 
)

Definition at line 662 of file Wand.cs.

663 {
664 this.glassesHandle = glassesHandle;
665 this.controllerIndex = controllerIndex;
666
667 Glasses.TryGetFriendlyName(glassesHandle, out var friendlyName);
668 Log.Info($"Glasses {glassesHandle} (\"{friendlyName}\") {Enum.GetName(typeof(ControllerIndex), controllerIndex)} Wand connected");
669 }
$ Glasses
Definition: Glasses.cs:862
The Logger.
Definition: Log.cs:42
static void Info(string m, params object[] list)
INFO logging function call.
Definition: Log.cs:140
readonly GlassesHandle glassesHandle
Definition: Wand.cs:644
readonly ControllerIndex controllerIndex
Definition: Wand.cs:645

References TiltFive.Wand.WandCore.controllerIndex, TiltFive.Wand.WandCore.glassesHandle, TiltFive.Logging.Log.Info(), and TiltFive.Glasses.TryGetFriendlyName().

Member Function Documentation

◆ CalculateRotation()

Quaternion TiltFive.Wand.WandCore.CalculateRotation ( Quaternion  rotToWND_GBD)
protected

Definition at line 944 of file Wand.cs.

945 {
946 Quaternion rotToDW_GBD = Quaternion.AngleAxis(90f, Vector3.right);
947 Quaternion rotToGBD_DW = Quaternion.Inverse(rotToDW_GBD);
948 Quaternion rotToWND_DW = rotToWND_GBD * rotToGBD_DW;
949 Quaternion rotToUGBD_UWND = new Quaternion(rotToWND_DW.x, -rotToWND_DW.y, rotToWND_DW.z, rotToWND_DW.w);
950 return rotToUGBD_UWND;
951 }

Referenced by TiltFive.Wand.WandCore.SetPoseGameboardSpace().

◆ Dispose()

virtual void TiltFive.Wand.WandCore.Dispose ( )
virtual

Definition at line 934 of file Wand.cs.

935 {
936 Log.Info($"Glasses {glassesHandle} {controllerIndex} Wand disconnected");
937 }

References TiltFive.Logging.Log.Info().

◆ FilterTrackingPointPose()

Pose TiltFive.Wand.WandCore.FilterTrackingPointPose ( Pose  staleGripPointPose,
Pose  staleTrackingPointPose,
Pose  newTrackingPointPose,
float  trackingPointOffsetDistance,
WandSettings  settings 
)
protected

Definition at line 985 of file Wand.cs.

987 {
988 if (!isTracked && settings.RejectUntrackedPositionData)
989 {
990 switch (settings.FailureMode)
991 {
992 default:
993 // If we have an undefined FailureMode for some reason, fall through to FreezePosition
994 case TrackableSettings.TrackingFailureMode.FreezePosition:
995 // We need to determine where to put each tracking point.
996 // We only want to freeze the position of the grip point while allowing the other
997 // points to rotate around it, colinear to the grip point's forward vector.
998 var extrapolatedPosition = staleGripPointPose.position +
999 Quaternion.Inverse(newTrackingPointPose.rotation) * Vector3.forward * trackingPointOffsetDistance;
1000 return new Pose(extrapolatedPosition, newTrackingPointPose.rotation);
1001 case TrackableSettings.TrackingFailureMode.FreezePositionAndRotation:
1002 return staleTrackingPointPose;
1003 case TrackableSettings.TrackingFailureMode.SnapToDefault:
1004 return GetDefaultPoseGameboardSpace(settings);
1005 }
1006 }
1007 else
1008 {
1009 return newTrackingPointPose;
1010 }
1011 }
static Pose GetDefaultPoseGameboardSpace(WandSettings settings)
Definition: Wand.cs:810

References TiltFive.TrackableSettings.FailureMode, TiltFive.Wand.WandCore.GetDefaultPoseGameboardSpace(), TiltFive.TrackableCore< WandSettings, T5_ControllerState >.isTracked, and TiltFive.TrackableSettings.RejectUntrackedPositionData.

Referenced by TiltFive.Wand.WandCore.ProcessTrackingData().

◆ GetButton()

bool TiltFive.Wand.WandCore.GetButton ( WandButton  button)

Definition at line 692 of file Wand.cs.

693 {
694 // If the wand isn't connected, GetButton() should return a default value of false.
695 return currentState?.GetButton(button) ?? false;
696 }
T5_ControllerState? currentState
Definition: Wand.cs:654

References TiltFive.Wand.WandCore.currentState.

◆ GetButtonDown()

bool TiltFive.Wand.WandCore.GetButtonDown ( WandButton  button)

Definition at line 706 of file Wand.cs.

707 {
708
709 // If the current wand state is null, the wand isn't connected.
710 // If so, let the application assume the user isn't pressing the button currently.
711 var pressed = currentState?.GetButton(button) ?? false;
712
713 // If the previous wand state is null, the wand wasn't connected.
714 // If so, let the application assume the user wasn't pressing the button last frame.
715 var previouslyPressed = previousState?.GetButton(button) ?? false;
716
717 // The wand could potentially connect while the user is holding a button, so just report the button state.
718 if (!previousState.HasValue && currentState.HasValue)
719 {
720 return pressed;
721 }
722 // Return true if the button is currently pressed, but was unpressed on the previous frame.
723 return pressed && !previouslyPressed;
724 }
T5_ControllerState? previousState
Definition: Wand.cs:655

References TiltFive.Wand.WandCore.currentState, and TiltFive.Wand.WandCore.previousState.

Referenced by TiltFive.Wand.WandCore.TryGetButtonDown().

◆ GetButtonUp()

bool TiltFive.Wand.WandCore.GetButtonUp ( WandButton  button)

Definition at line 733 of file Wand.cs.

734 {
735 // If the current wand state is null, the wand isn't connected.
736 // If so, let the application assume the user isn't pressing the button currently.
737 var pressed = currentState?.GetButton(button) ?? false;
738
739 // If the previous wand state is null, the wand wasn't connected.
740 // If so, let the application assume the user wasn't pressing the button last frame.
741 var previouslyPressed = previousState?.GetButton(button) ?? false;
742
743 // Return true if the button is currently released, but was pressed on the previous frame.
744 return previousState.HasValue
745 ? !pressed && previouslyPressed
746 // If the current state exists but the previous state was null, the wand has just connected.
747 // There's no way for the button to be pressed during the previous frame,
748 // so there's no way for the button to have been released this frame. Always return false.
749 : false;
750 }

References TiltFive.Wand.WandCore.currentState, and TiltFive.Wand.WandCore.previousState.

Referenced by TiltFive.Wand.WandCore.TryGetButtonUp().

◆ GetDefaultPoseGameboardSpace()

static Pose TiltFive.Wand.WandCore.GetDefaultPoseGameboardSpace ( WandSettings  settings)
staticprotected

Definition at line 810 of file Wand.cs.

811 {
812 Vector3 defaultPosition = DEFAULT_WAND_POSITION_GAME_BOARD_SPACE;
813
815 * (settings.controllerIndex == ControllerIndex.Right ? 1f : -1f);
816 return new Pose(defaultPosition, DEFAULT_WAND_ROTATION_GAME_BOARD_SPACE);
817 }
static readonly Vector3 DEFAULT_WAND_HANDEDNESS_OFFSET_GAME_BOARD_SPACE
A left/right offset to the default wand position, depending on handedness.
Definition: Wand.cs:74
static readonly Quaternion DEFAULT_WAND_ROTATION_GAME_BOARD_SPACE
The default rotation of the wand relative to the board.
Definition: Wand.cs:83
static readonly Vector3 DEFAULT_WAND_POSITION_GAME_BOARD_SPACE
The default position of the wand relative to the board.
Definition: Wand.cs:70

References TiltFive.Wand.DEFAULT_WAND_HANDEDNESS_OFFSET_GAME_BOARD_SPACE, TiltFive.Wand.DEFAULT_WAND_POSITION_GAME_BOARD_SPACE, and TiltFive.Wand.DEFAULT_WAND_ROTATION_GAME_BOARD_SPACE.

Referenced by TiltFive.Wand.WandCore.FilterTrackingPointPose(), and TiltFive.Wand.WandCore.SetDefaultPoseGameboardSpace().

◆ GetLatestInputs()

virtual void TiltFive.Wand.WandCore.GetLatestInputs ( )
virtual

Definition at line 671 of file Wand.cs.

672 {
674
675 try
676 {
677 T5_ControllerState state = new T5_ControllerState();
678
679 var result = NativePlugin.GetControllerState(glassesHandle, controllerIndex, ref state);
680
681 currentState = (result == 0)
682 ? state
683 : (T5_ControllerState?)null;
684 }
685 catch (Exception e)
686 {
687 currentState = null;
688 Log.Error(e.Message);
689 }
690 }
static void Error(string m, params object[] list)
ERROR logging function call.
Definition: Log.cs:127

References TiltFive.Wand.WandCore.controllerIndex, TiltFive.Wand.WandCore.currentState, TiltFive.Logging.Log.Error(), TiltFive.NativePlugin.GetControllerState(), TiltFive.Wand.WandCore.glassesHandle, and TiltFive.Wand.WandCore.previousState.

◆ GetStickTilt()

Vector2 TiltFive.Wand.WandCore.GetStickTilt ( )

Definition at line 759 of file Wand.cs.

760 {
761 return currentState?.Stick ?? Vector2.zero;
762 }

References TiltFive.Wand.WandCore.currentState, and TiltFive.T5_ControllerState.Stick.

Referenced by TiltFive.Wand.WandCore.TryGetStickTilt().

◆ GetTrigger()

float TiltFive.Wand.WandCore.GetTrigger ( )

◆ ProcessTrackingData()

void TiltFive.Wand.WandCore.ProcessTrackingData ( Vector3  gripPosition_UGBD,
Vector3  fingertipsPosition_UGBD,
Vector3  aimPosition_UGBD,
Quaternion  rotToUGBD_WND,
WandSettings  wandSettings,
ScaleSettings  scaleSettings,
GameBoardSettings  gameBoardSettings,
out Pose  gripPose_UGBD,
out Pose  fingertipsPose_UGBD,
out Pose  aimPose_UGBD 
)
protected

Definition at line 953 of file Wand.cs.

956 {
957 var incomingGripPose_UGBD = new Pose(gripPosition_UGBD, rotToUGBD_WND);
958 var incomingFingertipsPose_UGBD = new Pose(fingertipsPosition_UGBD, rotToUGBD_WND);
959 var incomingAimPose_UGBD = new Pose(aimPosition_UGBD, rotToUGBD_WND);
960
961 // Get the distance between the tracking points and the grip point.
962 // Currently, when a pose is considered invalid, the position and rotation reported by the native plugin are completely zero'd out.
963 // This crunches the tracking points together unless we consider the stale positions from the previous frame.
964 // It also means that we don't get the desired behavior for TrackingFailureMode.FreezePosition,
965 // in which the wand position freezes while still showing rotation values reported by the IMU.
966 // TODO: In the native plugin, even for invalid poses (both wand and glasses, which are also affected),
967 // include an offset for the tracking points, and pass through rotation data.
968 var staleGripPose_UGBD = pose_UGBD;
969 var staleFingertipsPose_UGBD = fingertipsPose_GameboardSpace;
970 var staleAimPose_UGBD = aimPose_GameboardSpace;
971
972 var gripPointOffsetDistance = 0f;
973 var fingertipsPointOffsetDistance = Mathf.Max((fingertipsPosition_UGBD - gripPosition_UGBD).magnitude,
974 (staleFingertipsPose_UGBD.position - staleGripPose_UGBD.position).magnitude);
975 var aimPointOffsetDistance = Mathf.Max((aimPosition_UGBD - gripPosition_UGBD).magnitude,
976 (staleAimPose_UGBD.position - staleGripPose_UGBD.position).magnitude);
977
978 // Handle invalid poses
979 gripPose_UGBD = FilterTrackingPointPose(staleGripPose_UGBD, staleGripPose_UGBD, incomingGripPose_UGBD, gripPointOffsetDistance, wandSettings);
980 fingertipsPose_UGBD = FilterTrackingPointPose(staleGripPose_UGBD, staleFingertipsPose_UGBD, incomingFingertipsPose_UGBD, fingertipsPointOffsetDistance, wandSettings);
981 aimPose_UGBD = FilterTrackingPointPose(staleGripPose_UGBD, staleAimPose_UGBD, incomingAimPose_UGBD, aimPointOffsetDistance, wandSettings);
982
983 }
Pose FilterTrackingPointPose(Pose staleGripPointPose, Pose staleTrackingPointPose, Pose newTrackingPointPose, float trackingPointOffsetDistance, WandSettings settings)
Definition: Wand.cs:985
Pose aimPose_GameboardSpace
Definition: Wand.cs:648
Pose fingertipsPose_GameboardSpace
Definition: Wand.cs:647

References TiltFive.Wand.WandCore.aimPose_GameboardSpace, TiltFive.Wand.WandCore.FilterTrackingPointPose(), TiltFive.Wand.WandCore.fingertipsPose_GameboardSpace, and TiltFive.TrackableCore< WandSettings, T5_ControllerState >.pose_UGBD.

Referenced by TiltFive.Wand.WandCore.SetPoseGameboardSpace().

◆ Reset()

new void TiltFive.Wand.WandCore.Reset ( WandSettings  wandSettings)

Definition at line 786 of file Wand.cs.

787 {
788 base.Reset(wandSettings);
789 }

◆ SetDefaultPoseGameboardSpace()

override void TiltFive.Wand.WandCore.SetDefaultPoseGameboardSpace ( WandSettings  settings)
protected

Definition at line 802 of file Wand.cs.

803 {
805 // We don't have a good offset that we can use for default fingertips/aim poses, so just use the default pose for everything
808 }

References TiltFive.Wand.WandCore.aimPose_GameboardSpace, TiltFive.Wand.WandCore.fingertipsPose_GameboardSpace, TiltFive.Wand.WandCore.GetDefaultPoseGameboardSpace(), and TiltFive.TrackableCore< WandSettings, T5_ControllerState >.pose_UGBD.

◆ SetDrivenObjectTransform()

override void TiltFive.Wand.WandCore.SetDrivenObjectTransform ( WandSettings  wandSettings,
ScaleSettings  scaleSettings,
GameBoardSettings  gameBoardSettings 
)
protected

Definition at line 916 of file Wand.cs.

917 {
918 if (wandSettings.GripPoint != null)
919 {
920 wandSettings.GripPoint.transform.SetPositionAndRotation(gripPose_UnityWorldSpace.position, gripPose_UnityWorldSpace.rotation);
921 }
922
923 if (wandSettings.FingertipPoint != null)
924 {
925 wandSettings.FingertipPoint.transform.SetPositionAndRotation(fingertipsPose_UnityWorldSpace.position, fingertipsPose_UnityWorldSpace.rotation);
926 }
927
928 if (wandSettings.AimPoint != null)
929 {
930 wandSettings.AimPoint.transform.SetPositionAndRotation(aimPose_UnityWorldSpace.position, aimPose_UnityWorldSpace.rotation);
931 }
932 }
Pose aimPose_UnityWorldSpace
Definition: Wand.cs:652
Pose fingertipsPose_UnityWorldSpace
Definition: Wand.cs:651
Pose gripPose_UnityWorldSpace
Definition: Wand.cs:650

References TiltFive.WandSettings.AimPoint, TiltFive.Wand.WandCore.aimPose_UnityWorldSpace, TiltFive.WandSettings.FingertipPoint, TiltFive.Wand.WandCore.fingertipsPose_UnityWorldSpace, TiltFive.WandSettings.GripPoint, and TiltFive.Wand.WandCore.gripPose_UnityWorldSpace.

◆ SetInvalidPoseGameboardSpace()

override void TiltFive.Wand.WandCore.SetInvalidPoseGameboardSpace ( in T5_ControllerState  t5_ControllerState,
WandSettings  settings,
ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
protected

Handle setting the wand pose when we know the controller state isn't valid.

Parameters
t5_ControllerStateThe invalid state. It can still be useful if we want to use its rotation values.
settings
scaleSettings
gameboardSettings

Definition at line 911 of file Wand.cs.

912 {
913 SetPoseGameboardSpace(t5_ControllerState, settings, scaleSettings, gameboardSettings);
914 }
override void SetPoseGameboardSpace(in T5_ControllerState controllerState, WandSettings wandSettings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
Definition: Wand.cs:877

References TiltFive.Wand.WandCore.SetPoseGameboardSpace().

◆ SetPoseGameboardSpace()

override void TiltFive.Wand.WandCore.SetPoseGameboardSpace ( in T5_ControllerState  controllerState,
WandSettings  wandSettings,
ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
protected

Definition at line 877 of file Wand.cs.

879 {
880 // Unity reference frames:
881 //
882 // UWND - Unity WaND local space.
883 // +x right, +y up, +z forward
884 // UGBD - Unity Gameboard space.
885 // +x right, +y up, +z forward
886 //
887 // Tilt Five reference frames:
888 //
889 // DW - Our right-handed version of Unity's default wand space.
890 // +x right, +y down, +z forward
891 // GBD - Gameboard space.
892 // +x right, +y forward, +z up
893
894 Vector3 gripPosition_UGBD = ConvertPosGBDToUGBD(controllerState.GripPos_GBD);
895 Vector3 fingertipsPosition_UGBD = ConvertPosGBDToUGBD(controllerState.FingertipsPos_GBD);
896 Vector3 aimPosition_UGBD = ConvertPosGBDToUGBD(controllerState.AimPos_GBD);
897 var rotation_UGBD = CalculateRotation(controllerState.RotToWND_GBD);
898
899 ProcessTrackingData(gripPosition_UGBD, fingertipsPosition_UGBD, aimPosition_UGBD,
900 rotation_UGBD, wandSettings, scaleSettings, gameboardSettings,
902 }
void ProcessTrackingData(Vector3 gripPosition_UGBD, Vector3 fingertipsPosition_UGBD, Vector3 aimPosition_UGBD, Quaternion rotToUGBD_WND, WandSettings wandSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings, out Pose gripPose_UGBD, out Pose fingertipsPose_UGBD, out Pose aimPose_UGBD)
Definition: Wand.cs:953
Quaternion CalculateRotation(Quaternion rotToWND_GBD)
Definition: Wand.cs:944

References TiltFive.Wand.WandCore.aimPose_GameboardSpace, TiltFive.Wand.WandCore.CalculateRotation(), TiltFive.TrackableCore< WandSettings, T5_ControllerState >.ConvertPosGBDToUGBD(), TiltFive.Wand.WandCore.fingertipsPose_GameboardSpace, TiltFive.TrackableCore< WandSettings, T5_ControllerState >.pose_UGBD, and TiltFive.Wand.WandCore.ProcessTrackingData().

Referenced by TiltFive.Wand.WandCore.SetInvalidPoseGameboardSpace().

◆ SetPoseUnityWorldSpace()

override void TiltFive.Wand.WandCore.SetPoseUnityWorldSpace ( ScaleSettings  scaleSettings,
GameBoardSettings  gameboardSettings 
)
protectedvirtual

◆ TryCheckConnected()

override bool TiltFive.Wand.WandCore.TryCheckConnected ( out bool  connected)
protectedvirtual

Determines whether the tracked object is still connected.

Parameters
connected
Returns

Implements TiltFive.TrackableCore< WandSettings, T5_ControllerState >.

Definition at line 826 of file Wand.cs.

827 {
829 {
830 try
831 {
832 T5_Bool wandAvailable = false;
833 int result = NativePlugin.GetWandAvailability(glassesHandle, ref wandAvailable, controllerIndex);
834
835 if (result == 0)
836 {
837 isConnected = wandAvailable;
838 connected = wandAvailable;
839 return true;
840 }
841 }
842 catch (DllNotFoundException e)
843 {
844 Log.Info("Could not connect to Tilt Five plugin for wand: {0}", e.Message);
846 }
847 catch (Exception e)
848 {
849 Log.Error(
850 "Failed to connect to Tilt Five plugin for wand availability: {0}",
851 e.ToString());
853 }
854 }
855
856 isConnected = false;
857 connected = false;
858 return false;
859 }
static bool wandAvailabilityErroredOnce
Definition: Wand.cs:100

References TiltFive.Wand.WandCore.controllerIndex, TiltFive.Logging.Log.Error(), TiltFive.NativePlugin.GetWandAvailability(), TiltFive.Wand.WandCore.glassesHandle, TiltFive.Logging.Log.Info(), TiltFive.TrackableCore< WandSettings, T5_ControllerState >.isConnected, and TiltFive.Wand.wandAvailabilityErroredOnce.

◆ TryGetButton()

bool TiltFive.Wand.WandCore.TryGetButton ( WandButton  button,
out bool  pressed 
)

Definition at line 698 of file Wand.cs.

699 {
700 pressed = currentState?.GetButton(button) ?? false;
701
702 // If the wand isn't connected, TryGetButton() should fail.
703 return currentState.HasValue;
704 }

References TiltFive.Wand.WandCore.currentState.

◆ TryGetButtonDown()

bool TiltFive.Wand.WandCore.TryGetButtonDown ( WandButton  button,
out bool  buttonDown 
)

Definition at line 726 of file Wand.cs.

727 {
728 // Even if this operation fails, give buttonDown a default value.
729 buttonDown = GetButtonDown(button);
730 return currentState.HasValue;
731 }
bool GetButtonDown(WandButton button)
Definition: Wand.cs:706

References TiltFive.Wand.WandCore.currentState, and TiltFive.Wand.WandCore.GetButtonDown().

◆ TryGetButtonUp()

bool TiltFive.Wand.WandCore.TryGetButtonUp ( WandButton  button,
out bool  buttonUp 
)

Definition at line 752 of file Wand.cs.

753 {
754 // Even if this operation fails, give buttonUp a default value.
755 buttonUp = GetButtonUp(button);
756 return currentState.HasValue;
757 }
bool GetButtonUp(WandButton button)
Definition: Wand.cs:733

References TiltFive.Wand.WandCore.currentState, and TiltFive.Wand.WandCore.GetButtonUp().

◆ TryGetStateFromPlugin()

override bool TiltFive.Wand.WandCore.TryGetStateFromPlugin ( out T5_ControllerState  controllerState,
out bool  poseIsValid,
GameBoardSettings  gameBoardSettings 
)
protected

Definition at line 861 of file Wand.cs.

862 {
863 if (!TryGetWandControlsState(glassesHandle, out var controllerStateResult, controllerIndex))
864 {
865 poseIsValid = false;
866 controllerState = new T5_ControllerState();
867
868 return false;
869 }
870
871 controllerState = controllerStateResult.Value;
872 poseIsValid = Glasses.IsTracked(glassesHandle) && controllerState.PoseValid;
873
874 return true;
875 }

References TiltFive.Wand.WandCore.controllerIndex, TiltFive.Wand.WandCore.glassesHandle, and TiltFive.Glasses.IsTracked().

◆ TryGetStickTilt()

bool TiltFive.Wand.WandCore.TryGetStickTilt ( out Vector2  stickTilt)

Definition at line 764 of file Wand.cs.

765 {
766 stickTilt = GetStickTilt();
767 return currentState.HasValue;
768 }
Vector2 GetStickTilt()
Definition: Wand.cs:759

References TiltFive.Wand.WandCore.currentState, and TiltFive.Wand.WandCore.GetStickTilt().

◆ TryGetTrigger()

bool TiltFive.Wand.WandCore.TryGetTrigger ( out float  triggerDisplacement)

Definition at line 775 of file Wand.cs.

776 {
777 triggerDisplacement = GetTrigger();
778 return currentState.HasValue;
779 }
float GetTrigger()
Definition: Wand.cs:770

References TiltFive.Wand.WandCore.currentState, and TiltFive.Wand.WandCore.GetTrigger().

◆ Update()

virtual new void TiltFive.Wand.WandCore.Update ( WandSettings  wandSettings,
ScaleSettings  scaleSettings,
GameBoardSettings  gameBoardSettings 
)
virtual

Definition at line 791 of file Wand.cs.

792 {
793 if (wandSettings == null)
794 {
795 Log.Error("WandSettings configuration required for Wand tracking updates.");
796 return;
797 }
798
799 base.Update(wandSettings, scaleSettings, gameBoardSettings);
800 }

References TiltFive.Logging.Log.Error().

Member Data Documentation

◆ aimPose_GameboardSpace

◆ aimPose_UnityWorldSpace

Pose TiltFive.Wand.WandCore.aimPose_UnityWorldSpace

◆ controllerIndex

◆ currentState

◆ fingertipsPose_GameboardSpace

◆ fingertipsPose_UnityWorldSpace

Pose TiltFive.Wand.WandCore.fingertipsPose_UnityWorldSpace

◆ glassesHandle

readonly GlassesHandle TiltFive.Wand.WandCore.glassesHandle

◆ previousState

T5_ControllerState? TiltFive.Wand.WandCore.previousState
protected

Property Documentation

◆ gripPose_UnityWorldSpace

Pose TiltFive.Wand.WandCore.gripPose_UnityWorldSpace
get

Definition at line 650 of file Wand.cs.

Referenced by TiltFive.Wand.WandCore.SetDrivenObjectTransform().


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