Skip to content

Commit a5ff181

Browse files
committed
Add parameters to define center of gravity dimensions individually
1 parent 41382f2 commit a5ff181

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

Source/Documentation/Manual/features-rollingstock.rst

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,18 +444,38 @@ stock with standard buffers/couplers on each end. Automatic sizing generally can
444444
for articulated rolling stock. And should something go wrong with the shape file causing automatic sizing to fail,
445445
OR will revert to the values entered in the ``Size`` parameter.
446446

447-
Automatic wagon centering
448-
-------------------------
447+
Improved wagon alignment tools
448+
------------------------------
449449

450-
Many MSTS and OR creators have encountered rolling stock shapes that were not correctly centered,
450+
Many MSTS and OR creators have encountered rolling stock shapes that were not correctly aligned,
451451
resulting in couplers/buffers clipping at one end of the wagon and separating at the other end.
452452
Normally, this would require inspecting the 3D model to determine exactly how off-center it was
453453
and carefully setting the Z value of ``CentreOfGravity ( x, y, z )`` to re-center the model.
454454

455+
.. index::
456+
single: ORTSCentreOfGravity_X
457+
single: ORTSCentreOfGravity_Y
458+
single: ORTSCentreOfGravity_Z
459+
460+
In some cases, this approach could still be insufficient as the Z offset is limited to 2 meters in
461+
order to prevent unusual behaviors with some MSTS models that used unreasonably large Z offsets.
462+
To facilitate models that need large offsets without introducing errors, OR now has parameters
463+
to define the CoG dimensions individually without any artifical limits added afterward.
464+
To set the horizontal, vertical, and lengthwise CoG offset ``ORTSCentreOfGravity_X``, ``ORTSCentreOfGravity_Y``,
465+
and ``ORTSCentreOfGravity_Z`` respectively can be entered in the Wagon section of an engine or wagon.
466+
467+
If placed later in the file than the original ``CentreOfGravity`` parameter, the data entered in the X/Y/Z
468+
parameters will overwrite the original data, but only for the specific X/Y/Z component provided. For
469+
example, if ``ORTSCentreOfGravity_Z ( -1m )`` is placed after ``CentreOfGravity ( 0m 2.5m 0.5m )`` the
470+
resulting CoG offset will actually be 0m, 2.5m, -1m, overwriting the original 0.5m Z offset while
471+
leaving the X and Y components unchanged.
472+
455473
.. index::
456474
single: ORTSAutoCenter
457475

458-
To make this easier, OR now includes the ``ORTSAutoCenter`` parameter. When ``ORTSAutoCenter ( 1 )``
476+
However, in many cases it is desireable to simply center the 3D model lengthwise such that the
477+
couplers/buffers are equidistant from the centerpoint of the model. To make this specific case
478+
easier, OR now includes the ``ORTSAutoCenter`` parameter. When ``ORTSAutoCenter ( 1 )``
459479
is included in the Wagon section of an engine or wagon, OR will inspect the main shape file used by
460480
the wagon to determine the exact Z value of CentreOfGravity required to re-center the shape in the
461481
simulation. This will overwrite the manually entered Z component of ``CentreOfGravity`` but will

Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,12 @@ public virtual void Parse(string lowercasetoken, STFReader stf)
13471347
}
13481348
stf.SkipRestOfBlock();
13491349
break;
1350+
case "wagon(ortscenterofgravity_x":
1351+
case "wagon(ortscentreofgravity_x": InitialCentreOfGravityM.X = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); break;
1352+
case "wagon(ortscenterofgravity_y":
1353+
case "wagon(ortscentreofgravity_y": InitialCentreOfGravityM.Y = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); break;
1354+
case "wagon(ortscenterofgravity_z":
1355+
case "wagon(ortscentreofgravity_z": InitialCentreOfGravityM.Z = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); break;
13501356
case "wagon(ortsautocentre":
13511357
case "wagon(ortsautocenter": AutoCenter = stf.ReadBoolBlock(false); break;
13521358
case "wagon(ortsunbalancedsuperelevation": MaxUnbalancedSuperElevationM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); break;

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/FreightAnimations.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public FreightAnimations(STFReader stf, MSTSWagon wagon)
109109
new STFReader.TokenProcessor("emptymaxbrakeforce", ()=>{ EmptyMaxBrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
110110
new STFReader.TokenProcessor("emptymaxbrakeshoeforce", ()=>{ EmptyMaxBrakeShoeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
111111
new STFReader.TokenProcessor("emptymaxhandbrakeforce", ()=>{ EmptyMaxHandbrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
112+
new STFReader.TokenProcessor("emptycenterofgravity_y", ()=>{ EmptyCentreOfGravityM_Y = stf.ReadFloatBlock(STFReader.UNITS.Distance, -1); }),
112113
new STFReader.TokenProcessor("emptycentreofgravity_y", ()=>{ EmptyCentreOfGravityM_Y = stf.ReadFloatBlock(STFReader.UNITS.Distance, -1); }),
113114
new STFReader.TokenProcessor("emptybrakerelayvalveratio", ()=>{ EmptyRelayValveRatio = stf.ReadFloatBlock(STFReader.UNITS.None, -1); }),
114115
new STFReader.TokenProcessor("emptybrakerelayvalveinshot", ()=>{ EmptyInshotPSI = stf.ReadFloatBlock(STFReader.UNITS.PressureDefaultPSI, -1); }),
@@ -1021,6 +1022,7 @@ public FreightAnimationContinuous(STFReader stf, MSTSWagon wagon)
10211022
new STFReader.TokenProcessor("fullmaxbrakeforce", ()=>{ FullMaxBrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
10221023
new STFReader.TokenProcessor("fullmaxbrakeshoeforce", ()=>{ FullMaxBrakeShoeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
10231024
new STFReader.TokenProcessor("fullmaxhandbrakeforce", ()=>{ FullMaxHandbrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
1025+
new STFReader.TokenProcessor("fullcenterofgravity_y", ()=>{ FullCentreOfGravityM_Y = stf.ReadFloatBlock(STFReader.UNITS.Distance, -1); }),
10241026
new STFReader.TokenProcessor("fullcentreofgravity_y", ()=>{ FullCentreOfGravityM_Y = stf.ReadFloatBlock(STFReader.UNITS.Distance, -1); }),
10251027
new STFReader.TokenProcessor("fullbrakerelayvalveratio", ()=>{ FullRelayValveRatio = stf.ReadFloatBlock(STFReader.UNITS.None, -1); }),
10261028
new STFReader.TokenProcessor("fullbrakerelayvalveinshot", ()=>{ FullInshotPSI = stf.ReadFloatBlock(STFReader.UNITS.PressureDefaultPSI, -1); })
@@ -1147,6 +1149,7 @@ public FreightAnimationStatic(STFReader stf)
11471149
new STFReader.TokenProcessor("fullmaxbrakeforce", ()=>{ FullStaticMaxBrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
11481150
new STFReader.TokenProcessor("fullmaxbrakeshoeforce", ()=>{ FullStaticMaxBrakeShoeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
11491151
new STFReader.TokenProcessor("fullmaxhandbrakeforce", ()=>{ FullStaticMaxHandbrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
1152+
new STFReader.TokenProcessor("fullcenterofgravity_y", ()=>{ FullStaticCentreOfGravityM_Y = stf.ReadFloatBlock(STFReader.UNITS.Distance, -1); }),
11501153
new STFReader.TokenProcessor("fullcentreofgravity_y", ()=>{ FullStaticCentreOfGravityM_Y = stf.ReadFloatBlock(STFReader.UNITS.Distance, -1); }),
11511154
new STFReader.TokenProcessor("fullbrakerelayvalveratio", ()=>{ FullStaticRelayValveRatio = stf.ReadFloatBlock(STFReader.UNITS.None, -1); }),
11521155
new STFReader.TokenProcessor("fullbrakerelayvalveinshot", ()=>{ FullStaticInshotPSI = stf.ReadFloatBlock(STFReader.UNITS.PressureDefaultPSI, -1); })

0 commit comments

Comments
 (0)