Skip to content

Commit 52c3c82

Browse files
committed
Camera behavior changes
1 parent fabfc5a commit 52c3c82

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

Source/ORTS.Common/Input/UserCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,5 +251,7 @@ public enum UserCommand
251251

252252
// Editor
253253
[GetString("Editor Unselect All")] EditorUnselectAll,
254+
[GetString("Editor Undo")] EditorUndo,
255+
[GetString("Editor Redo")] EditorRedo,
254256
}
255257
}

Source/ORTS.Settings/InputSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ static void InitializeCommands(UserCommandInput[] Commands)
538538
Commands[(int)UserCommand.GameUncoupleWithMouse] = new UserCommandKeyInput(0x16);
539539

540540
Commands[(int)UserCommand.EditorUnselectAll] = new UserCommandKeyInput(0x01);
541+
Commands[(int)UserCommand.EditorUndo] = new UserCommandKeyInput(Keys.Z, KeyModifiers.Control); // Not assigning by scan code, because on German influenced keyboard layounts
542+
Commands[(int)UserCommand.EditorRedo] = new UserCommandKeyInput(Keys.Y, KeyModifiers.Control); // the Y and Z keys are exchanged, and we want these to match the o/s
541543
}
542544
#endregion
543545

Source/RunActivity/Viewer3D/Cameras.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,11 @@ public override void HandleUserInput(ElapsedTime elapsedTime)
820820

821821
public override void ZoomByMouseWheel(float speed)
822822
{
823-
ZoomIn(speed * UserInput.MouseWheelChange * ZoomFactor);
823+
// Zoom/move towards the mouse cursor instead of the camera forward
824+
var movement = speed * -UserInput.MouseWheelChange * ZoomFactor * Vector3.Normalize(Viewer.NearPoint - Viewer.FarPoint);
825+
movement.Z *= -1;
826+
cameraLocation.Location += movement;
827+
cameraLocation.Normalize();
824828
}
825829

826830
public override void RotateByMouse()
@@ -831,8 +835,9 @@ public override void RotateByMouse()
831835
var deltaAngleX = MathHelper.WrapAngle(RotationXRadians - StoredAngleX);
832836
var deltaAngleY = MathHelper.WrapAngle(RotationYRadians - StoredAngleY);
833837

834-
var dax = StoredForward.Z * deltaAngleX;
835-
var daz = StoredForward.X * deltaAngleX;
838+
var dax = Vector3.Dot(StoredForward, Vector3.UnitZ) * deltaAngleX;
839+
var daz = Vector3.Dot(StoredForward, Vector3.UnitX) * deltaAngleX;
840+
836841
var transform = Matrix.CreateRotationX(dax);
837842
transform *= Matrix.CreateRotationZ(daz);
838843
transform *= Matrix.CreateRotationY(-deltaAngleY);
@@ -846,7 +851,7 @@ public override void RotateByMouse()
846851
cameraLocation = newWorldLocation;
847852
}
848853

849-
public void StoreRotationOrigin(Vector3 rotationOrigin)
854+
void StoreRotationOrigin(Vector3 rotationOrigin)
850855
{
851856
StoredOrigin = Viewer.TerrainPoint;
852857
StoredLocation = CameraWorldLocation;
@@ -858,7 +863,9 @@ public void StoreRotationOrigin(Vector3 rotationOrigin)
858863
StoredForward = xnaView.Forward;
859864
}
860865

861-
public void SetOrientation(float rotationXRadians, float rotationYRadians)
866+
public float GetRotationX() { return RotationXRadians; }
867+
public float GetRotationY() { return RotationYRadians; }
868+
public void SetRotation(float rotationXRadians, float rotationYRadians)
862869
{
863870
RotationXRadians = rotationXRadians;
864871
RotationYRadians = rotationYRadians;

Source/RunActivity/Viewer3D/EditorPrimitives.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ public MouseCrosshair(Viewer viewer, Color color)
176176
{
177177
new VertexPositionColor(new Vector3(-5, 0, 0), color),
178178
new VertexPositionColor(new Vector3(5, 0, 0), color),
179-
new VertexPositionColor(new Vector3(0, 0, -5), color),
180-
new VertexPositionColor(new Vector3(0, 0, 5), color),
179+
new VertexPositionColor(new Vector3(0, 0, -5), Color.Red),
180+
new VertexPositionColor(new Vector3(0, 0, 5), Color.Cyan),
181181
new VertexPositionColor(new Vector3(0, 0, 0), color),
182182
new VertexPositionColor(new Vector3(0, 20, 0), color)
183183
};

0 commit comments

Comments
 (0)