Cutscene viewer using znear/zfar when animating camera

This commit is contained in:
dexy 2019-11-28 16:36:32 +11:00
parent 9ba2e288ed
commit ac4d1a4b19
2 changed files with 37 additions and 1 deletions

View File

@ -61,6 +61,11 @@ namespace CodeWalker.World
WorldForm.SetCameraTransform(pos, rot);
if (Cutscene.CameraClipUpdate)
{
WorldForm.SetCameraClipPlanes(Cutscene.CameraNearClip, Cutscene.CameraFarClip);
Cutscene.CameraClipUpdate = false;
}
}
}
@ -254,6 +259,18 @@ namespace CodeWalker.World
private void AnimateCameraCheckBox_CheckedChanged(object sender, EventArgs e)
{
AnimateCamera = AnimateCameraCheckBox.Checked;
if (!AnimateCamera)
{
WorldForm?.ResetCameraClipPlanes();
}
else
{
if (Cutscene != null)
{
Cutscene.CameraClipUpdate = true;
}
}
}
private void PlayStopButton_Click(object sender, EventArgs e)
@ -316,7 +333,9 @@ namespace CodeWalker.World
public CutsceneObject CameraObject = null;
public float CameraNearClip { get; set; } = 0.5f;
public float CameraFarClip { get; set; } = 12000.0f;
public bool CameraClipUpdate = false;//signal to the form to update the camera clip planes
public Quaternion CameraRotationOffset = Quaternion.RotationAxis(Vector3.UnitX, -1.57079632679f) * Quaternion.RotationAxis(Vector3.UnitZ, 3.141592653f);
@ -962,6 +981,9 @@ namespace CodeWalker.World
obj.Position = pos + rot.Multiply(args.vPosition);
obj.Rotation = rot * args.vRotationQuaternion;
CameraNearClip = (args.fNearDrawDistance > 0) ? Math.Min(args.fNearDrawDistance, 0.5f) : 0.5f;
CameraFarClip = (args.fFarDrawDistance > 0) ? Math.Max(args.fFarDrawDistance, 1000.0f) : 12000.0f;
CameraClipUpdate = true;
CameraObject = obj;
}
private void CameraShadowCascade(CutEvent e)

View File

@ -1892,6 +1892,20 @@ namespace CodeWalker
camera.TargetRotation = Vector3.Zero;
camera.TargetDistance = 0.01f;
}
public void SetCameraClipPlanes(float znear, float zfar)
{
//sets the camera clip planes to the specified values, for use in eg cutscenes
camera.ZNear = znear;
camera.ZFar = zfar;
camera.UpdateProj = true;
}
public void ResetCameraClipPlanes()
{
//resets the camera clip planes to the values in the UI controls.
camera.ZNear = (float)NearClipUpDown.Value;
camera.ZFar = (float)FarClipUpDown.Value;
camera.UpdateProj = true;
}
public Vector3 GetCameraPosition()
{