Esempio n. 1
0
    public void OnPreCull()
    {
        if (!Mojing.SDK.NeedDistortion && Mojing.SDK.VRModeEnabled)
        {
            GetComponent <Camera>().projectionMatrix = CreateMatrix();
        }
        else
        {
            GetComponent <Camera>().ResetProjectionMatrix();
        }
        if (Mojing.SDK.bWaitForMojingWord)
        {
            EnableEye(false);
            return;
        }
        if (GetComponent <Camera>() != null)
        {
            SetUpEye();
#if !UNITY_EDITOR && UNITY_ANDROID
            //mojing2 render directly
            if (!Mojing.SDK.NeedDistortion)
            {
                return;
            }

            if (MojingSDK.Unity_IsEnableATW())
            {
                int iFrameIndex = 0;
                if (MojingSDK.Unity_IsATW_ON())
                {
                    // Unity_ATW_GetModelFrameIndex 接口中自带睡眠代码
                    iFrameIndex = MojingSDK.Unity_ATW_GetModelFrameIndex();
                }
                switch (eye)
                {
                case Mojing.Eye.Left:
                    GetComponent <Camera>().targetTexture = MojingRender.StereoScreen[iFrameIndex * 2];
                    break;

                case Mojing.Eye.Right:
                    GetComponent <Camera>().targetTexture = MojingRender.StereoScreen[iFrameIndex * 2 + 1];
                    break;
                }
            }
#endif
        }
        else
        {
            MojingLog.LogError(eye.ToString() + ": no camera found.");
        }
    }