18 using System.Collections.Generic;
21 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
22 using UnityEngine.InputSystem;
23 using UnityEngine.InputSystem.Controls;
36 #region Private Fields
41 private Dictionary<GlassesHandle, GlassesCore>
glassesCores =
new Dictionary<GlassesHandle, GlassesCore>();
44 private HashSet<GlassesHandle>
lostHandles =
new HashSet<GlassesHandle>();
73 [Obsolete(
"Glasses.updated is deprecated. Please use Glasses.IsTracked() instead.")]
80 [Obsolete(
"Glasses.configured is deprecated. Please use Player.IsConnected() instead.")]
86 [Obsolete(
"Glasses.position is deprecated. Please use Glasses.TryGetPose() and Pose.position instead.")]
92 [Obsolete(
"Glasses.rotation is deprecated. Please use Glasses.TryGetPose() and Pose.rotation instead.")]
98 [Obsolete(
"Glasses.forward is deprecated. Please use Glasses.TryGetPose() and Pose.forward instead.")]
104 [Obsolete(
"Glasses.right is deprecated. Please use Glasses.TryGetPose() and Pose.right instead.")]
110 [Obsolete(
"Glasses.up is deprecated. Please use Glasses.TryGetPose() and Pose.up instead.")]
117 [Obsolete(
"Glasses.leftEyePosition is deprecated. Please use Glasses.GetLeftEye() and Transform.position")]
123 [Obsolete(
"Glasses.rightEyePosition is deprecated. Please use Glasses.GetRightEye() and Transform.position")]
129 [Obsolete(
"Glasses.glassesAvailable is deprecated. Please use Player.IsConnected() instead.")]
132 #endregion Public Fields
135 #region Public Functions
144 return Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
148 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
158 public static bool TryGetGlassesDevice(
PlayerIndex playerIndex, out GlassesDevice glassesDevice)
160 if(!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
162 glassesDevice =
null;
166 return TryGetGlassesDevice(glassesHandle, out glassesDevice);
180 if(!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
189 #if TILT_FIVE_ENABLE_PROJECTOR_EXTRINSICS_ADJUSTMENTS
190 public static bool TrySetProjectorExtrinsicsAdjustment(
PlayerIndex playerIndex,
float[] args)
192 if (!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
196 return TrySetProjectorExtrinsicsAdjustment(glassesHandle, args);
201 if (!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
205 return SetSingleEyeMode(glassesHandle, eye);
217 if(
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle) &&
Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
219 pose = glassesCore.Pose_UnityWorldSpace;
235 if (
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle) &&
Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
237 pose = glassesCore.previewCore.Pose_UnityWorldSpace;
256 if(!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
270 if (!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
284 if (!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
291 #region Deprecated Public Functions
299 [Obsolete(
"Glasses.headPoseUpdated is deprecated. Please use Glasses.IsTracked() instead")]
302 if (playerIndex ==
PlayerIndex.None || !
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
307 return Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore)
308 && glassesCore.IsTracked;
316 [Obsolete(
"Converted to be an internal function.")]
319 Reset(playerIndex, glassesSettings, spectatorSettings);
331 [Obsolete(
"Converted to be an internal function.")]
334 return Validate(playerIndex, glassesSettings, spectatorSettings);
341 [Obsolete(
"Converted to be an internal function.")]
344 UpdateAllGlassesCores(glassesSettings, scaleSettings, gameBoardSettings);
352 [Obsolete(
"Deprecated in favor of Player.IsConnected().")]
355 return Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
359 [Obsolete(
"Converted to be an internal function.")]
362 #endregion Deprecated Public Functions
365 #endregion Public Functions
368 #region Internal Functions
370 internal static void Scan()
373 UInt64[] glassesHandles =
new UInt64[
GlassesSettings.MAX_SUPPORTED_GLASSES_COUNT];
374 Debug.Assert(glassesHandles.Length <= Byte.MaxValue);
375 byte glassesCount = (byte)glassesHandles.Length;
380 var refreshResult =
NativePlugin.RefreshGlassesAvailable();
381 result =
NativePlugin.GetGlassesHandles(ref glassesCount, glassesHandles);
383 catch (System.Exception e)
385 Log.
Error($
"Error getting glasses handles: {e.Message}");
401 var lostHandle = keyValuePair.Key;
402 var glassesCore = keyValuePair.Value;
404 glassesCore.Dispose();
412 for (
int i = 0; i < glassesCount; i++)
418 if (!
glassesCores.ContainsKey(glassesHandles[i]) && !
Player.AllSupportedPlayersConnected())
420 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
421 glassesCores[glassesHandles[i]] =
new GlassesDeviceCore(glassesHandles[i]);
423 glassesCores[glassesHandles[i]] =
new GlassesCore(glassesHandles[i]);
444 if (!
Instance.defaultGlassesHandle.HasValue && result == 0 && glassesCount > 0)
446 Instance.defaultGlassesHandle = glassesHandles[0];
452 Instance.defaultGlassesHandle =
null;
458 if (spectatorSettings ==
null && !TryGetSpectatorSettings(out spectatorSettings))
460 Log.
Error(
"Glasses.Reset() could not find any spectator settings.");
467 foreach (var glassesCore
in Instance.glassesCores.Values)
469 glassesCore.Reset(glassesSettings, spectatorSettings);
474 if (
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
476 Reset(glassesSettings, spectatorSettings, glassesHandle);
482 if (Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore) && spectatorSettings !=
null)
484 glassesCore.Reset(glassesSettings, spectatorSettings);
490 if (!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle))
495 if (spectatorSettings ==
null && !TryGetSpectatorSettings(out spectatorSettings))
500 return Validate(glassesSettings, spectatorSettings, glassesHandle);
505 return Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore)
506 && glassesCore.Validate(glassesSettings, spectatorSettings);
511 if (!TryGetSpectatorSettings(out var spectatorSettings))
517 foreach (var glassesCore
in Instance.glassesCores.Values)
519 glassesCore.Update(glassesSettings, scaleSettings, gameBoardSettings, spectatorSettings);
526 if (Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
528 glassesCore.Update(glassesSettings, scaleSettings, gameBoardSettings, spectatorSettings);
532 internal static bool IsTracked(GlassesHandle glassesHandle)
534 return Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore)
535 && glassesCore.IsTracked;
538 internal static bool IsConnected(GlassesHandle glassesHandle)
540 return Instance.glassesCores.ContainsKey(glassesHandle);
543 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
544 internal static bool TryGetGlassesDevice(GlassesHandle glassesHandle, out GlassesDevice glassesDevice)
546 if(!Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore)
547 || !(glassesCore is GlassesDeviceCore glassesDeviceCore))
549 glassesDevice =
null;
553 glassesDevice = glassesDeviceCore.glassesDevice;
558 internal static bool TryGetFriendlyName(GlassesHandle glassesHandle, out
string friendlyName)
560 if(!Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
566 return glassesCore.TryGetFriendlyName(out friendlyName);
569 #if TILT_FIVE_ENABLE_PROJECTOR_EXTRINSICS_ADJUSTMENTS
570 internal static bool TrySetProjectorExtrinsicsAdjustment(GlassesHandle glassesHandle,
float[] args)
572 if (!Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
576 return glassesCore.TrySetProjectorExtrinsicsAdjustment(args);
579 internal static bool SetSingleEyeMode(GlassesHandle glassesHandle,
AREyes eye)
581 if (!Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
585 return glassesCore.SetSingleEyeMode(eye);
595 internal static GlassesHandle? GetDefaultGlassesHandle()
597 var defaultGlassesHandle = Instance.defaultGlassesHandle;
598 return defaultGlassesHandle.HasValue && Instance.glassesCores.ContainsKey(defaultGlassesHandle.Value)
599 ? defaultGlassesHandle
603 internal static void SetDefaultGlassesHandle(GlassesHandle glassesHandle)
605 Instance.defaultGlassesHandle = glassesHandle;
608 internal static GlassesHandle[] GetAllConnectedGlassesHandles()
610 var keys = Instance.glassesCores.Keys;
611 GlassesHandle[] glassesHandles =
new GlassesHandle[keys.Count];
612 keys.CopyTo(glassesHandles, 0);
613 return glassesHandles;
616 internal static void OnDisable()
618 foreach (var glassesCore
in Instance.glassesCores.Values)
620 glassesCore.Dispose();
622 Instance.glassesCores.Clear();
625 #endregion Internal Functions
627 #region Private Functions
629 private static GameObject
GetPoseRoot(GlassesHandle glassesHandle)
631 if (!Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
635 return glassesCore.headPose.gameObject;
638 private static Camera
GetLeftEye(GlassesHandle glassesHandle)
640 if (!Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
644 return glassesCore.leftEye;
649 if (!Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
654 return glassesCore.rightEye;
660 && Instance.glassesCores.TryGetValue(glassesHandle, out var glassesCore))
673 spectatorSettings = tiltFiveManager2.spectatorSettings;
679 spectatorSettings = tiltFiveManager.spectatorSettings;
684 spectatorSettings =
null;
695 public Transform headPose => headPoseRoot.transform;
706 private readonly Vector3 DEFAULT_GLASSES_POSITION_GAME_BOARD_SPACE =
new Vector3(0f, 0.5f, -0.5f);
715 private readonly Quaternion DEFAULT_GLASSES_ROTATION_GAME_BOARD_SPACE = Quaternion.Euler(
new Vector3(-45f, 0f, 0f));
718 GlassesHandle glassesHandle,
719 T5_GlassesPoseUsage glassesPoseUsage,
722 this.glassesHandle = glassesHandle;
723 this.glassesPoseUsage = glassesPoseUsage;
724 headPoseRoot =
new GameObject(name);
729 GameObject.Destroy(headPoseRoot);
744 base.Update(glassesSettings, scaleSettings, gameBoardSettings);
749 pose_UGBD =
new Pose(
750 DEFAULT_GLASSES_POSITION_GAME_BOARD_SPACE,
751 DEFAULT_GLASSES_ROTATION_GAME_BOARD_SPACE);
758 pose_UWRLD = GameboardToWorldSpace(pose_UGBD, scaleSettings, gameBoardSettings);
763 connected = IsConnected(glassesHandle);
768 out T5_GlassesPose glassesPose,
769 out
bool poseIsValid,
772 T5_GlassesPose glassesPoseResult =
new T5_GlassesPose { };
779 ref glassesPoseResult,
782 catch (System.Exception e)
789 GameBoard.SetGameboardType(glassesHandle, glassesPoseResult.GameboardType);
796 poseIsValid = result ==
NativePlugin.T5_RESULT_SUCCESS && glassesPoseResult.GameboardType !=
GameboardType.GameboardType_None;
797 glassesPose = glassesPoseResult;
802 in T5_GlassesPose glassesPose,
807 pose_UGBD = GetPoseGameboardSpace(glassesPose);
811 in T5_GlassesPose glassesPose,
816 var newPose_GameboardSpace = GetPoseGameboardSpace(glassesPose);
823 pose_UGBD =
new Pose(pose_UGBD.position, newPose_GameboardSpace.rotation);
833 pose_UGBD =
new Pose(WorldToGameboardSpace(settings.
previewPose.position, scaleSettings, gameboardSettings),
834 WorldToGameboardSpace(settings.
previewPose.rotation, gameboardSettings));
843 pose_UGBD = newPose_GameboardSpace;
857 headPose.SetPositionAndRotation(headPose.position, pose_UWRLD.rotation);
867 headPose.SetPositionAndRotation(
878 headPose.SetPositionAndRotation(pose_UWRLD.position, pose_UWRLD.rotation);
898 Quaternion rotToDC_GBD = Quaternion.AngleAxis((-Mathf.PI / 2f) * Mathf.Rad2Deg, Vector3.right);
900 Quaternion rotToGBD_DC = Quaternion.Inverse(rotToDC_GBD);
902 Quaternion rotToGLS_GBD = glassesPose.RotationToGLS_GBD;
904 Quaternion rotToGLS_DC = rotToGLS_GBD * rotToGBD_DC;
906 Quaternion rotToUGBD_UGLS =
new Quaternion(rotToGLS_DC.x, rotToGLS_DC.y, -rotToGLS_DC.z, rotToGLS_DC.w);
909 Vector3 posOfUGLS_UGBD = ConvertPosGBDToUGBD(glassesPose.PosOfGLS_GBD);
911 return new Pose(posOfUGLS_UGBD, rotToUGBD_UGLS);
925 base(glassesHandle, T5_GlassesPoseUsage.SpectatorPresentation, $
"Glasses {glassesHandle} preview")
940 base.Update(glassesSettings, scaleSettings, gameBoardSettings);
956 public bool configured =
false;
958 public Dictionary<AREyes, Vector3> eyePositions =
new Dictionary<AREyes, Vector3>()
960 {
AREyes.EYE_LEFT,
new Vector3() },
961 {
AREyes.EYE_RIGHT,
new Vector3() }
964 public Dictionary<AREyes, Quaternion> eyeRotations =
new Dictionary<AREyes, Quaternion>()
966 {
AREyes.EYE_LEFT,
new Quaternion() },
967 {
AREyes.EYE_RIGHT,
new Quaternion() }
973 base(glassesHandle, T5_GlassesPoseUsage.GlassesPresentation, $
"Glasses {glassesHandle}")
975 if(!
Player.TryGetPlayerIndex(glassesHandle, out playerIndex))
977 Player.TryAddPlayer(glassesHandle, out playerIndex);
982 Log.
Info($
"Glasses {glassesHandle} connected.");
987 GameObject.Destroy(splitStereoCamera);
988 GameObject.Destroy(baseObject);
994 Log.
Info($
"Glasses {glassesHandle} (\"{friendlyName}\") disconnected");
1002 internal Camera leftEye => splitStereoCamera?.
leftEyeCamera;
1012 base.Reset(glassesSettings);
1018 Log.
Error($
"Required Camera assignment missing from { spectatorSettings.GetType() }. Check Spectator settings in Tilt Five Manager");
1023 if (glassesSettings.tiltFiveXR)
1027 if (
null == splitStereoCamera)
1030 GameObject spectatorCameraObject = spectatorSettings.
spectatorCamera.gameObject;
1034 if (
null == headPoseRoot)
1037 headPoseRoot =
new GameObject($
"Glasses {glassesHandle}");
1042 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
1043 if(glassesSettings.
objectTemplate.TryGetComponent<PlayerInput>(out var playerInput))
1045 Log.
Warn(
"Attaching a PlayerInput component to the Object Template is not recommended," +
1046 " as the Object Template does not persist across scene loads." +
1047 "Consider using the Input Template instead.");
1050 baseObject = GameObject.Instantiate(glassesSettings.
objectTemplate, headPoseRoot.transform);
1051 baseObject.name = $
"{baseObject.transform.parent.name} - Prefab {playerIndex}";
1053 splitStereoCamera.
Initialize(headPoseRoot, glassesSettings, spectatorSettings);
1059 TryGetFriendlyName(out friendlyName);
1074 valid &= splitStereoCamera !=
null
1076 && spectatorSettings == splitStereoCamera.spectatorSettings;
1083 T5_StringUTF8 friendlyNameResult =
"";
1088 result =
NativePlugin.GetGlassesFriendlyName(glassesHandle, ref friendlyNameResult);
1090 catch (System.Exception e)
1092 Log.
Error($
"Error getting friendly name: {e.Message}");
1096 friendlyName = (result ==
NativePlugin.T5_RESULT_SUCCESS)
1097 ? friendlyNameResult
1103 friendlyNameResult.Dispose();
1109 #if TILT_FIVE_ENABLE_PROJECTOR_EXTRINSICS_ADJUSTMENTS
1110 public bool TrySetProjectorExtrinsicsAdjustment(
float[] args)
1116 result =
NativePlugin.SetProjectorExtrinsicsAdjustment(glassesHandle, args);
1118 catch (System.Exception e)
1120 Log.
Error($
"Error setting projector extrinsics adjustment: ${e.Message}");
1125 public bool SetSingleEyeMode(
AREyes eye)
1129 if (leftEyeCamera ==
null || rightEyeCamera ==
null)
1131 Log.
Error(
"Eye camera null during call to SetSingleEyeMode()");
1140 leftEyeCamera.enabled =
true;
1141 rightEyeCamera.enabled =
false;
1143 RenderTexture rt = RenderTexture.active;
1144 RenderTexture.active = rightEyeCamera.targetTexture;
1145 GL.Viewport(rightEyeCamera.pixelRect);
1146 GL.Clear(
true,
true, Color.clear);
1147 RenderTexture.active = rt;
1153 leftEyeCamera.enabled =
false;
1154 rightEyeCamera.enabled =
true;
1156 RenderTexture rt = RenderTexture.active;
1157 RenderTexture.active = leftEyeCamera.targetTexture;
1158 GL.Viewport(leftEyeCamera.pixelRect);
1159 GL.Clear(
true,
true, Color.clear);
1160 RenderTexture.active = rt;
1164 leftEyeCamera.enabled =
true;
1165 rightEyeCamera.enabled =
true;
1178 if (
null == glassesSettings)
1180 Log.
Error(
"GlassesSettings configuration required for Glasses tracking Update.");
1184 if (
null == splitStereoCamera)
1186 Log.
Error($
"Stereo camera(s) missing from Glasses {glassesHandle} - aborting Update.");
1192 Log.
Warn(
"Found mismatched template Cameras in GlassesCore Update - should call Reset.");
1196 if (spectatorSettings != splitStereoCamera.spectatorSettings)
1198 Log.
Warn(
"Found mismatched spectator settings in GlassesCore Update - should call Reset.");
1203 base.Update(glassesSettings, scaleSettings, gameBoardSettings);
1204 previewCore.
Update(glassesSettings, scaleSettings, gameBoardSettings);
1207 splitStereoCamera.glassesHandle = glassesHandle;
1208 splitStereoCamera.enabled = isConnected;
1211 splitStereoCamera.glassesSettings = glassesSettings;
1212 splitStereoCamera.spectatorSettings = spectatorSettings;
1217 && spectatorGlassesHandle == glassesHandle;
1221 float scaleToUGBD_UWRLD = 1.0f / scaleToUWRLD_UGBD;
1224 splitStereoCamera.
posUGBD_UWRLD = gameboardPos_UWRLD.position;
1243 Log.
Error(
"Failed to obtain Glasses IPD");
1245 float ipd_UWRLD = scaleToUWRLD_UGBD * ipd_UGBD;
1246 Vector3 eyeOffset = (headPose.right.normalized * (ipd_UWRLD * 0.5f));
1249 eyePositions[
AREyes.EYE_LEFT] = headPose.position - eyeOffset;
1250 eyeRotations[
AREyes.EYE_LEFT] = headPose.rotation;
1253 eyePositions[
AREyes.EYE_RIGHT] = headPose.position + eyeOffset;
1254 eyeRotations[
AREyes.EYE_RIGHT] = headPose.rotation;
1257 if (
null != leftEyeCamera)
1259 GameObject leftEye = leftEyeCamera.gameObject;
1260 leftEye.transform.position = eyePositions[
AREyes.EYE_LEFT];
1261 leftEye.transform.rotation = eyeRotations[
AREyes.EYE_LEFT];
1264 leftEyeCamera.nearClipPlane = glassesSettings.
nearClipPlane / scaleToUGBD_UWRLD;
1265 leftEyeCamera.farClipPlane = glassesSettings.
farClipPlane / scaleToUGBD_UWRLD;
1266 leftEyeCamera.fieldOfView = glassesSettings.
fieldOfView;
1267 leftEyeCamera.cullingMask = glassesSettings.
cullingMask;
1271 if (
null != rightEyeCamera)
1273 GameObject rightEye = rightEyeCamera.gameObject;
1274 rightEye.transform.position = eyePositions[
AREyes.EYE_RIGHT];
1275 rightEye.transform.rotation = eyeRotations[
AREyes.EYE_RIGHT];
1278 rightEyeCamera.nearClipPlane = glassesSettings.
nearClipPlane / scaleToUGBD_UWRLD;
1279 rightEyeCamera.farClipPlane = glassesSettings.
farClipPlane / scaleToUGBD_UWRLD;
1280 rightEyeCamera.fieldOfView = glassesSettings.
fieldOfView;
1281 rightEyeCamera.cullingMask = glassesSettings.
cullingMask;
1285 if (!TryGetFriendlyName(out glassesSettings.
friendlyName))
1293 base.SetDrivenObjectTransform(settings, scaleSettings, gameBoardSettings);
1297 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
1298 private class GlassesDeviceCore : GlassesCore, IDisposable
1300 internal GlassesDevice glassesDevice;
1301 internal GameObject playerTemplateObject;
1303 private enum TrackingState :
int
1310 public GlassesDeviceCore(GlassesHandle glassesHandle) : base(glassesHandle)
1312 Input.AddGlassesDevice(playerIndex);
1313 glassesDevice =
Input.GetGlassesDevice(playerIndex);
1315 if(glassesDevice !=
null && glassesDevice.added)
1317 InputSystem.EnableDevice(glassesDevice);
1325 public override void Dispose()
1329 if(glassesDevice !=
null && glassesDevice.added)
1331 if (glassesDevice.LeftWand !=
null)
1335 if (glassesDevice.RightWand !=
null)
1339 InputSystem.DisableDevice(glassesDevice);
1340 Input.RemoveGlassesDevice(playerIndex);
1342 GameObject.Destroy(playerTemplateObject);
1347 base.Reset(glassesSettings, spectatorSettings);
1349 if(glassesSettings.playerTemplate)
1351 playerTemplateObject = GameObject.Instantiate(glassesSettings.playerTemplate);
1361 base.SetDrivenObjectTransform(settings, scaleSettings, gameboardSettings);
1363 if(glassesDevice ==
null || !glassesDevice.added)
1369 QueueDeltaStateEvent(glassesDevice.devicePosition, pose_UWRLD.position);
1370 QueueDeltaStateEvent(glassesDevice.centerEyePosition, pose_UWRLD.position);
1371 QueueDeltaStateEvent(glassesDevice.leftEyePosition, eyePositions[
AREyes.EYE_LEFT]);
1372 QueueDeltaStateEvent(glassesDevice.rightEyePosition, eyePositions[
AREyes.EYE_RIGHT]);
1375 QueueDeltaStateEvent(glassesDevice.deviceRotation, pose_UWRLD.rotation);
1376 QueueDeltaStateEvent(glassesDevice.centerEyeRotation, pose_UWRLD.rotation);
1377 QueueDeltaStateEvent(glassesDevice.leftEyeRotation, pose_UWRLD.rotation);
1378 QueueDeltaStateEvent(glassesDevice.rightEyeRotation, pose_UWRLD.rotation);
1381 QueueDeltaStateEvent(glassesDevice.RawPosition, pose_UGBD.position);
1382 QueueDeltaStateEvent(glassesDevice.RawLeftEyePosition, WorldToGameboardSpace(eyePositions[
AREyes.EYE_LEFT], scaleSettings, gameboardSettings));
1383 QueueDeltaStateEvent(glassesDevice.RawRightEyePosition, WorldToGameboardSpace(eyePositions[
AREyes.EYE_RIGHT], scaleSettings, gameboardSettings));
1386 QueueDeltaStateEvent(glassesDevice.RawRotation, pose_UGBD.rotation);
1387 QueueDeltaStateEvent(glassesDevice.leftEyeRotation, pose_UGBD.rotation);
1388 QueueDeltaStateEvent(glassesDevice.rightEyeRotation, pose_UGBD.rotation);
1390 InputSystem.QueueDeltaStateEvent(glassesDevice.isTracked, isTracked);
1392 var trackingState = TrackingState.Tracking;
1396 ? TrackingState.Limited
1397 : TrackingState.None;
1400 InputSystem.QueueDeltaStateEvent(glassesDevice.trackingState, (
int)trackingState);
1403 private static void QueueDeltaStateEvent(Vector3Control vector3Control, Vector3 delta)
1405 InputSystem.QueueDeltaStateEvent(vector3Control.x, delta.x);
1406 InputSystem.QueueDeltaStateEvent(vector3Control.y, delta.y);
1407 InputSystem.QueueDeltaStateEvent(vector3Control.z, delta.z);
1412 private static void QueueDeltaStateEvent(QuaternionControl quaternionControl, Quaternion delta)
1414 InputSystem.QueueDeltaStateEvent(quaternionControl.w, delta.w);
1415 InputSystem.QueueDeltaStateEvent(quaternionControl.x, delta.x);
1416 InputSystem.QueueDeltaStateEvent(quaternionControl.y, delta.y);
1417 InputSystem.QueueDeltaStateEvent(quaternionControl.z, delta.z);
TiltFive.Glasses.AREyes AREyes
The Camera Frame API and runtime.
static bool GetGlassesIPD(UInt64 glassesHandle, ref float glassesIPD)
Represents the game board.
float gameBoardScale
The game board's scale multiplies the perceived size of objects in the scene.
T5_GlassesPoseUsage glassesPoseUsage
BaseGlassesCore(GlassesHandle glassesHandle, T5_GlassesPoseUsage glassesPoseUsage, string name)
override void SetDrivenObjectTransform(GlassesSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
GlassesHandle glassesHandle
override bool TryGetStateFromPlugin(out T5_GlassesPose glassesPose, out bool poseIsValid, GameBoardSettings gameBoardSettings)
override bool TryCheckConnected(out bool connected)
Determines whether the tracked object is still connected.
override void SetInvalidPoseGameboardSpace(in T5_GlassesPose glassesPose, GlassesSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
override void Update(GlassesSettings glassesSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
Updates this T:TiltFive.Glasses.BaseGlassesCore
override void SetPoseUnityWorldSpace(ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
Sets the pose values of the tracked object in Unity World Space
Pose GetPoseGameboardSpace(T5_GlassesPose glassesPose)
override void SetPoseGameboardSpace(in T5_GlassesPose glassesPose, GlassesSettings glassesSettings, ScaleSettings scaleSettings, GameBoardSettings gameboardSettings)
override void SetDefaultPoseGameboardSpace(GlassesSettings settings)
Internal Glasses core runtime.
bool Validate(GlassesSettings glassesSettings, SpectatorSettings spectatorSettings)
Tests this T:TiltFive.Glasses.GlassesCore for validity with the parameterized T:TiltFive....
GlassesCore(GlassesHandle glassesHandle)
virtual void Update(GlassesSettings glassesSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings, SpectatorSettings spectatorSettings)
Updates this T:TiltFive.Glasses.GlassesCore
bool TryGetFriendlyName(out string friendlyName)
virtual void Reset(GlassesSettings glassesSettings, SpectatorSettings spectatorSettings)
Reset this T:TiltFive.Glasses.GlassesCore
Dictionary< AREyes, Vector3 > eyePositions
GlassesPreviewCore previewCore
override void SetDrivenObjectTransform(GlassesSettings settings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
bool configured
Configuration ready indicator.
Trackable core for the smoothed glasses preview pose.
new void Update(GlassesSettings glassesSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
Updates this T:TiltFive.Glasses.GlassesPreviewCore
GlassesPreviewCore(GlassesHandle glassesHandle)
The Glasses API and runtime.
static Camera GetLeftEye(PlayerIndex playerIndex)
Gets the left eye camera for the specified player's glasses.
HashSet< GlassesHandle > incomingHandles
static Vector3 up
Gets the head orientation's up vector.
static bool TryGetPreviewPose(PlayerIndex playerIndex, out Pose pose)
Attempts to get the position and orientation of the specified player's glasses, smoothed for on-scree...
static bool updated
Gets a value indicating whether this T:TiltFive.Glasses is updated.
static Vector3 leftEyePosition
Gets the left eye position.
static Camera GetRightEye(GlassesHandle glassesHandle)
static bool IsTracked(PlayerIndex playerIndex=PlayerIndex.One)
Indicate if the specified glasses are tracked.
GlassesHandle? defaultGlassesHandle
The identifier for the first detected pair of glasses.
static Vector3 rightEyePosition
Gets the right eye position.
static void Reset(GlassesSettings glassesSettings, SpectatorSettings spectatorSettings=null, PlayerIndex playerIndex=PlayerIndex.None)
Reset this T:TiltFive.Glasses.
static Vector3 position
Gets the head pose position.
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.
static Vector3 forward
Gets the head orientation's forward vector.
Dictionary< GlassesHandle, GlassesCore > glassesCores
The glasses core runtimes.
static GameObject GetPoseRoot(PlayerIndex playerIndex)
Gets the pose root GameObject for the specified player.
static Vector3 right
Gets the head orientation's right vector.
static void Update(GlassesSettings glassesSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
Updates this T:TiltFive.Glasses.
static GlassesCore GetPlayerOneGlassesCore()
static GameObject GetPoseRoot(GlassesHandle glassesHandle)
static Camera GetLeftEye(GlassesHandle glassesHandle)
static bool TryGetPose(PlayerIndex playerIndex, out Pose pose)
Attempts to get the position and orientation of the specified player's glasses.
static Quaternion rotation
Gets the head pose rotation.
static bool glassesAvailable
Indicates whether the glasses are plugged in and functioning.
static bool IsConnected(PlayerIndex playerIndex=PlayerIndex.One)
Indicate if the specified glasses are connected.
static bool Validate(GlassesSettings glassesSettings, SpectatorSettings spectatorSettings=null, PlayerIndex playerIndex=PlayerIndex.One)
Validates the specified glassesSettings with the specified glasses core.
static bool configured
Gets a value indicating whether this T:TiltFive.Glasses is configured.
static void ScanForGlasses()
HashSet< GlassesHandle > lostHandles
static bool headPoseUpdated(PlayerIndex playerIndex=PlayerIndex.One)
Returns a boolean indication that the head pose was successfully updated.
static Camera GetRightEye(PlayerIndex playerIndex)
Gets the right eye camera for the specified player's glasses.
static bool TryGetSpectatorSettings(out SpectatorSettings spectatorSettings)
GlassesSettings encapsulates all configuration data used by the Glasses' tracking runtime to compute ...
Camera cameraTemplate
The camera used as a template for creating the eye cameras at runtime.
static readonly string DEFAULT_FRIENDLY_NAME
const float DEFAULT_IPD_UGBD
float farClipPlane
The far clip plane in physical space (meters), to adjust for content scale and gameboard size
LayerMask cullingMask
The culling mask to be used by the eye cameras for this pair of glasses.
GameObject objectTemplate
The object used as a template for creating the base Game Object when a specific playerIndex connects.
float nearClipPlane
The near clip plane in physical space (meters), to adjust for content scale and gameboard size
static void Warn(string m, params object[] list)
WARN logging function call.
static void Info(string m, params object[] list)
INFO logging function call.
static void Error(string m, params object[] list)
ERROR logging function call.
Provides access to player settings and functionality.
static bool IsConnected(PlayerIndex playerIndex)
Determines whether the specified player has an associated pair of glasses connected.
ScaleSettings contains the scale data used to translate between Unity units and the user's physical s...
float GetScaleToUWRLD_UGBD(float gameboardScale)
PlayerIndex spectatedPlayer
The player that will have their perspective mirrored on screen.
Camera spectatorCamera
The camera used for rendering the onscreen preview
void Initialize(GameObject headPoseRoot, GlassesSettings glassesSettings, SpectatorSettings spectatorSettings)
Quaternion rotToUGBD_UWRLD
The rotation taking points from the Unity world-space reference frame to the game board reference fra...
Camera leftEyeCamera
The left eye Camera property.
Camera cameraTemplate
The Camera used as a template when creating the eye cameras.
Vector3 posUGBD_UWRLD
The position of the game board reference frame w.r.t. the Unity world-space reference frame.
Camera rightEyeCamera
The right eye Camera property.
float scaleToUGBD_UWRLD
The uniform scale factor that takes points from the Unity world-space to the game board reference fra...
static bool TryGetISceneInfo(out ISceneInfo sceneInfo)
Pose Pose_UnityWorldSpace
The Pose of the trackable in Unity world space.
bool RejectUntrackedPositionData
TrackingFailureMode FailureMode
ControllerIndex
Since wands are all physically identical (they have no "handedness"), it doesn't make sense to addres...
GameboardType
The type of Gameboard being tracked by the glasses
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)