Skip to content

Commit

Permalink
Viewport: Fix non-drag WSAD, add EQ up down strafe
Browse files Browse the repository at this point in the history
  • Loading branch information
CallumDev committed Dec 15, 2018
1 parent 005ece3 commit 11a411d
Showing 1 changed file with 40 additions and 24 deletions.
64 changes: 40 additions & 24 deletions src/Editor/LancerEdit/Viewport3D.cs
Expand Up @@ -122,40 +122,56 @@ public void End(bool view = true)
if (io.KeyCtrl)
{
//CTRL + RMB - Rotate Model
Rotation += (delta / 100) * new Vector2(1,-1);
Rotation += (delta / 100) * new Vector2(1, -1);
}
else
{
//RMB - Rotate viewport camera
CameraRotation += (delta / 100) * new Vector2(1,-1);
var rotmat = Matrix4.CreateRotationX(CameraRotation.Y) *
Matrix4.CreateRotationY(CameraRotation.X);
if (mw.Keyboard.IsKeyDown(Keys.W))
{
var z = rotmat.Transform(-Vector3.UnitZ);
CameraOffset += z * (float)mw.TimeStep * ModelScale;
}
else if (mw.Keyboard.IsKeyDown(Keys.S))
{
var z = rotmat.Transform(Vector3.UnitZ);
CameraOffset += z * (float)mw.TimeStep * ModelScale;
}
if (mw.Keyboard.IsKeyDown(Keys.A))
{
var x = rotmat.Transform(Vector3.UnitX);
CameraOffset += x * (float)mw.TimeStep * ModelScale;
}
else if (mw.Keyboard.IsKeyDown(Keys.D))
{
var x = rotmat.Transform(-Vector3.UnitX);
CameraOffset += x * (float)mw.TimeStep * ModelScale;
}
CameraRotation += (delta / 100) * new Vector2(1, -1);
KeyboardControls();
}
}
else if (io.MouseDown[1])
KeyboardControls();
}
}
}

void KeyboardControls()
{
var rotmat = Matrix4.CreateRotationX(CameraRotation.Y) *
Matrix4.CreateRotationY(CameraRotation.X);
if (mw.Keyboard.IsKeyDown(Keys.W))
{
var z = rotmat.Transform(-Vector3.UnitZ);
CameraOffset += z * (float)mw.TimeStep * ModelScale;
}
else if (mw.Keyboard.IsKeyDown(Keys.S))
{
var z = rotmat.Transform(Vector3.UnitZ);
CameraOffset += z * (float)mw.TimeStep * ModelScale;
}
if (mw.Keyboard.IsKeyDown(Keys.A))
{
var x = rotmat.Transform(Vector3.UnitX);
CameraOffset += x * (float)mw.TimeStep * ModelScale;
}
else if (mw.Keyboard.IsKeyDown(Keys.D))
{
var x = rotmat.Transform(-Vector3.UnitX);
CameraOffset += x * (float)mw.TimeStep * ModelScale;
}
if (mw.Keyboard.IsKeyDown(Keys.E))
{
var y = rotmat.Transform(Vector3.UnitY);
CameraOffset += y * (float)mw.TimeStep * ModelScale;
}
else if (mw.Keyboard.IsKeyDown(Keys.Q))
{
var y = rotmat.Transform(-Vector3.UnitY);
CameraOffset += y * (float)mw.TimeStep * ModelScale;
}
}
public void Dispose()
{
if(RenderTarget != null) {
Expand Down

0 comments on commit 11a411d

Please sign in to comment.