Added camera movement option to Cube
parent
0898284506
commit
efac8a0108
|
@ -31,6 +31,7 @@ namespace MoonWorks.Test
|
||||||
private Quaternion cubeRotation = Quaternion.Identity;
|
private Quaternion cubeRotation = Quaternion.Identity;
|
||||||
private Quaternion previousCubeRotation = Quaternion.Identity;
|
private Quaternion previousCubeRotation = Quaternion.Identity;
|
||||||
private bool depthOnlyEnabled = false;
|
private bool depthOnlyEnabled = false;
|
||||||
|
private Vector3 camPos = new Vector3(0, 1.5f, 4f);
|
||||||
|
|
||||||
struct ViewProjectionUniforms
|
struct ViewProjectionUniforms
|
||||||
{
|
{
|
||||||
|
@ -330,7 +331,8 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
finishedLoading = true;
|
finishedLoading = true;
|
||||||
Logger.LogInfo("Finished loading!");
|
Logger.LogInfo("Finished loading!");
|
||||||
Logger.LogInfo("Press Down to toggle Depth-Only Mode");
|
Logger.LogInfo("Press Left to toggle Depth-Only Mode");
|
||||||
|
Logger.LogInfo("Press Down to move the camera upwards");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
|
@ -345,7 +347,16 @@ namespace MoonWorks.Test
|
||||||
cubeTimer * 2f
|
cubeTimer * 2f
|
||||||
);
|
);
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Bottom))
|
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Bottom))
|
||||||
|
{
|
||||||
|
camPos.Y = System.MathF.Min(camPos.Y + 0.2f, 15f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
camPos.Y = System.MathF.Max(camPos.Y - 0.4f, 1.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
||||||
{
|
{
|
||||||
depthOnlyEnabled = !depthOnlyEnabled;
|
depthOnlyEnabled = !depthOnlyEnabled;
|
||||||
Logger.LogInfo("Depth-Only Mode enabled: " + depthOnlyEnabled);
|
Logger.LogInfo("Depth-Only Mode enabled: " + depthOnlyEnabled);
|
||||||
|
@ -361,7 +372,7 @@ namespace MoonWorks.Test
|
||||||
depthUniforms.ZFar
|
depthUniforms.ZFar
|
||||||
);
|
);
|
||||||
Matrix4x4 view = Matrix4x4.CreateLookAt(
|
Matrix4x4 view = Matrix4x4.CreateLookAt(
|
||||||
new Vector3(0, 1.5f, 4f),
|
camPos,
|
||||||
Vector3.Zero,
|
Vector3.Zero,
|
||||||
Vector3.Up
|
Vector3.Up
|
||||||
);
|
);
|
||||||
|
|
|
@ -94,5 +94,37 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool CheckButtonDown(Input.Inputs inputs, ButtonType buttonType)
|
||||||
|
{
|
||||||
|
bool down = false;
|
||||||
|
|
||||||
|
if (buttonType == ButtonType.Left)
|
||||||
|
{
|
||||||
|
down = (
|
||||||
|
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadLeft.IsDown) ||
|
||||||
|
inputs.Keyboard.IsDown(Input.KeyCode.A) ||
|
||||||
|
inputs.Keyboard.IsDown(Input.KeyCode.Left)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (buttonType == ButtonType.Bottom)
|
||||||
|
{
|
||||||
|
down = (
|
||||||
|
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadDown.IsDown) ||
|
||||||
|
inputs.Keyboard.IsDown(Input.KeyCode.S) ||
|
||||||
|
inputs.Keyboard.IsDown(Input.KeyCode.Down)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (buttonType == ButtonType.Right)
|
||||||
|
{
|
||||||
|
down = (
|
||||||
|
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadRight.IsDown) ||
|
||||||
|
inputs.Keyboard.IsDown(Input.KeyCode.D) ||
|
||||||
|
inputs.Keyboard.IsDown(Input.KeyCode.Right)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return down;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue