Tilt Five™ Unity API  1.4.1
TiltFive.Glasses Class Reference

The Glasses API and runtime. More...

Inheritance diagram for TiltFive.Glasses:
TiltFive.Singleton< Glasses >

Classes

class  BaseGlassesCore
 
class  GlassesCore
 Internal Glasses core runtime. More...
 
class  GlassesPreviewCore
 Trackable core for the smoothed glasses preview pose. More...
 

Public Types

enum class  AREyes { EYE_LEFT = 0 , EYE_RIGHT , EYE_MAX }
 

Static Public Member Functions

static bool IsTracked (PlayerIndex playerIndex=PlayerIndex.One)
 Indicate if the specified glasses are tracked. More...
 
static bool TryGetFriendlyName (PlayerIndex playerIndex, out string friendlyName)
 Gets the friendly name associated with the specified player's glasses in the Tilt Five Control Panel. More...
 
static bool TryGetPose (PlayerIndex playerIndex, out Pose pose)
 Attempts to get the position and orientation of the specified player's glasses. More...
 
static bool TryGetPreviewPose (PlayerIndex playerIndex, out Pose pose)
 Attempts to get the position and orientation of the specified player's glasses, smoothed for on-screen preview. More...
 
static GameObject GetPoseRoot (PlayerIndex playerIndex)
 Gets the pose root GameObject for the specified player. More...
 
static Camera GetLeftEye (PlayerIndex playerIndex)
 Gets the left eye camera for the specified player's glasses. More...
 
static Camera GetRightEye (PlayerIndex playerIndex)
 Gets the right eye camera for the specified player's glasses. More...
 
static bool headPoseUpdated (PlayerIndex playerIndex=PlayerIndex.One)
 Returns a boolean indication that the head pose was successfully updated. More...
 
static void Reset (GlassesSettings glassesSettings, SpectatorSettings spectatorSettings=null, PlayerIndex playerIndex=PlayerIndex.None)
 Reset this T:TiltFive.Glasses. More...
 
static bool Validate (GlassesSettings glassesSettings, SpectatorSettings spectatorSettings=null, PlayerIndex playerIndex=PlayerIndex.One)
 Validates the specified glassesSettings with the specified glasses core. More...
 
static void Update (GlassesSettings glassesSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
 Updates this T:TiltFive.Glasses. More...
 
static bool IsConnected (PlayerIndex playerIndex=PlayerIndex.One)
 Indicate if the specified glasses are connected. More...
 
static void ScanForGlasses ()
 

Properties

static bool updated [get]
 Gets a value indicating whether this T:TiltFive.Glasses is updated. More...
 
static bool configured [get]
 Gets a value indicating whether this T:TiltFive.Glasses is configured. More...
 
static Vector3 position [get]
 Gets the head pose position. More...
 
static Quaternion rotation [get]
 Gets the head pose rotation. More...
 
static Vector3 forward [get]
 Gets the head orientation's forward vector. More...
 
static Vector3 right [get]
 Gets the head orientation's right vector. More...
 
static Vector3 up [get]
 Gets the head orientation's up vector. More...
 
static Vector3 leftEyePosition [get]
 Gets the left eye position. More...
 
static Vector3 rightEyePosition [get]
 Gets the right eye position. More...
 
static bool glassesAvailable [get, private set]
 Indicates whether the glasses are plugged in and functioning. More...
 
- Properties inherited from TiltFive.Singleton< Glasses >
static T Instance [get]
 

Static Private Member Functions

static GameObject GetPoseRoot (GlassesHandle glassesHandle)
 
static Camera GetLeftEye (GlassesHandle glassesHandle)
 
static Camera GetRightEye (GlassesHandle glassesHandle)
 
static GlassesCore GetPlayerOneGlassesCore ()
 
static bool TryGetSpectatorSettings (out SpectatorSettings spectatorSettings)
 

Private Attributes

Dictionary< GlassesHandle, GlassesCoreglassesCores = new Dictionary<GlassesHandle, GlassesCore>()
 The glasses core runtimes. More...
 
HashSet< GlassesHandle > incomingHandles = new HashSet<GlassesHandle>()
 
HashSet< GlassesHandle > lostHandles = new HashSet<GlassesHandle>()
 
GlassesHandle? defaultGlassesHandle
 The identifier for the first detected pair of glasses. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TiltFive.Singleton< Glasses >
 Singleton ()
 

Detailed Description

The Glasses API and runtime.

Definition at line 34 of file Glasses.cs.

Member Enumeration Documentation

◆ AREyes

Enumerator
EYE_LEFT 
EYE_RIGHT 
EYE_MAX 

Definition at line 56 of file Glasses.cs.

57  {
58  EYE_LEFT = 0,
59  EYE_RIGHT,
60  EYE_MAX,
61  }

Member Function Documentation

◆ GetLeftEye() [1/2]

static Camera TiltFive.Glasses.GetLeftEye ( GlassesHandle  glassesHandle)
staticprivate

Definition at line 638 of file Glasses.cs.

639  {
640  if (!Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
641  {
642  return null;
643  }
644  return glassesCore.leftEye;
645  }

◆ GetLeftEye() [2/2]

static Camera TiltFive.Glasses.GetLeftEye ( PlayerIndex  playerIndex)
static

Gets the left eye camera for the specified player's glasses.

Parameters
playerIndex
Returns
Returns null if the specified player is not connected.

Definition at line 268 of file Glasses.cs.

269  {
270  if (!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
271  {
272  return null;
273  }
274  return GetLeftEye(glassesHandle);
275  }
static Camera GetLeftEye(PlayerIndex playerIndex)
Gets the left eye camera for the specified player's glasses.
Definition: Glasses.cs:268
Provides access to player settings and functionality.
Definition: Player.cs:31

Referenced by TiltFive.TiltFiveManager.GetEyeCamera(), and TiltFive.TiltFiveManager2.GetEyeCamera().

◆ GetPlayerOneGlassesCore()

static GlassesCore TiltFive.Glasses.GetPlayerOneGlassesCore ( )
staticprivate

Definition at line 657 of file Glasses.cs.

658  {
659  if(Player.TryGetGlassesHandle(PlayerIndex.One, out var glassesHandle)
660  && Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
661  {
662  return glassesCore;
663  }
664  return null;
665  }
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)

◆ GetPoseRoot() [1/2]

static GameObject TiltFive.Glasses.GetPoseRoot ( GlassesHandle  glassesHandle)
staticprivate

Definition at line 629 of file Glasses.cs.

630  {
631  if (!Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
632  {
633  return null;
634  }
635  return glassesCore.headPose.gameObject;
636  }

◆ GetPoseRoot() [2/2]

static GameObject TiltFive.Glasses.GetPoseRoot ( PlayerIndex  playerIndex)
static

Gets the pose root GameObject for the specified player.

This GameObject's pose is driven by the player's head position over the gameboard. Parented underneath this GameObject are the two eye cameras and an instance of the developer-provided prefab in the player's Glasses settings.

Parameters
playerIndex
Returns
Returns null if the specified player is not connected.

Definition at line 254 of file Glasses.cs.

255  {
256  if(!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
257  {
258  return null;
259  }
260  return GetPoseRoot(glassesHandle);
261  }
static GameObject GetPoseRoot(PlayerIndex playerIndex)
Gets the pose root GameObject for the specified player.
Definition: Glasses.cs:254

Referenced by TiltFive.TiltFiveManager.Update(), and TiltFive.TiltFiveManager2.Update().

◆ GetRightEye() [1/2]

static Camera TiltFive.Glasses.GetRightEye ( GlassesHandle  glassesHandle)
staticprivate

Definition at line 647 of file Glasses.cs.

648  {
649  if (!Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
650  {
651  return null;
652  }
653 
654  return glassesCore.rightEye;
655  }

◆ GetRightEye() [2/2]

static Camera TiltFive.Glasses.GetRightEye ( PlayerIndex  playerIndex)
static

Gets the right eye camera for the specified player's glasses.

Parameters
playerIndex
Returns
Returns null if the specified player is not connected.

Definition at line 282 of file Glasses.cs.

283  {
284  if (!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
285  {
286  return null;
287  }
288  return GetRightEye(glassesHandle);
289  }
static Camera GetRightEye(PlayerIndex playerIndex)
Gets the right eye camera for the specified player's glasses.
Definition: Glasses.cs:282

◆ headPoseUpdated()

static bool TiltFive.Glasses.headPoseUpdated ( PlayerIndex  playerIndex = PlayerIndex.One)
static

Returns a boolean indication that the head pose was successfully updated.

Returns
true, if the head pose was updated, false otherwise.
Parameters
glassesHandleThe specified glasses. If null is provided, this uses the default glasses.

Definition at line 300 of file Glasses.cs.

301  {
302  if (playerIndex == PlayerIndex.None || !Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
303  {
304  return false;
305  }
306 
307  return Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore)
308  && glassesCore.IsTracked;
309  }

References TiltFive.Singleton< Glasses >.Instance.

◆ IsConnected()

static bool TiltFive.Glasses.IsConnected ( PlayerIndex  playerIndex = PlayerIndex.One)
static

Indicate if the specified glasses are connected.

Returns
true if the glasses are connected, false otherwise.
Parameters
glassesHandleGlasses handle to check.

Definition at line 353 of file Glasses.cs.

354  {
355  return Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
356  && IsConnected(glassesHandle);
357  }
static bool IsConnected(PlayerIndex playerIndex=PlayerIndex.One)
Indicate if the specified glasses are connected.
Definition: Glasses.cs:353

◆ IsTracked()

static bool TiltFive.Glasses.IsTracked ( PlayerIndex  playerIndex = PlayerIndex.One)
static

Indicate if the specified glasses are tracked.

Returns
true if the glasses are tracked, false otherwise.
Parameters
playerIndexIf not provided, the Player 1's glasses are checked.

Definition at line 142 of file Glasses.cs.

143  {
144  return Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
145  && IsTracked(glassesHandle);
146  }
static bool IsTracked(PlayerIndex playerIndex=PlayerIndex.One)
Indicate if the specified glasses are tracked.
Definition: Glasses.cs:142

Referenced by TiltFive.SplitStereoCamera.SyncTransform(), and TiltFive.Wand.WandCore.TryGetStateFromPlugin().

◆ Reset()

static void TiltFive.Glasses.Reset ( GlassesSettings  glassesSettings,
SpectatorSettings  spectatorSettings = null,
PlayerIndex  playerIndex = PlayerIndex.None 
)
static

Reset this T:TiltFive.Glasses.

Parameters
glassesSettingsGlasses settings for configuring the specified glassesCore.
playerIndexThe specified player. If None is provided, this resets all glasses.

Definition at line 317 of file Glasses.cs.

318  {
319  Reset(playerIndex, glassesSettings, spectatorSettings);
320  }
static void Reset(GlassesSettings glassesSettings, SpectatorSettings spectatorSettings=null, PlayerIndex playerIndex=PlayerIndex.None)
Reset this T:TiltFive.Glasses.
Definition: Glasses.cs:317

Referenced by TiltFive.TiltFiveManager.OnEnable().

◆ ScanForGlasses()

static void TiltFive.Glasses.ScanForGlasses ( )
static

Definition at line 360 of file Glasses.cs.

360 { Scan(); }

◆ TryGetFriendlyName()

static bool TiltFive.Glasses.TryGetFriendlyName ( PlayerIndex  playerIndex,
out string  friendlyName 
)
static

Gets the friendly name associated with the specified player's glasses in the Tilt Five Control Panel.

Parameters
playerIndex
friendlyName
Returns
Returns false and sets friendlyName to null if there was a problem getting the friendly name for this player; otherwise true. This can happen if the provided PlayerIndex is invalid, the player is not connected, or if the user hasn't yet set a friendly name for this particular set of glasses.

Definition at line 178 of file Glasses.cs.

179  {
180  if(!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
181  {
182  friendlyName = null;
183  return false;
184  }
185 
186  return TryGetFriendlyName(glassesHandle, out friendlyName);
187  }
static bool TryGetFriendlyName(PlayerIndex playerIndex, out string friendlyName)
Gets the friendly name associated with the specified player's glasses in the Tilt Five Control Panel.
Definition: Glasses.cs:178

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

◆ TryGetPose()

static bool TiltFive.Glasses.TryGetPose ( PlayerIndex  playerIndex,
out Pose  pose 
)
static

Attempts to get the position and orientation of the specified player's glasses.

Parameters
playerIndex
pose
Returns
Returns false along with an empty pose if something goes wrong.

Definition at line 215 of file Glasses.cs.

216  {
217  if(Player.TryGetGlassesHandle(playerIndex, out var glassesHandle) && Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
218  {
219  pose = glassesCore.Pose_UnityWorldSpace;
220  return true;
221  }
222  pose = new Pose();
223  return false;
224  }

References TiltFive.Singleton< Glasses >.Instance.

◆ TryGetPreviewPose()

static bool TiltFive.Glasses.TryGetPreviewPose ( PlayerIndex  playerIndex,
out Pose  pose 
)
static

Attempts to get the position and orientation of the specified player's glasses, smoothed for on-screen preview.

Parameters
playerIndex
pose
Returns
Returns false along with an empty pose if something goes wrong.

Definition at line 233 of file Glasses.cs.

234  {
235  if (Player.TryGetGlassesHandle(playerIndex, out var glassesHandle) && Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
236  {
237  pose = glassesCore.previewCore.Pose_UnityWorldSpace;
238  return true;
239  }
240  pose = new Pose();
241  return false;
242  }

References TiltFive.Singleton< Glasses >.Instance.

Referenced by TiltFive.TiltFiveManager.Update(), and TiltFive.TiltFiveManager2.Update().

◆ TryGetSpectatorSettings()

static bool TiltFive.Glasses.TryGetSpectatorSettings ( out SpectatorSettings  spectatorSettings)
staticprivate

Definition at line 667 of file Glasses.cs.

668  {
669  if (TiltFiveSingletonHelper.TryGetISceneInfo(out var sceneInfo))
670  {
671  if (sceneInfo is TiltFiveManager2 tiltFiveManager2)
672  {
673  spectatorSettings = tiltFiveManager2.spectatorSettings;
674  return true;
675  }
676 
677  if (sceneInfo is TiltFiveManager tiltFiveManager)
678  {
679  spectatorSettings = tiltFiveManager.spectatorSettings;
680  return true;
681  }
682  }
683 
684  spectatorSettings = null;
685  return false;
686  }
The Tilt Five manager.
The Tilt Five manager.
static bool TryGetISceneInfo(out ISceneInfo sceneInfo)

References TiltFive.TiltFiveSingletonHelper.TryGetISceneInfo().

◆ Update()

static void TiltFive.Glasses.Update ( GlassesSettings  glassesSettings,
ScaleSettings  scaleSettings,
GameBoardSettings  gameBoardSettings 
)
static

Updates this T:TiltFive.Glasses.

Parameters
glassesSettingsGlasses settings for the update.

Definition at line 342 of file Glasses.cs.

343  {
344  UpdateAllGlassesCores(glassesSettings, scaleSettings, gameBoardSettings);
345  }

Referenced by TiltFive.Player.PlayerCore.GetLatestPoseData().

◆ Validate()

static bool TiltFive.Glasses.Validate ( GlassesSettings  glassesSettings,
SpectatorSettings  spectatorSettings = null,
PlayerIndex  playerIndex = PlayerIndex.One 
)
static

Validates the specified glassesSettings with the specified glasses core.

Returns
true, if the glasses core is valid with the given settings, false otherwise.
Parameters
glassesSettingsGlasses settings.
playerIndexThe specified glasses to validate. If None is provided, this uses the default glasses.

Definition at line 332 of file Glasses.cs.

333  {
334  return Validate(playerIndex, glassesSettings, spectatorSettings);
335  }
static bool Validate(GlassesSettings glassesSettings, SpectatorSettings spectatorSettings=null, PlayerIndex playerIndex=PlayerIndex.One)
Validates the specified glassesSettings with the specified glasses core.
Definition: Glasses.cs:332

Member Data Documentation

◆ defaultGlassesHandle

GlassesHandle? TiltFive.Glasses.defaultGlassesHandle
private

The identifier for the first detected pair of glasses.

Definition at line 49 of file Glasses.cs.

◆ glassesCores

Dictionary<GlassesHandle, GlassesCore> TiltFive.Glasses.glassesCores = new Dictionary<GlassesHandle, GlassesCore>()
private

The glasses core runtimes.

Definition at line 41 of file Glasses.cs.

◆ incomingHandles

HashSet<GlassesHandle> TiltFive.Glasses.incomingHandles = new HashSet<GlassesHandle>()
private

Definition at line 43 of file Glasses.cs.

◆ lostHandles

HashSet<GlassesHandle> TiltFive.Glasses.lostHandles = new HashSet<GlassesHandle>()
private

Definition at line 44 of file Glasses.cs.

Property Documentation

◆ configured

bool TiltFive.Glasses.configured
staticget

Gets a value indicating whether this T:TiltFive.Glasses is configured.

true if player 1's glasses are connected and they've been configured; otherwise, false.

Definition at line 81 of file Glasses.cs.

◆ forward

Vector3 TiltFive.Glasses.forward
staticget

Gets the head orientation's forward vector.

The forward vector of player 1's glasses (if connected, otherwise the default forward vector)

Definition at line 99 of file Glasses.cs.

◆ glassesAvailable

bool TiltFive.Glasses.glassesAvailable
staticgetprivate set

Indicates whether the glasses are plugged in and functioning.

Definition at line 130 of file Glasses.cs.

130 { get; private set; }

◆ leftEyePosition

Vector3 TiltFive.Glasses.leftEyePosition
staticget

Gets the left eye position.

The left eye position of player 1's glasses (if connected, otherwise the zero vector)

Definition at line 118 of file Glasses.cs.

◆ position

Vector3 TiltFive.Glasses.position
staticget

Gets the head pose position.

The position of player 1's glasses (if connected, otherwise a zero vector)

Definition at line 87 of file Glasses.cs.

◆ right

Vector3 TiltFive.Glasses.right
staticget

Gets the head orientation's right vector.

The right vector of player 1's glasses (if connected, otherwise the default right vector)

Definition at line 105 of file Glasses.cs.

◆ rightEyePosition

Vector3 TiltFive.Glasses.rightEyePosition
staticget

Gets the right eye position.

The right eye position of player 1's glasses (if connected, otherwise the zero vector)

Definition at line 124 of file Glasses.cs.

◆ rotation

Quaternion TiltFive.Glasses.rotation
staticget

Gets the head pose rotation.

The rotation of player 1's glasses (if connected, otherwise the identity quaternion)

Definition at line 93 of file Glasses.cs.

◆ up

Vector3 TiltFive.Glasses.up
staticget

Gets the head orientation's up vector.

The up vector of player 1's glasses (if connected, otherwise the default up vector)

Definition at line 111 of file Glasses.cs.

◆ updated

bool TiltFive.Glasses.updated
staticget

Gets a value indicating whether this T:TiltFive.Glasses is updated.

true if player 1's glasses are connected and their glasses pose has been updated; otherwise, false.

Definition at line 74 of file Glasses.cs.


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