17using System.Runtime.InteropServices;
42 public bool xyz =
true;
83 catch (System.DllNotFoundException e)
85 Log.
Info(
"Could not connect to Tilt Five plugin to get callback: {0}", e);
94 QualitySettings.vSyncCount = 0;
95 QualitySettings.maxQueuedFrames = 0;
110 string version =
"NOT VERSIONED";
113 TextAsset asset = (TextAsset)Resources.Load(
"pluginversion", typeof(TextAsset));
116 version = asset.text;
120 bool logEnabled = Debug.unityLogger.logEnabled;
123 Debug.unityLogger.logEnabled =
true;
127 StackTraceLogType logType = Application.GetStackTraceLogType(LogType.Log);
130 Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
132 Log.
Info(
"\n********************************" +
133 "\n* Tilt Five: Unity SDK Version - " +
135 "\n********************************");
138 Application.SetStackTraceLogType(LogType.Log, logType);
141 Debug.unityLogger.logEnabled = logEnabled;
146 return Instance.SetApplicationInfoImpl();
151 string applicationName = Application.productName;
154 applicationName = $
"Unity Editor: {applicationName}";
156 string applicationId = Application.identifier;
157 string productVersion = Application.version;
158 string engineVersion = Application.unityVersion;
159 TextAsset pluginVersionAsset = (TextAsset)Resources.Load(
"pluginversion");
160 string applicationVersionInfo = $
"App: {productVersion}, Engine: {engineVersion}, T5 SDK: {pluginVersionAsset.text}";
173 catch (System.DllNotFoundException e)
175 Log.
Info(
"Could not connect to Tilt Five plugin to register project info: {0}", e);
179 Log.
Error(
"Failed to register project info with the Tilt Five service.");
198 IntPtr leftTexHandle,
199 IntPtr rightTexHandle,
204 float widthToHeightRatio,
205 Quaternion rotToUGBD_ULVC,
206 Vector3 posOfULVC_UGBD,
207 Quaternion rotToUGBD_URVC,
208 Vector3 posOfURVC_UGBD) {
209 return Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
225 GlassesHandle glassesHandle,
226 IntPtr leftTexHandle,
227 IntPtr rightTexHandle,
232 float widthToHeightRatio,
233 Quaternion rotToUGBD_ULVC,
234 Vector3 posOfULVC_UGBD,
235 Quaternion rotToUGBD_URVC,
236 Vector3 posOfURVC_UGBD)
238 return Instance.PresentStereoImagesImpl(glassesHandle,
253 UInt64 glassesHandle,
254 IntPtr leftTexHandle,
255 IntPtr rightTexHandle,
260 float widthToHeightRatio,
261 Quaternion rotToUGBD_ULVC,
262 Vector3 posOfULVC_UGBD,
263 Quaternion rotToUGBD_URVC,
264 Vector3 posOfURVC_UGBD)
283 Quaternion rotToDC_GBD = Quaternion.AngleAxis(-90f, Vector3.right);
286 float startY_VCI = -Mathf.Tan(fovYDegrees * (0.5f * Mathf.PI / 180.0f));
287 float startX_VCI = startY_VCI * widthToHeightRatio;
288 float width_VCI = -2f * startX_VCI;
289 float height_VCI = -2f * startY_VCI;
290 Rect vci =
new Rect(startX_VCI, startY_VCI, width_VCI, height_VCI);
293 Quaternion rotToLVC_DC =
new Quaternion(rotToUGBD_ULVC.x, rotToUGBD_ULVC.y, -rotToUGBD_ULVC.z, rotToUGBD_ULVC.w);
294 Quaternion rotToRVC_DC =
new Quaternion(rotToUGBD_URVC.x, rotToUGBD_URVC.y, -rotToUGBD_URVC.z, rotToUGBD_URVC.w);
296 Quaternion rotToLVC_GBD = rotToLVC_DC * rotToDC_GBD;
297 Quaternion rotToRVC_GBD = rotToRVC_DC * rotToDC_GBD;
300 Vector3 posOfLVC_GBD =
new Vector3(posOfULVC_UGBD.x, posOfULVC_UGBD.z, posOfULVC_UGBD.y);
301 Vector3 posOfRVC_GBD =
new Vector3(posOfURVC_UGBD.x, posOfURVC_UGBD.z, posOfURVC_UGBD.y);
306 frameInfo.LeftTexHandle = leftTexHandle;
307 frameInfo.RightTexHandle = rightTexHandle;
309 frameInfo.TexWidth_PIX = (UInt16) texWidth_PIX;
310 frameInfo.TexHeight_PIX = (UInt16) texHeight_PIX;
312 frameInfo.IsSrgb = isSrgb;
313 frameInfo.IsUpsideDown =
false;
317 frameInfo.RotToLVC_GBD = rotToLVC_GBD;
318 frameInfo.PosOfLVC_GBD = posOfLVC_GBD;
320 frameInfo.RotToRVC_GBD = rotToRVC_GBD;
321 frameInfo.PosOfRVC_GBD = posOfRVC_GBD;
346 Log.
Error(
"Unable to send frame - the native plugin DLL may be failing to load");
353 Log.
Error(
"Unable to send frame - the native plugin returned a null SendFrame callback");
361 GL.InvalidateState();
365 Log.
Error($
"Failed to execute sendFrame callback: {e.Message}");
374 return Instance.GetDisplayDimensionsImpl(ref displayDimensions);
388 else Log.
Warn(
"Display.cs: Failed to retrieve display settings from plugin.");
395 return (0 == result);
398 public static bool GetGlassesIPD(UInt64 glassesHandle, ref
float glassesIPD)
400 return Instance.GetGlassesIPDImpl(glassesHandle, ref glassesIPD);
412 Log.
Warn(
"Display.cs: Failed to retrieve glasses IPD");
420 return (0 == result);
436 public static Matrix4x4
Frustum(
float L,
float R,
float B,
float T,
float n,
float f)
438 Matrix4x4 m =
new Matrix4x4();
440 m[0, 0] = (2 * n) / (R - L);
441 m[1, 1] = (2 * n) / (T - B);
442 m[0, 2] = (R + L) / (R - L);
443 m[1, 2] = (T + B) / (T - B);
444 m[2, 2] = -(f + n) / (f - n);
445 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.
bool SetApplicationInfoImpl()
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)
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.
static int GetGlassesIPD(UInt64 glassesHandle, ref float glassesIPD)
static int QueueStereoImages(UInt64 glassesHandle, T5_FrameInfo frameInfo)
static IntPtr GetSendFrameCallback()
static int GetMaxDisplayDimensions([MarshalAs(UnmanagedType.LPArray, SizeConst=2)] int[] displayDimensions)
static int SetApplicationInfo(T5_StringUTF8 appName, T5_StringUTF8 appId, T5_StringUTF8 appVersion)
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)
Render information to be used with NativePlugin.QueueStereoImages(T5_FrameInfo)
Represents a string value.