Beispiel #1
0
        public RSViewport(RSScene scene)
        {
            Scene  = scene;
            Camera = new RSCamera();

            Scene.OnSceneImported += new SceneImportedCallback(OnSceneImport);
        }
Beispiel #2
0
        // Update is called once per frame
        void Update()
        {
            WaitToConnectCounter++;

            Quaternion rot = RenderCamera.transform.rotation;
            Vector3    pos = RenderCamera.transform.position;

            if (prevCameraPosition != pos || prevCameraRotation != rot)
            {
                prevCameraPosition = pos;
                prevCameraRotation = rot;

                UpdateCamera();

                if (!Connected && WaitToConnectCounter > 10)
                {
                    Connected = true;
                    Connect();
                }
            }

            DisplayNav = !Input.GetMouseButton(0);
            if (Viewport != null && RenderCamera != null && Scene.Ready)
            {
                Viewport.UpdateResolution(Screen.width, Screen.height);

                RSCamera cam = Viewport.Camera;
                cam.FieldOfView      = RenderCamera.fieldOfView;
                cam.Orthographic     = RenderCamera.orthographic;
                cam.OrthographicSize = RenderCamera.orthographicSize;

                if (Viewport.RenderLoopRunning && cam.HasNewChanges)
                {
                    DisplayRender = false;
                    Viewport.RestartLoop();
                }
            }

            if (RenderTarget != null)
            {
                bool  display = DisplayRender && DisplayNav;
                Color colour  = RenderTarget.guiTexture.color;
                float alpha   = colour.a;
                if (display && alpha < 0.5f)
                {
                    alpha += (Time.deltaTime / 0.25f) * 0.5f;
                }
                else if (!display && alpha > 0.0f)
                {
                    alpha -= (Time.deltaTime / 0.25f) * 0.5f;
                }
                colour.a = Mathf.Clamp(alpha, 0.0f, 0.5f);
                RenderTarget.guiTexture.color = colour;
            }
        }
Beispiel #3
0
        // Update is called once per frame
        void Update()
        {
            Viewport.Update(Time.deltaTime);

            WaitToConnectCounter++;

            Quaternion rot = RenderCamera.transform.rotation;
            Vector3    pos = RenderCamera.transform.position;

            if (prevCameraPosition != pos || prevCameraRotation != rot)
            {
                prevCameraPosition = pos;
                prevCameraRotation = rot;

                UpdateCamera();

                if (!Connected && WaitToConnectCounter > 10)
                {
                    Connected = true;
                    Connect();
                }
            }

            DisplayNav = !Input.GetMouseButton(0);

            if (Viewport != null)
            {
                RSCamera cam        = Viewport.Camera;
                bool     hasChanges = cam.HasNewChanges;

                if (hasChanges && Service != null)
                {
                    Service.InvalidateRenderRequests();
                }

                if (RenderCamera != null && Scene.Ready)
                {
                    Viewport.UpdateResolution(Screen.width, Screen.height);

                    cam.FieldOfView      = RenderCamera.fieldOfView;
                    cam.Orthographic     = RenderCamera.orthographic;
                    cam.OrthographicSize = RenderCamera.orthographicSize;

                    if (Viewport.RenderLoopRunning && hasChanges)
                    {
                        DisplayRender = false;
                        Viewport.RestartLoop();
                    }
                }
            }

            if (RenderTarget != null)
            {
                bool  display = DisplayRender && DisplayNav;
                float alpha   = RenderTarget.GetComponent <CanvasGroup>().alpha;
                if (display && alpha < 1.0f)
                {
                    alpha += (Time.deltaTime / 0.25f) * 0.5f;
                }
                else if (!display && alpha > 0.0f)
                {
                    alpha -= (Time.deltaTime / 0.25f) * 0.5f;
                }
                alpha = Mathf.Clamp(alpha, 0.0f, 1.0f);
                RenderTarget.GetComponent <CanvasGroup>().alpha = alpha;
            }
        }