Skip to content

Commit 1e8a350

Browse files
committed
Automatic merge of T1.5.1-687-gd279e384a and 20 pull requests
- Pull request #570 at c59c788: Experimental glTF 2.0 support with PBR lighting - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #865 at 67014b7: Dispatcher window improvements - Pull request #874 at f8dbeab: Dynamic brake controller refactoring - Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #878 at f9aa2ad: Implement Polach Adhesion - Pull request #882 at d8a1c4d: Blueprint/train car operations UI window - Pull request #883 at edcc2dd: SwitchPanel disconnect/connect handling - Pull request #885 at c81447b: feat: Add notifications to Menu - Pull request #886 at 228f0f0: Scene viewer extension to TrackViewer - Pull request #887 at 4665bda: docs: Document projects, assemblies, namespaces - Pull request #888 at d7daf62: docs: Document player application model - Pull request #889 at 43341cf: No speed update - Pull request #890 at 39a9fa4: Allow depart early - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #893 at bf8876b: Signal errors - Pull request #894 at 794fddf: Correct Decrease Colour - Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains - Pull request #897 at 64a29c8: feat: Improved system information collection
22 parents ee861f3 + d279e38 + c59c788 + d00beb9 + 67014b7 + f8dbeab + 43bf33e + f92de76 + f9aa2ad + d8a1c4d + edcc2dd + c81447b + 228f0f0 + 4665bda + d7daf62 + 43341cf + 39a9fa4 + 1f5ba4c + bf8876b + 794fddf + 5866028 + 64a29c8 commit 1e8a350

File tree

5 files changed

+45
-53
lines changed

5 files changed

+45
-53
lines changed

Source/Contrib/TrackViewer/SceneViewer.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,36 +147,14 @@ public void Update(GameTime gameTime)
147147
{
148148
SelectedObjectChanged();
149149
}
150-
if (UserInput.IsMouseMiddleButtonPressed && UserInput.ModifiersMaskShiftCtrlAlt(false, false, false))
151-
{
152-
Camera.StoreRotationOrigin(Viewer.TerrainPoint);
153-
Viewer.EditorShapes.CrosshairPositionUpdateEnabled = false;
154-
}
155-
if (UserInput.IsMouseMiddleButtonDown && UserInput.ModifiersMaskShiftCtrlAlt(false, false, false))
156-
{
157-
Camera.RotateByMouse();
158-
}
159-
else
160-
{
161-
Viewer.EditorShapes.CrosshairPositionUpdateEnabled = true;
162-
}
163-
if (UserInput.IsMouseMiddleButtonDown && UserInput.ModifiersMaskShiftCtrlAlt(true, false, false))
164-
{
165-
Camera.PanByMouse();
166-
}
167-
else
168-
{
169-
Camera.ZoomByMouseWheel(1);
170-
}
171-
172150
if (UserInput.IsPressed(UserCommand.EditorUnselectAll))
173151
{
174152
SelectedObject = null;
175153
SelectedObjectChanged();
176154
}
177155

178-
SetCameraLocationStatus(TrackViewer.RenderProcess?.Viewer?.Camera?.CameraWorldLocation ?? new WorldLocation());
179-
//FillCursorPositionStatus(TrackViewer.RenderProcess?.Viewer?.TerrainPoint ?? new Vector3());
156+
SetCameraLocationStatus(Camera?.CameraWorldLocation ?? new WorldLocation());
157+
//FillCursorPositionStatus(Viewer?.TerrainPoint ?? new Vector3());
180158
}
181159

182160
public void EndDraw()

Source/Contrib/TrackViewer/TrackViewer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,14 @@ private void DrawLoadingMessage(string message)
324324
/// <param name="gameTime">Provides a snapshot of timing values.</param>
325325
protected override void Update(GameTime gameTime)
326326
{
327+
SceneViewer?.Update(gameTime);
328+
327329
if (!this.IsTrackViewerWindowActive)
328330
{
329331
lostFocus = true;
330332
if (this.IsRenderWindowActive)
331333
{
332334
base.Update(gameTime);
333-
SceneViewer?.Update(gameTime);
334335
}
335336
return;
336337
}
@@ -549,8 +550,6 @@ protected override void Update(GameTime gameTime)
549550
SetTitle();
550551

551552
RenderProcess.IsMouseVisible = true;
552-
553-
SceneViewer?.Update(gameTime);
554553
}
555554

556555
/// <summary>

Source/RunActivity/Viewer3D/Cameras.cs

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ public class ViewerCamera : FreeRoamCamera
806806
{
807807
Vector3 RotationOrigin;
808808
Vector3 RotationDirection;
809+
WorldLocation RotationLocation;
809810
float RotationRadius;
810811
float RotationReferenceAngleX;
811812
float RotationReferenceAngleY;
@@ -817,25 +818,38 @@ public ViewerCamera(Viewer viewer)
817818

818819
public override void HandleUserInput(ElapsedTime elapsedTime)
819820
{
820-
// The UserInput code goes to the consuming class according to the architecture,
821-
// this class is intentionally lacks calling the base(elapsedTime).
821+
if (UserInput.IsMouseMiddleButtonPressed && UserInput.ModifiersMaskShiftCtrlAlt(false, false, false))
822+
{
823+
StoreRotationOrigin(Viewer.TerrainPoint);
824+
Viewer.EditorShapes.CrosshairPositionUpdateEnabled = false;
825+
}
826+
if (UserInput.IsMouseMiddleButtonDown && UserInput.ModifiersMaskShiftCtrlAlt(false, false, false))
827+
{
828+
RotateByMouse();
829+
}
830+
else
831+
{
832+
Viewer.EditorShapes.CrosshairPositionUpdateEnabled = true;
833+
}
834+
if (UserInput.IsMouseMiddleButtonDown && UserInput.ModifiersMaskShiftCtrlAlt(true, false, false))
835+
{
836+
PanByMouse();
837+
}
838+
else
839+
{
840+
ZoomByMouseWheel(GetSpeed(elapsedTime));
841+
}
822842
}
823843

824844
public override void ZoomByMouseWheel(float speed)
825845
{
826-
// The UserInput code goes to the consuming class according to the architecture, only the functionality is implemented here
827-
828846
ZoomIn(speed * UserInput.MouseWheelChange * ZoomFactor);
829847
}
830848

831849
public override void RotateByMouse()
832850
{
833-
// The UserInput code goes to the consuming class according to the architecture, only the functionality is implemented here
834-
835-
RotationXRadians += GetMouseDelta(UserInput.MouseMoveY);
836-
RotationYRadians += GetMouseDelta(UserInput.MouseMoveX);
837-
RotationXRadians = MathHelper.WrapAngle(RotationXRadians);
838-
RotationYRadians = MathHelper.WrapAngle(RotationYRadians);
851+
RotationXRadians = MathHelper.WrapAngle(RotationXRadians + GetMouseDelta(UserInput.MouseMoveY));
852+
RotationYRadians = MathHelper.WrapAngle(RotationYRadians + GetMouseDelta(UserInput.MouseMoveX));
839853

840854
// Method 1
841855
//var deltaAngleX = MathHelper.WrapAngle(GetMouseDelta(UserInput.MouseMoveY));
@@ -852,27 +866,33 @@ public override void RotateByMouse()
852866
//var deltaAngleY = MathHelper.WrapAngle(RotationYRadians - RotationReferenceAngleY);
853867
//var transform = Matrix.CreateFromYawPitchRoll(-deltaAngleY, -deltaAngleX, 0);
854868
//var newLocation = RotationOrigin + RotationRadius * Vector3.Transform(RotationDirection, transform);
869+
870+
// Method 3
871+
//var deltaAngleX = MathHelper.WrapAngle(RotationXRadians);
872+
//var deltaAngleY = MathHelper.WrapAngle(RotationYRadians);
873+
//var transform = Matrix.CreateFromYawPitchRoll(-deltaAngleY, -deltaAngleX, 0);
874+
//var newLocation = RotationOrigin + RotationRadius * Vector3.Transform(Vector3.UnitZ, transform);
875+
855876
//newLocation.Z *= -1;
856-
//var newWorldLocation = CameraWorldLocation;
877+
//var newWorldLocation = RotationLocation;
857878
//newWorldLocation.Location = newLocation;
858879

859880
//SetLocation(newWorldLocation);
860881
}
861882

862883
public void StoreRotationOrigin(Vector3 rotationOrigin)
863884
{
864-
RotationOrigin = rotationOrigin;
885+
RotationOrigin = Viewer.TerrainPoint;
886+
RotationLocation = CameraWorldLocation;
865887
RotationDirection = XnaLocation(CameraWorldLocation) - RotationOrigin;
866888
RotationRadius = RotationDirection.Length();
867889
RotationDirection = Vector3.Normalize(RotationDirection);
868-
RotationReferenceAngleX = RotationXRadians;
869-
RotationReferenceAngleY = RotationYRadians;
890+
RotationReferenceAngleX = MathHelper.WrapAngle(RotationXRadians);
891+
RotationReferenceAngleY = MathHelper.WrapAngle(RotationYRadians);
870892
}
871893

872894
public void PanByMouse()
873895
{
874-
// The UserInput code goes to the consuming class according to the architecture, only the functionality is implemented here
875-
876896
var previousFarSource = new Vector3(UserInput.MouseX - UserInput.MouseMoveX, UserInput.MouseY - UserInput.MouseMoveY, 1);
877897
var previousFarPoint = Viewer.DefaultViewport.Unproject(previousFarSource, XnaProjection, XnaView, Matrix.Identity);
878898
var movement = Viewer.FarPoint - previousFarPoint;
@@ -891,8 +911,6 @@ public void PanByMouse()
891911

892912
public bool PickByMouse(out StaticShape pickedObjectOut)
893913
{
894-
// The UserInput code goes to the consuming class by the accepted architecture, only the functionality is implemented here
895-
896914
if (Viewer == null)
897915
{
898916
pickedObjectOut = null;

Source/RunActivity/Viewer3D/EditorPrimitives.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,8 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
8383
{
8484
CrosshairPosition = Viewer.TerrainPoint;
8585
}
86-
if (CrosshairPosition != Viewer.NearPoint)
87-
{
88-
var mouseCrosshairMatrix = Matrix.CreateTranslation(CrosshairPosition);
89-
frame.AddPrimitive(MouseCrosshair.Material, MouseCrosshair, RenderPrimitiveGroup.World, ref mouseCrosshairMatrix);
90-
}
86+
var mouseCrosshairMatrix = Matrix.CreateTranslation(CrosshairPosition);
87+
frame.AddPrimitive(MouseCrosshair.Material, MouseCrosshair, RenderPrimitiveGroup.World, ref mouseCrosshairMatrix);
9188
}
9289
}
9390

Source/RunActivity/Viewer3D/Viewer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,14 +930,14 @@ void HandleUserInput(ElapsedTime elapsedTime)
930930
TerrainPoint = EditorMode ? GetTerrainPoint() : NearPoint;
931931
}
932932

933-
if (EditorMode)
934-
return;
935-
936933
if (UserInput.IsPressed(UserCommand.CameraReset))
937934
Camera.Reset();
938935

939936
Camera?.HandleUserInput(elapsedTime);
940937

938+
if (EditorMode)
939+
return;
940+
941941
PlayerLocomotiveViewer?.HandleUserInput(elapsedTime);
942942
InfoDisplay?.HandleUserInput(elapsedTime);
943943
WindowManager?.HandleUserInput(elapsedTime);

0 commit comments

Comments
 (0)