private void GetPathNodeStateInfo(float timeInClip, float clipDuration, Path path, int nodeIndex, out CinematicCameraState cameraState, out Quaternion rotationToPath, out Vector3 forwardDir, out Vector3 upDir)
            {
                // (TO DO: cache components)
                CinematicCameraShot shot = path._nodes[nodeIndex]._node.GetComponent <CinematicCameraShot>();

                if (shot != null)
                {
                    cameraState = shot.GetState(timeInClip, clipDuration);

                    PathPosition nodePos = path.GetPoint(path.GetPathT(path._nodes[nodeIndex]._node));
                    rotationToPath = Quaternion.FromToRotation(nodePos._pathForward, shot.transform.forward);
                    forwardDir     = shot.transform.forward;
                    upDir          = shot.transform.up;
                }
                else
                {
                    cameraState    = default;
                    rotationToPath = Quaternion.identity;
                    forwardDir     = Vector3.forward;
                    upDir          = Vector3.up;
                }
            }
Beispiel #2
0
                private void RenderGamePreview(Event evnt)
                {
                    CinematicCamera previewCamera = (CinematicCamera)_previewCameraProperty.objectReferenceValue;

                    if (_preview && previewCamera != null)
                    {
                        CinematicCameraShot shot = (CinematicCameraShot)target;

                        float clipPosition = CinematicCameraMixer.GetClipPosition(shot._previewClipExtrapolation, _previewClipTime, shot._previewClipDuration);
                        previewCamera.SetState(shot.GetState(clipPosition));

                        Rect sceneViewRect = Camera.current.pixelRect;

                        //IF double pixel rendering!!
                        sceneViewRect.width  /= 2;
                        sceneViewRect.height /= 2;

                        int viewWidth  = (int)sceneViewRect.width;
                        int viewHeight = (int)sceneViewRect.height;

                        //If at this height the width is to big, need to make height less
                        if (Mathf.FloorToInt(viewHeight * kAspectRatio) > viewWidth)
                        {
                            viewHeight = (int)(sceneViewRect.width * (1f / kAspectRatio));
                        }
                        //If at this height the height is to big, need to make width less
                        if (Mathf.FloorToInt(viewWidth * (1f / kAspectRatio)) > viewHeight)
                        {
                            viewWidth = (int)(sceneViewRect.height * kAspectRatio);
                        }

                        if (_targetTexture == null || viewWidth != _targetTexture.width || viewHeight != _targetTexture.height)
                        {
                            if (_targetTexture == null)
                            {
                                _targetTexture = new RenderTexture(viewWidth, viewHeight, 16, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
                            }
                            else
                            {
                                _targetTexture.Release();
                            }

                            _targetTexture.width        = viewWidth;
                            _targetTexture.height       = viewHeight;
                            _targetTexture.antiAliasing = 1;
                            _targetTexture.Create();
                        }

                        if (_targetTexture.IsCreated())
                        {
                            //Render scene - need better way of grabbing post fx
                            RenderTexture active = RenderTexture.active;
                            RenderTexture.active = _targetTexture;
                            GL.Clear(true, true, Color.clear);
                            RenderTexture.active = active;

                            RenderCameras();

                            //Render on screen
                            GUI.BeginGroup(sceneViewRect);

                            //Clear screen to black
                            Color guiColor = GUI.color;
                            GUI.color = Color.black;
                            GUI.DrawTexture(sceneViewRect, EditorUtils.OnePixelTexture);
                            GUI.color = guiColor;

                            //Render game texture to screen
                            Rect viewRect = new Rect
                            {
                                width  = viewWidth,
                                height = viewHeight
                            };
                            viewRect.x = (sceneViewRect.width - viewRect.width) * 0.5f;
                            viewRect.y = (sceneViewRect.height - viewRect.height) * 0.5f;
                            GUI.DrawTexture(GetFlippedRect(viewRect), _targetTexture, ScaleMode.StretchToFill, false);

                            GUI.EndGroup();
                        }
                    }
                }
Beispiel #3
0
 public CinematicCameraState GetState()
 {
     return(_shot.GetState(GetClipPosition(_extrapolation, _time, _duration)));
 }
 public CinematicCameraState GetState()
 {
     return(_shot.GetState(_time));
 }