24 instance = FindObjectOfType<AbstractARManager>();
31 private string licenseKey = null;
33 private int screenWidth = 0;
34 private int screenHeight = 0;
35 private ScreenOrientation orientation = ScreenOrientation.Unknown;
36 private float nearClipPlane = 0.0f;
37 private float farClipPlane = 0.0f;
38 private Camera arCamera = null;
39 private int cameraWidth = 0;
40 private int cameraHeight = 0;
50 if (Application.platform == RuntimePlatform.Android ||
51 Application.platform == RuntimePlatform.IPhonePlayer)
60 MaxstAR.OnSurfaceChanged(Screen.width, Screen.height);
69 if (Application.platform == RuntimePlatform.Android)
73 else if (Application.platform == RuntimePlatform.IPhonePlayer)
80 if (screenWidth != Screen.width || screenHeight != Screen.height)
82 screenWidth = Screen.width;
83 screenHeight = Screen.height;
84 MaxstAR.OnSurfaceChanged(screenWidth, screenHeight);
87 if (Application.platform == RuntimePlatform.Android ||
88 Application.platform == RuntimePlatform.IPhonePlayer)
97 arCamera = GetComponent<Camera>();
110 Matrix4x4 targetPose = trackable.GetTargetPose().inverse;
112 if (targetPose == Matrix4x4.zero)
115 Quaternion rotation = Quaternion.Euler(90, 0, 0);
116 Matrix4x4 m = Matrix4x4.TRS(
new Vector3(0, 0, 0), rotation,
new Vector3(1, 1, 1));
117 targetPose = m * targetPose;
119 Camera.main.transform.position = MatrixUtils.PositionFromMatrix(targetPose);
120 Camera.main.transform.rotation = MatrixUtils.QuaternionFromMatrix(targetPose);
121 Camera.main.transform.localScale = MatrixUtils.ScaleFromMatrix(targetPose);
131 if (Application.platform == RuntimePlatform.Android)
133 androidEngine.Dispose();
164 return worldCenterMode;
174 this.worldCenterMode = worldCenterMode;
179 if (screenWidth != Screen.width || screenHeight != Screen.height)
181 screenWidth = Screen.width;
182 screenHeight = Screen.height;
183 MaxstAR.OnSurfaceChanged(screenWidth, screenHeight);
186 if (orientation != Screen.orientation)
188 orientation = Screen.orientation;
190 if (Application.platform == RuntimePlatform.Android ||
191 Application.platform == RuntimePlatform.IPhonePlayer)
193 MaxstAR.SetScreenOrientation((
int)orientation);
197 if (nearClipPlane != arCamera.nearClipPlane || farClipPlane != arCamera.farClipPlane)
199 nearClipPlane = arCamera.nearClipPlane;
200 farClipPlane = arCamera.farClipPlane;
210 int tempCameraWidth = CameraDevice.GetInstance().GetWidth();
211 int tempCameraHeight = CameraDevice.GetInstance().GetHeight();
213 if (tempCameraWidth == 0 || tempCameraHeight == 0)
218 if (cameraWidth != tempCameraWidth || cameraHeight != tempCameraHeight)
220 cameraWidth = tempCameraWidth;
221 cameraHeight = tempCameraHeight;
224 TransformBackgroundPlane(arCamera, AbstractCameraBackgroundBehaviour.Instance.transform);
226 arCamera.projectionMatrix = MatrixUtils.getProjectionMatrix();
241 private void TransformBackgroundPlane(Camera camera, Transform planeTransform)
243 float widthRatio = (float)Screen.width / cameraWidth;
244 float heightRatio = (
float)Screen.height / cameraHeight;
245 float farClipPlane = camera.farClipPlane * 0.90f;
246 float tanFovWidth = (1.0f / (float)Screen.width) * (float)Screen.height;
247 float frustumWidth = tanFovWidth * farClipPlane * camera.aspect;
248 float viewWidth = (
float)frustumWidth / Screen.width;
249 float viewHeight = viewWidth * (widthRatio / heightRatio);
250 float flipHorizontal = 1.0f;
251 float flipVertical = 1.0f;
262 if (CameraDevice.GetInstance().IsFlipHorizontal())
264 flipHorizontal = -1.0f;
267 if (CameraDevice.GetInstance().IsFlipVertical())
269 flipVertical = -1.0f;
272 if (MaxstARUtils.IsDirectXAPI())
274 flipHorizontal = -flipHorizontal;
277 if (widthRatio > heightRatio)
279 planeTransform.localScale =
new Vector3(widthRatio * cameraWidth * viewWidth * flipVertical,
280 widthRatio * cameraHeight * viewWidth * flipHorizontal, 0.1f);
281 planeTransform.localPosition =
new Vector3(0.0f, 0.0f, farClipPlane);
285 planeTransform.localScale =
new Vector3(heightRatio * cameraWidth * viewHeight * flipVertical,
286 heightRatio * cameraHeight * viewHeight * flipHorizontal, 0.1f);
287 planeTransform.localPosition =
new Vector3(0.0f, 0.0f, farClipPlane);
290 if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D9 ||
291 SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 ||
292 SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12)
294 planeTransform.localScale =
new Vector3(planeTransform.localScale.x, -planeTransform.localScale.y, planeTransform.localScale.z);
WorldCenterMode
The world center mode defines what is the center in game view. If camera is world center then trackab...
Trackable GetTrackable(int index)
Get tracking target information
static AbstractConfigurationScriptableObject GetInstance()
Get configuration asset instance
virtual void OnDestroy()
Release sdk
static void SetScreenOrientation(int orientation)
Notify screen orientation chagned
WorldCenterMode WorldCenterModeSetting
Get world center mode value
void Init()
Set device orientation and surface size
TrackingResult GetTrackingResult()
Output the number of trackers that have been tracked successfully.
Container for individual tracking information
Initialize system environment with app key, screen size and orientation
int GetCount()
Get tracking target count. Current version ar engine could not track multi target. That feature will be implemented not so far future.
string LicenseKey
App signature key
TrackingState GetTrackingState()
Get saved TrackingState value
void SetWorldCenterMode(WorldCenterMode worldCenterMode)
Set world center mode
Control the configuration asset file
virtual void Awake()
Intialize sdk
Contains tracked targets informations
static TrackerManager GetInstance()
Get TrackerManager instance
Control AR Engine (Singletone)
Container for individual tracking information