public override void OnLogicFinished(StateMachineComponent stateMachine) { CinematicCameraMixer camera = _camera.GetComponent(); CinematicCameraShot cameraShot = _shot.GetComponent(); if (camera != null && cameraShot != null) { camera.StopCameraShot(cameraShot); } }
public override void OnLogicStarted(StateMachineComponent stateMachine) { CinematicCameraMixer camera = _camera.GetComponent(); CinematicCameraShot cameraShot = _shot.GetComponent(); if (camera != null && cameraShot != null) { camera.StartCameraShot(cameraShot, _duration, _extrapolation, _blendTime, _blendEaseType); } }
public void End(StateMachineComponent stateMachine) { CinematicCameraMixer camera = _camera.GetComponent(); CinematicCameraShot cameraShot = _shot.GetComponent(); if (camera != null && cameraShot != null) { camera.StopCameraShot(cameraShot); } }
private void HandleMouseDrag(Event evnt) { if (InFreeCamMode()) { CinematicCameraShot cameraShot = (CinematicCameraShot)target; Vector3 eulerAngles = cameraShot.transform.eulerAngles; eulerAngles += new Vector3(evnt.delta.y / Camera.current.pixelRect.height, evnt.delta.x / Camera.current.pixelRect.width, 0.0f) * kMouseLookSpeed; cameraShot.transform.eulerAngles = eulerAngles; } Event.current.Use(); }
public eEventTriggerReturn Trigger(StateMachineComponent stateMachine) { CinematicCameraMixer camera = _camera.GetComponent(); CinematicCameraShot cameraShot = _shot.GetComponent(); if (camera != null && cameraShot != null) { camera.StartCameraShot(cameraShot, _duration, _extrapolation, _blendTime, _blendEaseType); } return(eEventTriggerReturn.EventOngoing); }
private static void UpdateKeys() { _previewClipTime += Time.deltaTime; if (InFreeCamMode()) { Vector3 movement = Vector3.zero; bool held = false; if (_buttonPressed.TryGetValue(KeyCode.A, out held) && held) { movement.x -= 1.0f; } if (_buttonPressed.TryGetValue(KeyCode.D, out held) && held) { movement.x += 1.0f; } if (_buttonPressed.TryGetValue(KeyCode.W, out held) && held) { movement.z += 1.0f; } if (_buttonPressed.TryGetValue(KeyCode.S, out held) && held) { movement.z -= 1.0f; } if (_buttonPressed.TryGetValue(KeyCode.R, out held) && held) { movement.y += 1.0f; } if (_buttonPressed.TryGetValue(KeyCode.F, out held) && held) { movement.y -= 1.0f; } CinematicCameraShot cameraShot = (CinematicCameraShot)_previewShot.target; float speed = kMovementSpeed; if (_buttonPressed.TryGetValue(KeyCode.Space, out held) && held) { speed = kFastMovementSpeed; } cameraShot.transform.Translate(movement * speed, Space.Self); } }
public void StartCameraShot(CinematicCameraShot shot, Extrapolation extrapolation, float blendTime = -1.0f, InterpolationType blendType = InterpolationType.InOutCubic) { if (blendTime <= 0.0f) { _currentShot._weight = 1.0f; _blendingShots = new ShotInfo[0]; } else if (_currentShot._shot != null) { ArrayUtils.Add(ref _blendingShots, _currentShot); _currentShot._weight = 0.0f; _currentShot._blendType = blendType; _currentShotBlendSpeed = 1.0f / blendTime; } _currentShot._shot = shot; _currentShot._extrapolation = extrapolation; _currentShot._time = 0.0f; }
public void StopCameraShot(CinematicCameraShot shot, float blendTime = -1.0f, InterpolationType blendType = InterpolationType.Linear) { if (_currentShot._shot != null && _currentShot._shot == shot) { if (blendTime <= 0.0f) { _currentShot._weight = 1.0f; _blendingShots = new ShotInfo[0]; } else { ArrayUtils.Add(ref _blendingShots, _currentShot); _currentShot._weight = 0.0f; _currentShot._blendType = blendType; _currentShotBlendSpeed = 1.0f / blendTime; } _currentShot = new ShotInfo(); } }
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; } }
protected bool IsBeingPreviewed() { return(CinematicCameraShot.IsPreviewing()); }
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(); } } }