7 using System.Runtime.InteropServices;
17 private GameObject eyeLeft = null;
18 private GameObject eyeRight = null;
24 if (Application.platform == RuntimePlatform.Android)
32 bool res = wearableDeviceController.IsSupportedWearableDevice();
33 Debug.Log(
"wearableDeviceController.IsSupportedWearableDevice()" + res.ToString());
34 if (wearableDeviceController.IsSupportedWearableDevice())
36 string modelName = wearableDeviceController.GetModelName();
38 Debug.Log(modelName.ToString());
39 if (wearableCalibration.
Init(modelName, Screen.width, Screen.height))
41 Debug.Log(
"wearableCalibration.Init suc");
42 wearableDeviceController.SetStereoMode(
true);
45 cameraBackground.gameObject.SetActive(
false);
56 if (Application.platform == RuntimePlatform.Android)
63 wearableDeviceController.SetStereoMode(
false);
64 wearableCalibration.
Deinit();
71 private void CreateWearableEye()
75 eyeLeft =
new GameObject(
"EyeLeft");
76 eyeLeft.AddComponent<Camera>();
81 eyeRight =
new GameObject(
"EyeRight");
82 eyeRight.AddComponent<Camera>();
85 eyeLeft.transform.parent = transform;
86 eyeRight.transform.parent = transform;
88 eyeLeft.transform.localPosition = Vector3.zero;
89 eyeLeft.transform.localRotation = Quaternion.identity;
90 eyeLeft.transform.localScale = Vector3.one;
92 eyeRight.transform.localPosition = Vector3.zero;
93 eyeRight.transform.localRotation = Quaternion.identity;
94 eyeRight.transform.localScale = Vector3.one;
96 Camera mainCamera = transform.GetComponent<Camera>();
97 Camera leftCamera = eyeLeft.GetComponent<Camera>();
98 Camera rightCamera = eyeRight.GetComponent<Camera>();
100 CameraClearFlags clearFlags = mainCamera.clearFlags;
101 Color backgroundColor = mainCamera.backgroundColor;
102 float depth = mainCamera.depth + 1;
103 float nearClipPlane = mainCamera.nearClipPlane;
104 float farClipPlane = mainCamera.farClipPlane;
109 Matrix4x4 projectionEyeLeft = MatrixUtils.ConvertGLProjectionToUnityProjection(projectionMatrixEyeLeftPtr);
110 Matrix4x4 projectionEyeRight = MatrixUtils.ConvertGLProjectionToUnityProjection(projectionMatrixEyeRightPtr);
112 leftCamera.clearFlags = clearFlags;
113 leftCamera.backgroundColor = backgroundColor;
114 leftCamera.depth = depth;
115 leftCamera.nearClipPlane = nearClipPlane;
116 leftCamera.farClipPlane = farClipPlane;
117 leftCamera.rect =
new Rect(0.0f, 0.0f, 0.5f, 1.0f);
118 leftCamera.projectionMatrix = projectionEyeLeft;
120 rightCamera.clearFlags = clearFlags;
121 rightCamera.backgroundColor = backgroundColor;
122 rightCamera.depth = depth;
123 rightCamera.nearClipPlane = nearClipPlane;
124 rightCamera.farClipPlane = farClipPlane;
125 rightCamera.rect =
new Rect(0.5f, 0.0f, 0.5f, 1.0f);
126 rightCamera.projectionMatrix = projectionEyeRight;
129 private void DestroyWearableEye()
133 DestroyImmediate(eyeLeft);
136 if (eyeRight != null)
138 DestroyImmediate(eyeRight);
bool Init(string modelName, int width, int height)
Initialize the HMD device.
static AbstractConfigurationScriptableObject GetInstance()
Get configuration asset instance
WearableType
Wearable Device Type
float [] GetProjectionMatrix(EyeType eyeType)
Get calibrated HMD projection matrix.
API for wearable calibration.
static WearableCalibration GetInstance()
Get a WearableCalibration instance.
void Deinit()
Deinitialize the HMD device.
Control the configuration asset file
Handles native background rendering. Background rendering includes camera image, feature point...
WearableCalibration.WearableType WearableType
Select wearable device type
Create stereo camera for optical see-through HMD