Beispiel #1
0
        void OnPreRender()
        {
            if (screenWidth != Screen.width || screenHeight != Screen.height)
            {
                screenWidth  = Screen.width;
                screenHeight = Screen.height;
                MaxstAR.OnSurfaceChanged(screenWidth, screenHeight);
            }

            if (orientation != Screen.orientation)
            {
                orientation = Screen.orientation;

                if (Application.platform == RuntimePlatform.Android ||
                    Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    MaxstAR.SetScreenOrientation((int)orientation);
                }
            }

            if (nearClipPlane != arCamera.nearClipPlane || farClipPlane != arCamera.farClipPlane)
            {
                nearClipPlane = arCamera.nearClipPlane;
                farClipPlane  = arCamera.farClipPlane;
            }

            arCamera.projectionMatrix = CameraDevice.GetInstance().GetProjectionMatrix();
        }
Beispiel #2
0
        /// <summary>
        /// Set device orientation and surface size
        /// </summary>
        void InitInternal()
        {
            licenseKey = AbstractConfigurationScriptableObject.GetInstance().LicenseKey;

#if UNITY_IOS && !UNITY_EDITOR
            NativeAPI.init(licenseKey);
#endif

            // If CameraBackgroundBehaviour is not activated when start application, projection matrix
            // can not be made because screen width and height isn't set properly.
            if (screenWidth != Screen.width || screenHeight != Screen.height)
            {
                screenWidth  = Screen.width;
                screenHeight = Screen.height;
                MaxstAR.OnSurfaceChanged(screenWidth, screenHeight);
            }

            if (Application.platform == RuntimePlatform.Android ||
                Application.platform == RuntimePlatform.IPhonePlayer)
            {
                MaxstAR.SetScreenOrientation((int)Screen.orientation);
            }
            else
            {
                MaxstAR.SetScreenOrientation((int)ScreenOrientation.LandscapeLeft);
            }

            arCamera = GetComponent <Camera>();
        }
Beispiel #3
0
        /// <summary>
        /// Intialize sdk
        /// </summary>
        protected void Init()
        {
            InitInternal();

            if (Application.platform == RuntimePlatform.Android ||
                Application.platform == RuntimePlatform.IPhonePlayer)
            {
                MaxstAR.SetScreenOrientation((int)Screen.orientation);
            }
            else
            {
                MaxstAR.SetScreenOrientation((int)ScreenOrientation.LandscapeLeft);
            }

            MaxstAR.OnSurfaceChanged(Screen.width, Screen.height);
        }
        void OnPreRender()
        {
            if (screenWidth != Screen.width || screenHeight != Screen.height)
            {
                screenWidth  = Screen.width;
                screenHeight = Screen.height;
                MaxstAR.OnSurfaceChanged(screenWidth, screenHeight);
            }

            if (orientation != Screen.orientation)
            {
                orientation = Screen.orientation;

                if (Application.platform == RuntimePlatform.Android ||
                    Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    MaxstAR.SetScreenOrientation((int)orientation);
                }
            }

            if (nearClipPlane != arCamera.nearClipPlane || farClipPlane != arCamera.farClipPlane)
            {
                nearClipPlane = arCamera.nearClipPlane;
                farClipPlane  = arCamera.farClipPlane;
            }

            int tempCameraWidth  = CameraDevice.GetInstance().GetWidth();
            int tempCameraHeight = CameraDevice.GetInstance().GetHeight();

            if (tempCameraWidth == 0 || tempCameraHeight == 0)
            {
                return;
            }

            if (cameraWidth != tempCameraWidth || cameraHeight != tempCameraHeight)
            {
                cameraWidth  = tempCameraWidth;
                cameraHeight = tempCameraHeight;
            }

            //if (AbstractCameraBackgroundBehaviour.Instance != null)
            //{
            //	TransformBackgroundPlane(arCamera, AbstractCameraBackgroundBehaviour.Instance.transform);
            //}

            arCamera.projectionMatrix = CameraDevice.GetInstance().GetProjectionMatrix();
        }
        void Awake()
        {
            Debug.Log("Current graphics device type is " + SystemInfo.graphicsDeviceType + ".");

            if (Application.platform == RuntimePlatform.Android ||
                Application.platform == RuntimePlatform.IPhonePlayer)
            {
                MaxstAR.SetScreenOrientation((int)Screen.orientation);
            }
            else
            {
                MaxstAR.SetScreenOrientation((int)ScreenOrientation.LandscapeLeft);
            }

            rg16TextureSupported = false;

            try
            {
                if (SystemInfo.SupportsTextureFormat((TextureFormat)62))
                {
                    Debug.Log("RG16 Support");
                    rg16TextureSupported = true;
                }
                else
                {
                    if (Application.platform == RuntimePlatform.OSXEditor)
                    {
                        Debug.Log("RG16 Support");
                        rg16TextureSupported = true;
                    }
                    else
                    {
                        Debug.Log("RG16 not Support");
                        rg16TextureSupported = false;
                    }
                }
            }
            catch (Exception e)              // CS0168
            {
                Debug.Log("Exception! " + e.Message);
                rg16TextureSupported = false;
            }
        }
        /// <summary>
        /// Intialize sdk
        /// </summary>
        protected void Init()
        {
            int screenScale = (int)Screen.dpi / 100;

            arCamera = GetComponent <Camera>();
            ARManagerTargetObject aRManagerTargetObject = GetComponent <ARManagerTargetObject>();

            if (aRManagerTargetObject != null)
            {
                targetImage = aRManagerTargetObject.targetImageUI;
                if (arCamera != null)
                {
                    float width  = targetImage.rectTransform.rect.width;
                    float height = targetImage.rectTransform.rect.height;
                    renderTexture                    = new RenderTexture((int)(width * screenScale), (int)(height * screenScale), 24);
                    arCamera.targetTexture           = renderTexture;
                    targetImage.material.mainTexture = renderTexture;
                    targetImage.SetAllDirty();
                }
            }

            InitInternal();

            if (Application.platform == RuntimePlatform.Android ||
                Application.platform == RuntimePlatform.IPhonePlayer)
            {
                MaxstAR.SetScreenOrientation((int)Screen.orientation);
            }
            else
            {
                MaxstAR.SetScreenOrientation((int)ScreenOrientation.LandscapeLeft);
            }

            if (targetImage != null)
            {
                MaxstAR.OnSurfaceChanged((int)targetImage.rectTransform.rect.width, (int)targetImage.rectTransform.rect.height);
            }
            else
            {
                MaxstAR.OnSurfaceChanged(Screen.width, Screen.height);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Set device orientation and surface size
        /// </summary>
        void InitInternal()
        {
            // If CameraBackgroundBehaviour is not activated when start application, projection matrix
            // can not be made because screen width and height isn't set properly yet.
            if (screenWidth != Screen.width || screenHeight != Screen.height)
            {
                screenWidth  = Screen.width;
                screenHeight = Screen.height;
                MaxstAR.OnSurfaceChanged(screenWidth, screenHeight);
            }

            if (Application.platform == RuntimePlatform.Android ||
                Application.platform == RuntimePlatform.IPhonePlayer)
            {
                MaxstAR.SetScreenOrientation((int)Screen.orientation);
            }
            else
            {
                MaxstAR.SetScreenOrientation((int)ScreenOrientation.LandscapeLeft);
            }

            arCamera = GetComponent <Camera>();
        }
        void OnPreRender()
        {
            if (targetImage != null)
            {
                if (screenWidth != (int)targetImage.rectTransform.rect.width || screenHeight != (int)targetImage.rectTransform.rect.height)
                {
                    screenWidth  = (int)targetImage.rectTransform.rect.width;
                    screenHeight = (int)targetImage.rectTransform.rect.height;
                    if (arCamera.targetTexture != null)
                    {
                        arCamera.targetTexture.Release();
                    }
                    int   screenScale = (int)Screen.dpi / 100;
                    float width       = targetImage.rectTransform.rect.width;
                    float height      = targetImage.rectTransform.rect.height;
                    renderTexture                    = new RenderTexture((int)(width * screenScale), (int)(height * screenScale), 24);
                    arCamera.targetTexture           = renderTexture;
                    targetImage.material.mainTexture = renderTexture;
                    targetImage.SetAllDirty();
                    MaxstAR.OnSurfaceChanged(screenWidth, screenHeight);
                }
            }
            else
            {
                if (screenWidth != Screen.width || screenHeight != Screen.height)
                {
                    screenWidth  = Screen.width;
                    screenHeight = Screen.height;
                    MaxstAR.OnSurfaceChanged(screenWidth, screenHeight);
                }
            }


            if (orientation != Screen.orientation)
            {
                orientation = Screen.orientation;

                if (Application.platform == RuntimePlatform.Android ||
                    Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    MaxstAR.SetScreenOrientation((int)orientation);
                }
            }

            if (nearClipPlane != arCamera.nearClipPlane || farClipPlane != arCamera.farClipPlane)
            {
                nearClipPlane = arCamera.nearClipPlane;
                farClipPlane  = arCamera.farClipPlane;
            }

            int tempCameraWidth  = CameraDevice.GetInstance().GetWidth();
            int tempCameraHeight = CameraDevice.GetInstance().GetHeight();

            if (tempCameraWidth == 0 || tempCameraHeight == 0)
            {
                return;
            }

            if (cameraWidth != tempCameraWidth || cameraHeight != tempCameraHeight)
            {
                cameraWidth  = tempCameraWidth;
                cameraHeight = tempCameraHeight;
            }

            if (AbstractCameraBackgroundBehaviour.Instance != null)
            {
                TransformBackgroundPlane(arCamera, AbstractCameraBackgroundBehaviour.Instance.transform);
            }

            arCamera.projectionMatrix = CameraDevice.GetInstance().GetProjectionMatrix();
        }
Beispiel #9
0
        void Awake()
        {
            base.Init();

#if UNITY_ANDROID
            androidEngine = new AndroidEngine();
#elif UNITY_IOS
            string licenseKey = ConfigurationScriptableObject.GetInstance().LicenseKey;
            NativeAPI.init(licenseKey);
#endif

#if UNITY_EDITOR
            // Find arsdk_version.txt
            // if not exist file create file and write arsdk version
            // if file exist write
            System.IO.File.WriteAllText(System.IO.Path.Combine(Application.streamingAssetsPath, "arsdk_version.txt"), MaxstAR.GetVersion());
#endif
        }
Beispiel #10
0
        void Awake()
        {
            base.Init();

#if UNITY_ANDROID
            androidEngine = new AndroidEngine();
#endif

#if UNITY_EDITOR
            // Find arsdk_version.txt
            // if not exist file create file and write arsdk version
            // if file exist write
            System.IO.File.WriteAllText(System.IO.Path.Combine(Application.streamingAssetsPath, "arsdk_version.txt"), MaxstAR.GetVersion());
#endif
        }