Exemplo n.º 1
0
        void OnDestroy()
        {
            if (leftCamera != null)
            {
                leftCamera.targetTexture = null;
            }
            if (rightCamera != null)
            {
                rightCamera.targetTexture = null;
            }
            if (centerCamera != null)
            {
                centerCamera.targetTexture = null;
            }

            Composer.DpnuSetTextureEx((int)UIType, IntPtr.Zero, 0, (int)dpncTwType.NONE, new dpnRect(viewport));
            Composer.DpnuSetTextureEx((int)UIType, IntPtr.Zero, 1, (int)dpncTwType.NONE, new dpnRect(viewport));
            //Composer.DpnuSetTextureEx((int)UIType, IntPtr.Zero, 2, (int)dpncTwType.NONE, new dpnRect(viewport));
            for (int i = 0; i < Common.NUM_BUFFER; i++)
            {
                for (int j = 0; j < cameraNum; ++j)
                {
                    int index = i * cameraNum + j;
                    if (_canvas_texture[index].IsCreated())
                    {
                        _canvas_texture[index].Release();
                    }
                }
            }
        }
Exemplo n.º 2
0
        // Use this for initialization
        void Start()
        {
            _canvas_camera = GetComponent <Camera>();
            Reshape();
                        #if UNITY_ANDROID && !UNITY_EDITOR
                        #else
            if (0.0f == depth)
            {
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 0, (int)dpncTwType.DISTORTION, new dpnRect(viewport));
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 1, (int)dpncTwType.DISTORTION, new dpnRect(viewport));
            }
            else
            {
                Rect viewport_left  = new Rect(viewport.x + DpnManager.DeviceInfo.ipd / (4 * depth * (float)Math.Tan((Math.PI / 360) * DpnManager.DeviceInfo.fov_x)), viewport.y, viewport.width, viewport.height);
                Rect viewport_right = new Rect(viewport.x - DpnManager.DeviceInfo.ipd / (4 * depth * (float)Math.Tan((Math.PI / 360) * DpnManager.DeviceInfo.fov_x)), viewport.y, viewport.width, viewport.height);
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 0, (int)dpncTwType.DISTORTION, new dpnRect(viewport_left));
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 1, (int)dpncTwType.DISTORTION, new dpnRect(viewport_right));
            }
            #endif

#if UNITY_ANDROID && (UNITY_5_5_0 || UNITY_5_4_3)
            // In Unity 5.5.0 and Unity 5.4.3,
            // surface is deleted and rebuilt after the first frame is completed by Unity, the second frame will be black screen.
            // So, Skip the rendering of the first frame to avoid flickering.
            StartCoroutine(Coroutine_EnableCamera());
#endif

#if UNITY_EDITOR
            InitEditorMultiLayer();
#endif
        }
Exemplo n.º 3
0
 void OnDestroy()
 {
     Composer.DpnuSetTextureEx((int)UIType, IntPtr.Zero, 2, (int)dpncTwType.NONE, new dpnRect(viewport));
     for (int i = 0; i < Common.NUM_BUFFER; i++)
     {
         if (_canvas_texture[i].IsCreated())
         {
             _canvas_texture[i].Release();
         }
     }
 }
Exemplo n.º 4
0
        // Use this for initialization
        void Start()
        {
            Reshape();
#if UNITY_ANDROID && !UNITY_EDITOR
#else
            if (0.0f == depth)
            {
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 0, (int)dpncTwType.DISTORTION, new dpnRect(viewport));
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index + 1], 1, (int)dpncTwType.DISTORTION, new dpnRect(viewport));
            }
            else
            {
                // Rect viewport_left = new Rect(viewport.x + DpnManager.DeviceInfo.ipd / (4 * depth * (float)Math.Tan((Math.PI / 360) * DpnManager.DeviceInfo.fov_x)), viewport.y, viewport.width, viewport.height);
                // Rect viewport_right = new Rect(viewport.x - DpnManager.DeviceInfo.ipd / (4 * depth * (float)Math.Tan((Math.PI / 360) * DpnManager.DeviceInfo.fov_x)), viewport.y, viewport.width, viewport.height);
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 0, (int)dpncTwType.DISTORTION, new dpnRect(viewport));
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index + 1], 1, (int)dpncTwType.DISTORTION, new dpnRect(viewport));
            }
#endif

#if UNITY_ANDROID && (UNITY_5_5_0 || UNITY_5_4_3)
            // In Unity 5.5.0 and Unity 5.4.3,
            // surface is deleted and rebuilt after the first frame is completed by Unity, the second frame will be black screen.
            // So, Skip the rendering of the first frame to avoid flickering.
            StartCoroutine(Coroutine_EnableCamera());
#endif

            SetSrcBlendFactor(1);

            SetCommandBufferEnabled(true);

#if UNITY_ANDROID && !UNITY_EDITOR
            Camera.onPostRender += OnCameraPostRender;
#endif

            leftCamera.depth = depth;
            leftCamera.transform.localPosition = new Vector3(DpnManager.DeviceInfo.ipd * -0.5f, 0, 0);
            leftCamera.fieldOfView             = DpnManager.DeviceInfo.fov_y;

            rightCamera.depth = depth + 0.1f;
            rightCamera.transform.localPosition = new Vector3(DpnManager.DeviceInfo.ipd * 0.5f, 0, 0);
            rightCamera.fieldOfView             = DpnManager.DeviceInfo.fov_y;

            centerCamera.depth = depth + 0.2f;
            centerCamera.transform.localPosition = new Vector3(0, 0, 0);
            centerCamera.fieldOfView             = DpnManager.DeviceInfo.fov_y;

#if !UNITY_EDITOR
            centerCamera.enabled = false;
#endif

            Camera.onPreRender += OnCameraPreRender;
        }
Exemplo n.º 5
0
        void OnPostRender()
        {
            dpnRect view    = new dpnRect(new Rect(0, 0, _canvas_texture[index].width, _canvas_texture[index].height));
            IntPtr  tempPtr = Marshal.AllocHGlobal(Marshal.SizeOf(view));

            Marshal.StructureToPtr(view, tempPtr, false);
            Composer.PostRender(RENDER_EVENT.Posttransparent, (int)tempPtr);
            if (0.0f == depth)
            {
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 2, (int)dpncTwType.DISTORTION, new dpnRect(viewport));
            }
            else
            {
                Rect viewport_left  = new Rect(viewport.x + DpnManager.DeviceInfo.ipd / (4 * depth * (float)Math.Tan((Math.PI / 360) * DpnManager.DeviceInfo.fov_x)), viewport.y, viewport.width, viewport.height);
                Rect viewport_right = new Rect(viewport.x - DpnManager.DeviceInfo.ipd / (4 * depth * (float)Math.Tan((Math.PI / 360) * DpnManager.DeviceInfo.fov_x)), viewport.y, viewport.width, viewport.height);
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 0, (int)dpncTwType.DISTORTION, new dpnRect(viewport_left));
                Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 1, (int)dpncTwType.DISTORTION, new dpnRect(viewport_right));
            }
        }