The Wand API and runtime.
More...
|
static Vector3 | GetPosition (ControllerIndex controllerIndex=ControllerIndex.Right, ControllerPosition controllerPosition=ControllerPosition.Grip, PlayerIndex playerIndex=PlayerIndex.One) |
| Gets the position of the wand in world space. More...
|
|
static Quaternion | GetRotation (ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One) |
| Gets the rotation of the wand in world space. More...
|
|
static bool | IsTracked (ControllerIndex controllerIndex=ControllerIndex.Right, PlayerIndex playerIndex=PlayerIndex.One) |
|
static bool | TryCheckConnected (out bool connected, PlayerIndex playerIndex, ControllerIndex controllerIndex=ControllerIndex.Right) |
| Gets the connection status of the indicated wand. More...
|
|
static bool | TrySendImpulse (float amplitude, float duration, PlayerIndex playerIndex=PlayerIndex.One, ControllerIndex controllerIndex=ControllerIndex.Right) |
| Try to send a haptics impulse to the specified wand More...
|
|
static void | Update (WandSettings wandSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings, PlayerIndex playerIndex=PlayerIndex.One) |
|
static void | ScanForWands () |
|
The Wand API and runtime.
Definition at line 55 of file Wand.cs.
◆ GetPosition()
Gets the position of the wand in world space.
- Parameters
-
controllerIndex | |
controllerPosition | |
glassesHandle | The specified glasses. If null is provided, this uses the default glasses. |
- Returns
- If the indicated wand is not connected, this returns the zero vector.
Definition at line 158 of file Wand.cs.
163 if(!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
164 || !
Instance.wandCores.TryGetValue(glassesHandle, out var wandPair)
165 || !wandPair.TryGet(controllerIndex, out var wandCore))
170 switch (controllerPosition)
173 return wandCore.fingertipsPose_UnityWorldSpace.position;
175 return wandCore.aimPose_UnityWorldSpace.position;
177 return wandCore.Pose_UnityWorldSpace.position;
ControllerPosition
Points of interest along the wand controller, such as the handle position or wand tip.
References TiltFive.Singleton< Wand >.Instance.
◆ GetRotation()
Gets the rotation of the wand in world space.
- Parameters
-
controllerIndex | |
glassesHandle | The specified glasses. If null is provided, this uses the default glasses. |
- Returns
- If the indicated wand is not connected, this returns the identity quaternion.
Definition at line 189 of file Wand.cs.
191 if (!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
192 || !
Instance.wandCores.TryGetValue(glassesHandle, out var wandPair)
193 || !wandPair.TryGet(controllerIndex, out var wandCore))
195 return Quaternion.identity;
198 return wandCore.Pose_UnityWorldSpace.rotation;
References TiltFive.Singleton< Wand >.Instance.
◆ IsTracked()
Definition at line 201 of file Wand.cs.
203 if (!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
204 || !
Instance.wandCores.TryGetValue(glassesHandle, out var wandPair)
205 || !wandPair.TryGet(controllerIndex, out var wandCore))
210 return wandCore.IsTracked;
References TiltFive.Singleton< Wand >.Instance.
◆ ObtainWandCore()
Definition at line 670 of file Wand.cs.
672 WandCore wandCore =
null;
673 var glassesAlreadyMonitored =
wandCores.TryGetValue(glassesHandle, out var wandPair);
679 if (!glassesAlreadyMonitored || !wandPair.TryGet(controllerIndex, out wandCore))
681 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
682 wandCore =
new WandDeviceCore(glassesHandle, controllerIndex);
684 wandCore =
new WandCore(glassesHandle, controllerIndex);
690 else if(glassesAlreadyMonitored && wandPair.TryGet(controllerIndex, out var lostWandCore))
static bool TryGetWandAvailability(out bool connected, GlassesHandle glassesHandle, ControllerIndex controllerIndex)
Dictionary< GlassesHandle, WandPair > wandCores
The collection of WandCores. GlassesHandles are mapped to pairs of right/left WandCores.
HashSet< WandCore > lostWands
References TiltFive.Wand.lostWands, TiltFive.Wand.TryGetWandAvailability(), and TiltFive.Wand.wandCores.
◆ ScanForWands()
static void TiltFive.Wand.ScanForWands |
( |
| ) |
|
|
static |
◆ TryCheckConnected()
Gets the connection status of the indicated wand.
- Parameters
-
connected | |
playerIndex | |
controllerIndex | |
- Returns
- Returns false if something went wrong while attempting to check wand connectivity.
Definition at line 220 of file Wand.cs.
222 if(!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
223 || !
Instance.wandCores.TryGetValue(glassesHandle, out var wandPair)
224 || !wandPair.TryGet(controllerIndex, out var wandCore))
230 connected = wandCore.IsConnected;
References TiltFive.Singleton< Wand >.Instance.
Referenced by TiltFive.Input.GetWandAvailability().
◆ TryGetWandAvailability()
static bool TiltFive.Wand.TryGetWandAvailability |
( |
out bool |
connected, |
|
|
GlassesHandle |
glassesHandle, |
|
|
ControllerIndex |
controllerIndex |
|
) |
| |
|
staticprivate |
Definition at line 637 of file Wand.cs.
643 T5_Bool wandAvailable =
false;
644 int result = NativePlugin.GetWandAvailability(glassesHandle, ref wandAvailable, controllerIndex);
646 if (result == NativePlugin.T5_RESULT_SUCCESS)
648 connected = wandAvailable;
652 catch (DllNotFoundException e)
654 Log.
Info(
"Could not connect to Tilt Five plugin for wand: {0}", e.Message);
660 "Failed to connect to Tilt Five plugin for wand availability: {0}",
static void Info(string m, params object[] list)
INFO logging function call.
static void Error(string m, params object[] list)
ERROR logging function call.
static bool wandAvailabilityErroredOnce
References TiltFive.Logging.Log.Error(), TiltFive.Logging.Log.Info(), and TiltFive.Wand.wandAvailabilityErroredOnce.
Referenced by TiltFive.Wand.ObtainWandCore().
◆ TryScanForWands()
static bool TiltFive.Wand.TryScanForWands |
( |
| ) |
|
|
staticprivate |
◆ TrySendImpulse()
Try to send a haptics impulse to the specified wand
- Parameters
-
amplitude | The amplitude of the impulse, between [0.0,1.0]. |
duration | The duration of the impulse, between 0.0 and 0.320 s. |
playerIndex | |
controllerIndex | |
- Returns
- Returns false if something went wrong while attempting to send the impulse command
Definition at line 267 of file Wand.cs.
269 if (!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
270 || !
Instance.wandCores.TryGetValue(glassesHandle, out var wandPair)
271 || !wandPair.TryGet(controllerIndex, out var wandCore))
278 if (NativePlugin.SendImpulse(glassesHandle, controllerIndex, amplitude, (UInt16)(Mathf.Clamp(duration, 0.0f, 0.320f) * 1000)) == 0)
287 catch (DllNotFoundException e)
289 Log.
Info(
"Tilt Five library missing. Could not connect to wand: {0}", e.Message);
295 "Failed to send impulse to wand: {0}",
References TiltFive.Logging.Log.Error(), TiltFive.Logging.Log.Info(), and TiltFive.Singleton< Wand >.Instance.
◆ Update()
◆ currentFrame
int TiltFive.Wand.currentFrame = -1 |
|
staticprivate |
◆ DEFAULT_WAND_HANDEDNESS_OFFSET_GAME_BOARD_SPACE
readonly Vector3 TiltFive.Wand.DEFAULT_WAND_HANDEDNESS_OFFSET_GAME_BOARD_SPACE = new Vector3(0.125f, 0f, 0f) |
|
staticprivate |
◆ DEFAULT_WAND_POSITION_GAME_BOARD_SPACE
readonly Vector3 TiltFive.Wand.DEFAULT_WAND_POSITION_GAME_BOARD_SPACE = new Vector3(0f, 0.25f, -0.25f) |
|
staticprivate |
◆ DEFAULT_WAND_ROTATION_GAME_BOARD_SPACE
readonly Quaternion TiltFive.Wand.DEFAULT_WAND_ROTATION_GAME_BOARD_SPACE = Quaternion.Euler(new Vector3(-33f, 0f, 0f)) |
|
staticprivate |
The default rotation of the wand relative to the board.
The wand GameObject will snap back to this rotation if the glasses are unavailable. If different behavior is desired in this scenario, a different camera should be used.
Definition at line 83 of file Wand.cs.
Referenced by TiltFive.Wand.WandCore.GetDefaultPoseGameboardSpace().
◆ incomingHandles
HashSet<GlassesHandle> TiltFive.Wand.incomingHandles = new HashSet<GlassesHandle>() |
|
private |
◆ lastScanAttempt
DateTime TiltFive.Wand.lastScanAttempt = System.DateTime.MinValue |
|
staticprivate |
◆ lostHandles
HashSet<GlassesHandle> TiltFive.Wand.lostHandles = new HashSet<GlassesHandle>() |
|
private |
◆ lostWands
◆ wandAvailabilityErroredOnce
bool TiltFive.Wand.wandAvailabilityErroredOnce = false |
|
staticprivate |
◆ wandCores
Dictionary<GlassesHandle, WandPair> TiltFive.Wand.wandCores = new Dictionary<GlassesHandle, WandPair>() |
|
private |
◆ wandScanInterval
readonly double TiltFive.Wand.wandScanInterval = 0.5d |
|
staticprivate |
The documentation for this class was generated from the following file: