41 public bool xyz =
true;
82 catch (System.DllNotFoundException e)
84 Log.
Info(
"Could not connect to Tilt Five plugin to get callback: {0}", e);
93 QualitySettings.vSyncCount = 0;
94 QualitySettings.maxQueuedFrames = 0;
99 string version =
"NOT VERSIONED";
102 TextAsset asset = (TextAsset)Resources.Load(
"pluginversion", typeof(TextAsset));
105 version = asset.text;
109 bool logEnabled = Debug.unityLogger.logEnabled;
112 Debug.unityLogger.logEnabled =
true;
116 StackTraceLogType logType = Application.GetStackTraceLogType(LogType.Log);
119 Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
121 Log.
Info(
"\n********************************" +
122 "\n* Tilt Five: Unity SDK Version - " +
124 "\n********************************");
127 Application.SetStackTraceLogType(LogType.Log, logType);
130 Debug.unityLogger.logEnabled = logEnabled;
133 [Obsolete(
"This function has been moved into TiltFive.SystemControl")]
152 IntPtr leftTexHandle,
153 IntPtr rightTexHandle,
158 float widthToHeightRatio,
159 Quaternion rotToUGBD_ULVC,
160 Vector3 posOfULVC_UGBD,
161 Quaternion rotToUGBD_URVC,
162 Vector3 posOfURVC_UGBD) {
163 return Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
179 GlassesHandle glassesHandle,
180 IntPtr leftTexHandle,
181 IntPtr rightTexHandle,
186 float widthToHeightRatio,
187 Quaternion rotToUGBD_ULVC,
188 Vector3 posOfULVC_UGBD,
189 Quaternion rotToUGBD_URVC,
190 Vector3 posOfURVC_UGBD)
192 return Instance.PresentStereoImagesImpl(glassesHandle,
207 UInt64 glassesHandle,
208 IntPtr leftTexHandle,
209 IntPtr rightTexHandle,
214 float widthToHeightRatio,
215 Quaternion rotToUGBD_ULVC,
216 Vector3 posOfULVC_UGBD,
217 Quaternion rotToUGBD_URVC,
218 Vector3 posOfURVC_UGBD)
237 Quaternion rotToDC_GBD = Quaternion.AngleAxis(-90f, Vector3.right);
240 float startY_VCI = -Mathf.Tan(fovYDegrees * (0.5f * Mathf.PI / 180.0f));
241 float startX_VCI = startY_VCI * widthToHeightRatio;
242 float width_VCI = -2f * startX_VCI;
243 float height_VCI = -2f * startY_VCI;
244 Rect vci =
new Rect(startX_VCI, startY_VCI, width_VCI, height_VCI);
247 Quaternion rotToLVC_DC =
new Quaternion(rotToUGBD_ULVC.x, rotToUGBD_ULVC.y, -rotToUGBD_ULVC.z, rotToUGBD_ULVC.w);
248 Quaternion rotToRVC_DC =
new Quaternion(rotToUGBD_URVC.x, rotToUGBD_URVC.y, -rotToUGBD_URVC.z, rotToUGBD_URVC.w);
250 Quaternion rotToLVC_GBD = rotToLVC_DC * rotToDC_GBD;
251 Quaternion rotToRVC_GBD = rotToRVC_DC * rotToDC_GBD;
254 Vector3 posOfLVC_GBD =
new Vector3(posOfULVC_UGBD.x, posOfULVC_UGBD.z, posOfULVC_UGBD.y);
255 Vector3 posOfRVC_GBD =
new Vector3(posOfURVC_UGBD.x, posOfURVC_UGBD.z, posOfURVC_UGBD.y);
258 T5_FrameInfo frameInfo =
new T5_FrameInfo();
260 frameInfo.LeftTexHandle = leftTexHandle;
261 frameInfo.RightTexHandle = rightTexHandle;
263 frameInfo.TexWidth_PIX = (UInt16) texWidth_PIX;
264 frameInfo.TexHeight_PIX = (UInt16) texHeight_PIX;
266 frameInfo.IsSrgb = isSrgb;
267 frameInfo.IsUpsideDown =
false;
271 frameInfo.RotToLVC_GBD = rotToLVC_GBD;
272 frameInfo.PosOfLVC_GBD = posOfLVC_GBD;
274 frameInfo.RotToRVC_GBD = rotToRVC_GBD;
275 frameInfo.PosOfRVC_GBD = posOfRVC_GBD;
280 result =
NativePlugin.QueueStereoImages(glassesHandle, frameInfo);
300 Log.
Error(
"Unable to send frame - the native plugin DLL may be failing to load");
307 Log.
Error(
"Unable to send frame - the native plugin returned a null SendFrame callback");
315 GL.InvalidateState();
319 Log.
Error($
"Failed to execute sendFrame callback: {e.Message}");
328 return Instance.GetDisplayDimensionsImpl(ref displayDimensions);
342 else Log.
Warn(
"Display.cs: Failed to retrieve display settings from plugin.");
352 public static bool GetGlassesIPD(UInt64 glassesHandle, ref
float glassesIPD)
354 return Instance.GetGlassesIPDImpl(glassesHandle, ref glassesIPD);
362 result =
NativePlugin.GetGlassesIPD(glassesHandle, ref glassesIPD);
366 Log.
Warn(
"Display.cs: Failed to retrieve glasses IPD");
377 internal static void ApplyGraphicsSettings(
GraphicsSettings graphicsSettings)
388 Application.targetFrameRate = graphicsSettings.applicationTargetFramerate;
389 QualitySettings.vSyncCount = graphicsSettings.applicationVSyncCount;
406 public static Matrix4x4
Frustum(
float L,
float R,
float B,
float T,
float n,
float f)
408 Matrix4x4 m =
new Matrix4x4();
410 m[0, 0] = (2 * n) / (R - L);
411 m[1, 1] = (2 * n) / (T - B);
412 m[0, 2] = (R + L) / (R - L);
413 m[1, 2] = (T + B) / (T - B);
414 m[2, 2] = -(f + n) / (f - n);
415 m[2, 3] = -(2 * f * n) / (f - n);
AllAxesBoolean(bool setXYZ)
AxesBoolean(bool setX, bool setY, bool setZ)
static Matrix4x4 Frustum(float L, float R, float B, float T, float n, float f)
static Matrix4x4 Frustum(ARProjectionFrustum f)
bool PresentStereoImagesImpl(UInt64 glassesHandle, IntPtr leftTexHandle, IntPtr rightTexHandle, int texWidth_PIX, int texHeight_PIX, bool isSrgb, float fovYDegrees, float widthToHeightRatio, Quaternion rotToUGBD_ULVC, Vector3 posOfULVC_UGBD, Quaternion rotToUGBD_URVC, Vector3 posOfURVC_UGBD)
static bool GetDisplayDimensions(ref Vector2Int displayDimensions)
bool GetGlassesIPDImpl(UInt64 glassesHandle, ref float glassesIPD)
static bool GetGlassesIPD(UInt64 glassesHandle, ref float glassesIPD)
static bool SetApplicationInfo()
IntPtr _sendFrameCallback
bool GetDisplayDimensionsImpl(ref Vector2Int displayDimensions)
static bool GetGlassesAvailability()
Get whether any glasses are available
static bool PresentStereoImages(PlayerIndex playerIndex, IntPtr leftTexHandle, IntPtr rightTexHandle, int texWidth_PIX, int texHeight_PIX, bool isSrgb, float fovYDegrees, float widthToHeightRatio, Quaternion rotToUGBD_ULVC, Vector3 posOfULVC_UGBD, Quaternion rotToUGBD_URVC, Vector3 posOfURVC_UGBD)
GraphicsSettings encapsulates configuration data related to the project's graphics settings,...
bool matchGlassesFramerate
Determines whether the Tilt Five SDK should optimize the project's framerate and vsync for sending fr...
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.
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)
ARProjectionFrustum(float l, float r, float b, float t, float n, float f)