Tilt Five™ Unity API  1.4.1
TiltFive.GameBoard Class Reference

Represents the game board. More...

Inheritance diagram for TiltFive.GameBoard:
TiltFive.UniformScaleTransform

Classes

struct  GameboardDimensions
 
struct  GameboardExtents
 Represents the distances from the gameboard tracking origin to the borders of the gameboard's viewable area. More...
 

Public Types

enum class  Edge { Near , Far , Left , Right }
 Represents cardinal positions around the gameboard (i.e. the centers of the edges of the gameboard), relative to a user positioned at the near (default) edge. More...
 
enum class  Corner { FarLeft , FarRight , NearLeft , NearRight }
 Represents ordinal positions around the gameboard, relative to a user positioned at the near (default) edge. More...
 

Public Member Functions

bool TransformPose (Vector3 positionInGameboardSpace, Quaternion rotationToGameboardSpace, PlayerIndex playerIndex, out Vector3 positionInWorldSpace, out Quaternion rotationToWorldSpace)
 Transforms the provided pose from gameboard space to world space. More...
 
bool TransformPose (Pose poseInGameboardSpace, PlayerIndex playerIndex, out Pose poseInWorldSpace)
 Transforms the provided pose from gameboard space to world space. More...
 
bool TransformPoint (Vector3 pointInGameboardSpace, PlayerIndex playerIndex, out Vector3 pointInWorldSpace)
 Transforms the provided position from gameboard space to world space. More...
 
bool InverseTransformPose (Vector3 positionInWorldSpace, Quaternion rotationToWorldSpace, PlayerIndex playerIndex, out Vector3 positionInGameboardSpace, out Quaternion rotationToGameboardSpace)
 Transforms the provided pose from world space to gameboard space. More...
 
bool InverseTransformPose (Pose poseInWorldSpace, PlayerIndex playerIndex, out Pose poseInGameboardSpace)
 Transforms the provided pose from world space to gameboard space. More...
 
bool InverseTransformPoint (Vector3 pointInWorldSpace, PlayerIndex playerIndex, out Vector3 pointInGameboardSpace)
 Transforms the provided position from world space to gameboard space. More...
 
- Public Member Functions inherited from TiltFive.UniformScaleTransform
void Awake ()
 

Static Public Member Functions

static bool TryGetGameboardType (out GameboardType gameboardType)
 Attempts to check the latest glasses pose for the current gameboard type, such as LE, XE, or none. More...
 
static bool TryGetGameboardType (PlayerIndex playerIndex, out GameboardType gameboardType)
 
static bool TryGetGameboardDimensions (GameboardType gameboardType, out GameboardDimensions gameboardDimensions)
 Attempts to obtain the physical dimensions for a particular gameboard type. More...
 
static bool TryGetGameboardExtents (GameboardType gameboardType, out GameboardExtents gameboardExtents)
 Attempts to obtain the physical dimensions for a particular gameboard type. More...
 

Public Attributes

bool ShowGizmo
 Shows the game board gizmo in the editor. More...
 
bool ShowGrid
 
float GridHeightOffset = 0f
 
bool StickyHeightOffset = true
 
float GizmoOpacity = 0.75f
 Sets the opacity of the game board gizmo in the editor. More...
 
GameboardType GameboardType
 The gameboard configuration, such as LE, XE, or folded XE. More...
 

Static Private Attributes

static Dictionary< PlayerIndex, GameboardTypeplayerGameboards = new Dictionary<PlayerIndex, GameboardType>()
 

Additional Inherited Members

- Protected Member Functions inherited from TiltFive.UniformScaleTransform
void UnifyScale ()
 Synchronizes the component values of the game object's local scale vector (e.g. [1,2,3] becomes [3,3,3]). More...
 
- Properties inherited from TiltFive.UniformScaleTransform
float localScale [get, set]
 The size of the object as a single float value, rather than a scale vector. More...
 
Vector3 position [get, set]
 The position vector for the associated transform. More...
 
Quaternion rotation [get, set]
 The rotation vector for the associated transform. More...
 

Detailed Description

Represents the game board.

Definition at line 28 of file GameBoard.cs.

Member Enumeration Documentation

◆ Corner

Represents ordinal positions around the gameboard, relative to a user positioned at the near (default) edge.

Enumerator
FarLeft 
FarRight 
NearLeft 
NearRight 

Definition at line 135 of file GameBoard.cs.

136  {
137  FarLeft,
138  FarRight,
139  NearLeft,
140  NearRight
141  }

◆ Edge

Represents cardinal positions around the gameboard (i.e. the centers of the edges of the gameboard), relative to a user positioned at the near (default) edge.

Enumerator
Near 

The near edge of the gameboard.

This is the side of the gameboard with the T5 logo.

Far 

The far edge of the gameboard.

This edge is positioned opposite the near edge.

Left 

The left edge of the gameboard.

From the perspective of a user sitting at the near edge of the gameboard, this edge is to their left.

Right 

The right edge of the gameboard.

From the perspective of a user sitting at the near edge of the gameboard, this edge is to their right.

Definition at line 106 of file GameBoard.cs.

107  {
112  Near,
117  Far,
123  Left,
129  Right
130  }
@ Right
The wand held in the player's right hand.
@ Left
The wand held in the player's left hand.

Member Function Documentation

◆ InverseTransformPoint()

bool TiltFive.GameBoard.InverseTransformPoint ( Vector3  pointInWorldSpace,
PlayerIndex  playerIndex,
out Vector3  pointInGameboardSpace 
)

Transforms the provided position from world space to gameboard space.

Parameters
pointInWorldSpaceA position in Unity world space.
playerIndexThe player whose content scale settings should be considered while converting between spaces. This is necessary because multiple players with differing scale settings may share the same gameboard.
pointInGameboardSpaceThe resulting point in gameboard space.
Returns
Returns false and sets pointInGameboardSpace to Vector3.zero if the function failed while calculating the transformed point; returns true otherwise. This function can fail if playerIndex is invalid.

Definition at line 532 of file GameBoard.cs.

533  {
534  if (!Player.TryGetSettings(playerIndex, out var playerSettings))
535  {
536  pointInGameboardSpace = Vector3.zero;
537  return false;
538  }
539 
540  pointInGameboardSpace = InverseTransformPoint(pointInWorldSpace, playerSettings.scaleSettings);
541  return true;
542  }
bool InverseTransformPoint(Vector3 pointInWorldSpace, PlayerIndex playerIndex, out Vector3 pointInGameboardSpace)
Transforms the provided position from world space to gameboard space.
Definition: GameBoard.cs:532

References TiltFive.Player.TryGetSettings().

◆ InverseTransformPose() [1/2]

bool TiltFive.GameBoard.InverseTransformPose ( Pose  poseInWorldSpace,
PlayerIndex  playerIndex,
out Pose  poseInGameboardSpace 
)

Transforms the provided pose from world space to gameboard space.

Parameters
poseInWorldSpaceA position and orientation in Unity world space.
playerIndexThe player whose content scale settings should be considered while converting between spaces. This is necessary because multiple players with differing scale settings may share the same gameboard.
poseInGameboardSpaceThe resulting position and orientation in gameboard space.
Returns
Returns false and sets poseInGameboardSpace to an empty pose if the function failed while calculating the transformed pose; returns true otherwise. This function can fail if playerIndex is invalid.

Definition at line 510 of file GameBoard.cs.

511  {
512  if (!Player.TryGetSettings(playerIndex, out var playerSettings))
513  {
514  poseInGameboardSpace = new Pose();
515  return false;
516  }
517 
518  poseInGameboardSpace = InverseTransformPose(poseInWorldSpace, playerSettings.scaleSettings);
519  return true;
520  }
bool InverseTransformPose(Vector3 positionInWorldSpace, Quaternion rotationToWorldSpace, PlayerIndex playerIndex, out Vector3 positionInGameboardSpace, out Quaternion rotationToGameboardSpace)
Transforms the provided pose from world space to gameboard space.
Definition: GameBoard.cs:485

References TiltFive.GameBoard.InverseTransformPose(), and TiltFive.Player.TryGetSettings().

◆ InverseTransformPose() [2/2]

bool TiltFive.GameBoard.InverseTransformPose ( Vector3  positionInWorldSpace,
Quaternion  rotationToWorldSpace,
PlayerIndex  playerIndex,
out Vector3  positionInGameboardSpace,
out Quaternion  rotationToGameboardSpace 
)

Transforms the provided pose from world space to gameboard space.

Parameters
positionInWorldSpaceA position in Unity world space.
rotationToWorldSpaceAn orientation in Unity world space.
playerIndexThe player whose content scale settings should be considered while converting between spaces. This is necessary because multiple players with differing scale settings may share the same gameboard.
positionInGameboardSpaceThe resulting position in gameboard space.
rotationToGameboardSpaceThe resulting orientation in gameboard space.
Returns
Returns false and sets positionInGameboardSpace and rotationToGameboardSpace to default values if the function failed while calculating the transformed pose; returns true otherwise. This function can fail if playerIndex is invalid.

Definition at line 485 of file GameBoard.cs.

487  {
488  if (!Player.TryGetSettings(playerIndex, out var playerSettings))
489  {
490  positionInGameboardSpace = Vector3.zero;
491  rotationToGameboardSpace = Quaternion.identity;
492  return false;
493  }
494 
495  InverseTransformPose(positionInWorldSpace, rotationToWorldSpace, playerSettings.scaleSettings,
496  out positionInGameboardSpace, out rotationToGameboardSpace);
497  return true;
498  }

References TiltFive.Player.TryGetSettings().

Referenced by TiltFive.GameBoard.InverseTransformPose().

◆ TransformPoint()

bool TiltFive.GameBoard.TransformPoint ( Vector3  pointInGameboardSpace,
PlayerIndex  playerIndex,
out Vector3  pointInWorldSpace 
)

Transforms the provided position from gameboard space to world space.

Parameters
pointInGameboardSpaceA point in gameboard space.
playerIndexThe player whose content scale settings should be considered while converting between spaces. This is necessary because multiple players with differing scale settings may share the same gameboard.
pointInWorldSpaceThe resulting point in Unity world space.
Returns
Returns false and sets pointInWorldSpace to Vector3.zero if the function failed while calculating the transformed point; returns true otherwise. This function can fail if playerIndex is invalid.

Definition at line 461 of file GameBoard.cs.

462  {
463  if (!Player.TryGetSettings(playerIndex, out var playerSettings))
464  {
465  pointInWorldSpace = Vector3.zero;
466  return false;
467  }
468 
469  pointInWorldSpace = TransformPoint(pointInGameboardSpace, playerSettings.scaleSettings);
470  return true;
471  }
bool TransformPoint(Vector3 pointInGameboardSpace, PlayerIndex playerIndex, out Vector3 pointInWorldSpace)
Transforms the provided position from gameboard space to world space.
Definition: GameBoard.cs:461

References TiltFive.Player.TryGetSettings().

◆ TransformPose() [1/2]

bool TiltFive.GameBoard.TransformPose ( Pose  poseInGameboardSpace,
PlayerIndex  playerIndex,
out Pose  poseInWorldSpace 
)

Transforms the provided pose from gameboard space to world space.

Parameters
poseInGameboardSpaceA position and orientation in gameboard space.
playerIndexThe player whose content scale settings should be considered while converting between spaces. This is necessary because multiple players with differing scale settings may share the same gameboard.
poseInWorldSpaceThe resulting position and orientation in Unity world space.
Returns
Returns false and sets poseInWorldSpace to an empty pose if the function failed while calculating the transformed pose; returns true otherwise. This function can fail if playerIndex is invalid.

Definition at line 439 of file GameBoard.cs.

440  {
441  if (!Player.TryGetSettings(playerIndex, out var playerSettings))
442  {
443  poseInWorldSpace = new Pose();
444  return false;
445  }
446 
447  poseInWorldSpace = TransformPose(poseInGameboardSpace, playerSettings.scaleSettings);
448  return true;
449  }
bool TransformPose(Vector3 positionInGameboardSpace, Quaternion rotationToGameboardSpace, PlayerIndex playerIndex, out Vector3 positionInWorldSpace, out Quaternion rotationToWorldSpace)
Transforms the provided pose from gameboard space to world space.
Definition: GameBoard.cs:414

References TiltFive.GameBoard.TransformPose(), and TiltFive.Player.TryGetSettings().

◆ TransformPose() [2/2]

bool TiltFive.GameBoard.TransformPose ( Vector3  positionInGameboardSpace,
Quaternion  rotationToGameboardSpace,
PlayerIndex  playerIndex,
out Vector3  positionInWorldSpace,
out Quaternion  rotationToWorldSpace 
)

Transforms the provided pose from gameboard space to world space.

Parameters
positionInGameboardSpaceA position in gameboard space.
rotationToGameboardSpaceAn orientation in gameboard space.
playerIndexThe player whose content scale settings should be considered while converting between spaces. This is necessary because multiple players with differing scale settings may share the same gameboard.
positionInWorldSpaceThe resulting position in Unity world space.
rotationToWorldSpaceThe resulting orientation in Unity world space.
Returns
Returns false and sets positionInGameboardSpace and rotationToWorldSpace to default values if the function failed while calculating the transformed pose; returns true otherwise. This function can fail if playerIndex is invalid.

Definition at line 414 of file GameBoard.cs.

416  {
417  if (!Player.TryGetSettings(playerIndex, out var playerSettings))
418  {
419  positionInWorldSpace = Vector3.zero;
420  rotationToWorldSpace = Quaternion.identity;
421  return false;
422  }
423 
424  TransformPose(positionInGameboardSpace, rotationToGameboardSpace, playerSettings.scaleSettings,
425  out positionInWorldSpace, out rotationToWorldSpace);
426  return true;
427  }

References TiltFive.Player.TryGetSettings().

Referenced by TiltFive.GameBoard.TransformPose().

◆ TryGetGameboardDimensions()

static bool TiltFive.GameBoard.TryGetGameboardDimensions ( GameboardType  gameboardType,
out GameboardDimensions  gameboardDimensions 
)
static

Attempts to obtain the physical dimensions for a particular gameboard type.

Parameters
gameboardType
gameboardDimensions
Returns
Returns dimensions for GameboardType.GameboardType_LE if it fails.

Definition at line 344 of file GameBoard.cs.

345  {
346  if(gameboardType == GameboardType.GameboardType_None)
347  {
348  gameboardDimensions = new GameboardDimensions();
349  return false;
350  }
351 
352  // Default to the LE gameboard dimensions in meters.
353  T5_GameboardSize gameboardSize = GameboardExtents.GAMEBOARD_SIZE_LE;
354  int result = NativePlugin.T5_RESULT_UNKNOWN_ERROR;
355 
356  try
357  {
358  result = NativePlugin.GetGameboardDimensions(gameboardType, ref gameboardSize);
359  }
360  catch (Exception e)
361  {
362  Log.Error(e.Message);
363  }
364 
365  gameboardDimensions = new GameboardDimensions(gameboardSize);
366 
367  return result == NativePlugin.T5_RESULT_SUCCESS;
368  }
GameboardType GameboardType
The gameboard configuration, such as LE, XE, or folded XE.
Definition: GameBoard.cs:57
The Logger.
Definition: Log.cs:42
static void Error(string m, params object[] list)
ERROR logging function call.
Definition: Log.cs:127

References TiltFive.Logging.Log.Error().

◆ TryGetGameboardExtents()

static bool TiltFive.GameBoard.TryGetGameboardExtents ( GameboardType  gameboardType,
out GameboardExtents  gameboardExtents 
)
static

Attempts to obtain the physical dimensions for a particular gameboard type.

Parameters
gameboardType
gameboardExtents
Returns
Returns true on successful gameboard extents retrieval, and false otherwise. Use this return value to determine whether gameboardExtents is valid.

Definition at line 377 of file GameBoard.cs.

378  {
379  if(gameboardType == GameboardType.GameboardType_None)
380  {
381  gameboardExtents = new GameboardExtents();
382  return false;
383  }
384 
385  T5_GameboardSize gameboardSize = new T5_GameboardSize();
386  int result = NativePlugin.T5_RESULT_UNKNOWN_ERROR;
387 
388  try
389  {
390  result = NativePlugin.GetGameboardDimensions(gameboardType, ref gameboardSize);
391  }
392  catch (Exception e)
393  {
394  Log.Error(e.Message);
395  }
396 
397  gameboardExtents = new GameboardExtents(gameboardSize);
398 
399  return result == NativePlugin.T5_RESULT_SUCCESS;
400  }

References TiltFive.Logging.Log.Error().

◆ TryGetGameboardType() [1/2]

static bool TiltFive.GameBoard.TryGetGameboardType ( out GameboardType  gameboardType)
static

Attempts to check the latest glasses pose for the current gameboard type, such as LE, XE, or none.

Parameters
gameboardTypeOutput gameboard type. Contains GameboardType.GameboardType_None if no pose was provided, which can happen if the user looks away and the head tracking camera loses sight of the gameboard.
Returns
Returns true on successful pose retrieval, false otherwise.

Definition at line 318 of file GameBoard.cs.

319  {
320  return TryGetGameboardType(PlayerIndex.One, out gameboardType);
321  }
static bool TryGetGameboardType(out GameboardType gameboardType)
Attempts to check the latest glasses pose for the current gameboard type, such as LE,...
Definition: GameBoard.cs:318
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)

◆ TryGetGameboardType() [2/2]

static bool TiltFive.GameBoard.TryGetGameboardType ( PlayerIndex  playerIndex,
out GameboardType  gameboardType 
)
static

Definition at line 323 of file GameBoard.cs.

324  {
325  // Return false and a default gameboard if the player is nonexistent or disconnected.
326  if(!Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
327  || !playerGameboards.TryGetValue(playerIndex, out var currentGameboardType))
328  {
329  gameboardType = GameboardType.GameboardType_None;
330  return false;
331  }
332 
333  gameboardType = currentGameboardType;
334  return true;
335  }
static Dictionary< PlayerIndex, GameboardType > playerGameboards
Definition: GameBoard.cs:95

References TiltFive.GameBoard.playerGameboards.

Member Data Documentation

◆ GameboardType

GameboardType TiltFive.GameBoard.GameboardType

The gameboard configuration, such as LE, XE, or folded XE.

Definition at line 57 of file GameBoard.cs.

◆ GizmoOpacity

float TiltFive.GameBoard.GizmoOpacity = 0.75f

Sets the opacity of the game board gizmo in the editor.

Definition at line 50 of file GameBoard.cs.

◆ GridHeightOffset

float TiltFive.GameBoard.GridHeightOffset = 0f

Definition at line 41 of file GameBoard.cs.

◆ playerGameboards

Dictionary<PlayerIndex, GameboardType> TiltFive.GameBoard.playerGameboards = new Dictionary<PlayerIndex, GameboardType>()
staticprivate

Definition at line 95 of file GameBoard.cs.

Referenced by TiltFive.GameBoard.TryGetGameboardType().

◆ ShowGizmo

bool TiltFive.GameBoard.ShowGizmo

Shows the game board gizmo in the editor.

Definition at line 36 of file GameBoard.cs.

◆ ShowGrid

bool TiltFive.GameBoard.ShowGrid

Definition at line 39 of file GameBoard.cs.

◆ StickyHeightOffset

bool TiltFive.GameBoard.StickyHeightOffset = true

Definition at line 42 of file GameBoard.cs.


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