Skip to content

Commit 146b772

Browse files
committed
Automatic merge of T1.5.1-757-gef6c1a8c8 and 16 pull requests
- Pull request #570 at 3539862: 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 #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 #882 at a055bca: Blueprint/train car operations UI window - Pull request #885 at 74466d9: feat: Add notifications to Menu - Pull request #886 at 1b88d7a: Scene viewer extension to TrackViewer - Pull request #888 at b20b888: docs: Document player application model - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #893 at bf8876b: Signal errors - Pull request #894 at 5ff1e73: 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 0a9d939: feat: Improved system information collection - Pull request #898 at e271395: Extra line with all the arguments for debugging purposes in logfile - Pull request #899 at 28638b2: Duplex steam engines - Booster Engine addition
18 parents 5c77bcc + ef6c1a8 + 3539862 + d00beb9 + f8dbeab + 43bf33e + f92de76 + a055bca + 74466d9 + 1b88d7a + b20b888 + 1f5ba4c + bf8876b + 5ff1e73 + 5866028 + 0a9d939 + e271395 + 28638b2 commit 146b772

File tree

3 files changed

+4
-125
lines changed

3 files changed

+4
-125
lines changed

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,7 +3263,6 @@ public class ThreeDimentionCabViewer : TrainCarViewer
32633263
//Dictionary<int, DigitalDisplay> DigitParts = null;
32643264
Dictionary<(CabViewControlType, int), ThreeDimCabDigit> DigitParts3D = null;
32653265
Dictionary<(CabViewControlType, int), ThreeDimCabDPI> DPIDisplays3D = null;
3266-
Dictionary<(CabViewControlType, int), ThreeDimCabScreen> ScreenDisplays3D = null;
32673266
AnimatedPart ExternalWipers = null; // setting to zero to prevent a warning. Probably this will be used later. TODO
32683267
protected MSTSLocomotive MSTSLocomotive { get { return (MSTSLocomotive)Car; } }
32693268
MSTSLocomotiveViewer LocoViewer;
@@ -3287,7 +3286,6 @@ public ThreeDimentionCabViewer(Viewer viewer, MSTSLocomotive car, MSTSLocomotive
32873286
DigitParts3D = new Dictionary<(CabViewControlType, int), ThreeDimCabDigit>();
32883287
Gauges = new Dictionary<(CabViewControlType, int), ThreeDimCabGaugeNative>();
32893288
DPIDisplays3D = new Dictionary<(CabViewControlType, int), ThreeDimCabDPI>();
3290-
ScreenDisplays3D = new Dictionary<(CabViewControlType, int), ThreeDimCabScreen>();
32913289
OnDemandAnimateParts = new Dictionary<(CabViewControlType, int), AnimatedPart>();
32923290

32933291
// Find the animated parts
@@ -3382,10 +3380,6 @@ public ThreeDimentionCabViewer(Viewer viewer, MSTSLocomotive car, MSTSLocomotive
33823380
{
33833381
DPIDisplays3D.Add(key, new ThreeDimCabDPI(viewer, iMatrix, parameter1, parameter2, this.TrainCarShape, locoViewer.ThreeDimentionCabRenderer.ControlMap[key]));
33843382
}
3385-
else if (style is CircularSpeedGaugeRenderer || style is DriverMachineInterfaceRenderer)
3386-
{
3387-
ScreenDisplays3D.Add(key, new ThreeDimCabScreen(viewer, iMatrix, TrainCarShape, locoViewer.ThreeDimentionCabRenderer.ControlMap[key]));
3388-
}
33893383
else
33903384
{
33913385
//if there is a part already, will insert this into it, otherwise, create a new
@@ -3538,24 +3532,6 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
35383532
p.Value.PrepareFrame(frame, elapsedTime);
35393533
}
35403534

3541-
foreach (var p in ScreenDisplays3D)
3542-
{
3543-
var dpdisplay = p.Value.CVFR.Control;
3544-
if (dpdisplay.Screens != null && dpdisplay.Screens[0] != "all")
3545-
{
3546-
foreach (var screen in dpdisplay.Screens)
3547-
{
3548-
if (LocoViewer.ThreeDimentionCabRenderer.ActiveScreen[dpdisplay.Display] == screen)
3549-
{
3550-
p.Value.PrepareFrame(frame, elapsedTime);
3551-
break;
3552-
}
3553-
}
3554-
continue;
3555-
}
3556-
p.Value.PrepareFrame(frame, elapsedTime);
3557-
}
3558-
35593535
foreach (var p in Gauges)
35603536
{
35613537
var gauge = p.Value.CVFR.Control;
@@ -3609,10 +3585,6 @@ internal override void Mark()
36093585
{
36103586
threeDimCabDPI.Mark();
36113587
}
3612-
foreach (var threeDimCabControl in ScreenDisplays3D.Values)
3613-
{
3614-
threeDimCabControl.Mark();
3615-
}
36163588
}
36173589
}
36183590

Source/RunActivity/Viewer3D/RollingStock/SubSystems/ETCS/DriverMachineInterface.cs

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,7 @@ public override void Draw(SpriteBatch spriteBatch, Point drawPosition)
754754

755755
public class CircularSpeedGaugeRenderer : CabViewDigitalRenderer
756756
{
757-
public DriverMachineInterface DMI;
758-
757+
DriverMachineInterface DMI;
759758
[CallOnThread("Loader")]
760759
public CircularSpeedGaugeRenderer(Viewer viewer, MSTSLocomotive locomotive, CVCDigital control, CabShader shader)
761760
: base(viewer, locomotive, control, shader)
@@ -865,79 +864,4 @@ public override void Draw(GraphicsDevice graphicsDevice)
865864
ControlView.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.Default, null, Shader);
866865
}
867866
}
868-
869-
public class ScreenMaterial : SceneryMaterial
870-
{
871-
CircularSpeedGaugeRenderer CircularSpeedGaugeRenderer;
872-
SpriteBatch SpriteBatch;
873-
874-
public ScreenMaterial(Viewer viewer, string key, CircularSpeedGaugeRenderer circularSpeedGaugeRenderer)
875-
: base(viewer, key, SceneryMaterialOptions.ShaderFullBright, 0)
876-
{
877-
CircularSpeedGaugeRenderer = circularSpeedGaugeRenderer;
878-
Texture = new RenderTarget2D(viewer.GraphicsDevice,
879-
CircularSpeedGaugeRenderer.DMI.Width, CircularSpeedGaugeRenderer.DMI.Height, false, SurfaceFormat.Color, DepthFormat.None);
880-
SpriteBatch = new SpriteBatch(viewer.GraphicsDevice);
881-
}
882-
883-
public override void Render(GraphicsDevice graphicsDevice, IEnumerable<RenderItem> renderItems, ref Matrix XNAViewMatrix, ref Matrix XNAProjectionMatrix)
884-
{
885-
var originalRenderTargets = graphicsDevice.GetRenderTargets();
886-
graphicsDevice.SetRenderTarget(Texture as RenderTarget2D);
887-
SpriteBatch.Begin(); // Dummy Begin(), gets closed immediately
888-
CircularSpeedGaugeRenderer.Draw(graphicsDevice);
889-
SpriteBatch.End();
890-
graphicsDevice.SetRenderTargets(originalRenderTargets);
891-
892-
base.Render(graphicsDevice, renderItems, ref XNAViewMatrix, ref XNAProjectionMatrix);
893-
}
894-
}
895-
896-
public class ThreeDimCabScreen
897-
{
898-
PoseableShape TrainCarShape;
899-
Matrix XNAMatrix;
900-
Viewer Viewer;
901-
ShapePrimitive ShapePrimitive;
902-
public CircularSpeedGaugeRenderer CVFR;
903-
ScreenMaterial Material;
904-
public ThreeDimCabScreen(Viewer viewer, int iMatrix, PoseableShape trainCarShape, CabViewControlRenderer c)
905-
{
906-
CVFR = (CircularSpeedGaugeRenderer)c;
907-
Viewer = viewer;
908-
TrainCarShape = trainCarShape;
909-
XNAMatrix = TrainCarShape.SharedShape.Matrices[iMatrix];
910-
Material = new ScreenMaterial(viewer, "ETCS_SCREEN", CVFR);
911-
912-
var vertices = new[]
913-
{
914-
new VertexPositionNormalTexture(new Vector3(0, 0, 0), new Vector3(0, 0, -1), new Vector2(0, 0)),
915-
new VertexPositionNormalTexture(new Vector3(0, 0, 1), new Vector3(0, 0, -1), new Vector2(0, 1)),
916-
new VertexPositionNormalTexture(new Vector3(1, 0, 0), new Vector3(0, 0, -1), new Vector2(1, 0)),
917-
new VertexPositionNormalTexture(new Vector3(1, 0, 1), new Vector3(0, 0, -1), new Vector2(1, 1)),
918-
};
919-
var indices = new short[] { 0, 1, 2, 2, 1, 3 };
920-
var indexBuffer = new IndexBuffer(viewer.GraphicsDevice, IndexElementSize.SixteenBits, indices.Length, BufferUsage.WriteOnly);
921-
indexBuffer.SetData(indices);
922-
ShapePrimitive = new ShapePrimitive(Material, new SharedShape.VertexBufferSet(vertices, viewer.GraphicsDevice), indexBuffer, 2, new[] { -1 }, 0);
923-
}
924-
925-
public void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
926-
{
927-
if (!CVFR.IsPowered && CVFR.Control.HideIfDisabled)
928-
return;
929-
930-
Matrix mx = TrainCarShape.Location.XNAMatrix;
931-
mx.M41 += (TrainCarShape.Location.TileX - Viewer.Camera.TileX) * 2048;
932-
mx.M43 += (-TrainCarShape.Location.TileZ + Viewer.Camera.TileZ) * 2048;
933-
Matrix m = XNAMatrix * mx;
934-
935-
frame.AddPrimitive(ShapePrimitive.Material, ShapePrimitive, RenderPrimitiveGroup.Interior, ref m, ShapeFlags.None);
936-
}
937-
938-
internal void Mark()
939-
{
940-
ShapePrimitive.Mark();
941-
}
942-
}
943867
}

Source/RunActivity/Viewer3D/RollingStock/SubSystems/ETCS/SpeedDistanceMonitoring.cs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class CircularSpeedGauge : DMIArea
5353
readonly Point ReleaseSpeedPosition = new Point(26 - 6, 274 - 8);
5454
readonly int[] UnitCenterPosition = new int[] { 140, 204 };
5555
// 240 and 260 are non-standard scales by ETA, but national railways often use one of these instead of 250
56-
readonly int[] StandardScalesKMpH = new int[] { 140, 180, 240, 250, 260, 280, 400 };
56+
readonly int[] StandardScalesKMpH = new int[] { 140, 180, 240, 250, 260, 400 };
5757
readonly int[] StandardScalesMpH = new int[] { 87, 111, 155, 248 };
5858

5959
const string UnitMetricString = "km/h";
@@ -222,38 +222,21 @@ public void SetRange(int maxSpeed)
222222
y -= textHeight / 2f * (1f - (float)Math.Cos(angle));
223223
// Cheating for better outlook:
224224
if (UnitMetric && 240 <= MaxSpeed && MaxSpeed <= 260)
225-
{
226225
switch (speed)
227226
{
228227
case 100: x -= textWidth / 4f; break;
229228
case 120: x -= textWidth / 10f; y -= textHeight / 6f; break;
230229
case 140: x += textWidth / 6f; y -= textHeight / 6f; break;
231230
}
232-
}
231+
233232
DialSpeeds.Add(new TextPrimitive(new Point((int)x, (int)y), Color.White, speed.ToString(), FontDialSpeeds));
234233
}
235234
}
236235
else
237-
{
238236
DialLineCoords.Add(new Vector4(x, y, LineHalf, angle + MathHelper.PiOver2));
239-
}
240-
241-
var longLineEach = 2;
242-
if (MaxSpeed == 280 && UnitMetric)
243-
{
244-
longLineEach = 4;
245-
}
246-
if (MaxSpeed > 300 && UnitMetric)
247-
{
248-
longLineEach = 5;
249-
}
250-
if (MaxSpeed > 200 && !UnitMetric)
251-
{
252-
longLineEach = (speed + 5 > MidSpeed) ? 4 : 2;
253-
}
254237

255238
longLine++;
256-
longLine %= longLineEach;
239+
longLine %= MaxSpeed != StandardScales[StandardScales.Length - 1] ? 2 : UnitMetric ? 5 : (speed + 5 > MidSpeed) ? 4 : 2;
257240
}
258241
else if (UnitMetric && (MaxSpeed == 240 || MaxSpeed == 260))
259242
{

0 commit comments

Comments
 (0)