Skip to content

Commit d663400

Browse files
committed
Remove shape descriptor changes from this branch
1 parent d252ea4 commit d663400

File tree

15 files changed

+75
-383
lines changed

15 files changed

+75
-383
lines changed

Source/Documentation/Manual/features-rollingstock.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,6 @@ Here below a sample of a ``.load-or`` file::
10611061
{
10621062
"Name" : "triton",
10631063
"Shape" : "COMMON_Container_3d\\Cont_40ftHC\\container-40ftHC_Triton.s",
1064-
"ShapeDescriptor" : "COMMON_Container_3d\\Cont_40ftHC\\container-40ftHC_Triton.sd",
10651064
"ContainerType" : "C40ftHC",
10661065
"IntrinsicShapeOffset": [0,1.175,0],
10671066
"EmptyMassKG": 2100.,
@@ -1073,9 +1072,6 @@ Here below a sample of a ``.load-or`` file::
10731072
- "Name" has as value a string used by Open Rails when the container must be indentified in a message
10741073
to the player.
10751074
- "Shape" has as value the path of the container shape (.s) file, having ``Trainset`` as base.
1076-
- "ShapeDescriptor" has the path of the container shape descriptor (.sd) file,
1077-
having ``Trainset`` as base. This is optional; if missing OR assumes the shape
1078-
descriptor is in the same location with the same name as the shape file.
10791075
- "ContainerType" identifies the container type, which may be one of the following ones::
10801076

10811077
* C20ft

Source/Orts.Formats.Msts/ShapeDescriptorFile.cs

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
using System;
1919
using System.Collections.Generic;
20-
using Microsoft.Xna.Framework;
2120
using Orts.Parsers.Msts;
2221

2322
namespace Orts.Formats.Msts
@@ -70,7 +69,7 @@ public SDShape()
7069

7170
public SDShape(STFReader stf)
7271
{
73-
stf.ReadString();
72+
stf.ReadString(); // Ignore the filename string. TODO: Check if it agrees with the SD file name? Is this important?
7473
stf.ParseBlock(new STFReader.TokenProcessor[] {
7574
new STFReader.TokenProcessor("esd_detail_level", ()=>{ ESD_Detail_Level = stf.ReadIntBlock(null); }),
7675
new STFReader.TokenProcessor("esd_alternative_texture", ()=>{ ESD_Alternative_Texture = stf.ReadIntBlock(null); }),
@@ -85,22 +84,9 @@ public SDShape(STFReader stf)
8584
new STFReader.TokenProcessor("esd_ortssoundfilename", ()=>{ ESD_SoundFileName = stf.ReadStringBlock(null); }),
8685
new STFReader.TokenProcessor("esd_ortsbellanimationfps", ()=>{ ESD_CustomAnimationFPS = stf.ReadFloatBlock(STFReader.UNITS.Frequency, null); }),
8786
new STFReader.TokenProcessor("esd_ortscustomanimationfps", ()=>{ ESD_CustomAnimationFPS = stf.ReadFloatBlock(STFReader.UNITS.Frequency, null); }),
88-
new STFReader.TokenProcessor("esd_ortstexturereplacement", ()=>{ ParseReplacementStrings(stf, ref ESD_TextureReplacement); }),
89-
new STFReader.TokenProcessor("esd_ortsmatrixrename", ()=>{ ParseReplacementStrings(stf, ref ESD_MatrixRename); }),
90-
new STFReader.TokenProcessor("esd_ortsmatrixtranslation", ()=>{ ParseMatrixOverride(STFReader.UNITS.Distance, stf, ref ESD_MatrixTranslation); }),
91-
new STFReader.TokenProcessor("esd_ortsmatrixscale", ()=>{ ParseMatrixOverride(STFReader.UNITS.None, stf, ref ESD_MatrixScale); }),
92-
new STFReader.TokenProcessor("esd_ortsmatrixrotation", ()=>{ ParseMatrixOverride(STFReader.UNITS.Angle, stf, ref ESD_MatrixRotation); }),
9387
});
94-
95-
// Store set of all matrices that got modified
96-
foreach (string mat in ESD_MatrixRename.Keys)
97-
ESD_ModifiedMatrices.Add(mat);
98-
foreach (string mat in ESD_MatrixTranslation.Keys)
99-
ESD_ModifiedMatrices.Add(mat);
100-
foreach (string mat in ESD_MatrixScale.Keys)
101-
ESD_ModifiedMatrices.Add(mat);
102-
foreach (string mat in ESD_MatrixRotation.Keys)
103-
ESD_ModifiedMatrices.Add(mat);
88+
// TODO - some objects have no bounding box - ie JP2BillboardTree1.sd
89+
//if (ESD_Bounding_Box == null) throw new STFException(stf, "Missing ESD_Bound_Box statement");
10490
}
10591
public int ESD_Detail_Level;
10692
public int ESD_Alternative_Texture;
@@ -110,46 +96,6 @@ public SDShape(STFReader stf)
11096
public bool ESD_SubObj;
11197
public string ESD_SoundFileName = "";
11298
public float ESD_CustomAnimationFPS = 8;
113-
// Dictionary of <original texture name, replacement texture name>
114-
public Dictionary<string, string> ESD_TextureReplacement = new Dictionary<string, string>();
115-
// Dictionary of <original matrix name, replacement matrix name>
116-
public Dictionary<string, string> ESD_MatrixRename = new Dictionary<string, string>();
117-
// Set of matrix names that are modified in some way or another
118-
public HashSet<string> ESD_ModifiedMatrices = new HashSet<string>();
119-
// Dictionary of <matrix name, matrix translation x/y/z vector>
120-
public Dictionary<string, Vector3> ESD_MatrixTranslation = new Dictionary<string, Vector3>();
121-
// Dictionary of <matrix name, matrix scale x/y/z vector>
122-
public Dictionary<string, Vector3> ESD_MatrixScale = new Dictionary<string, Vector3>();
123-
// Dictionary of <matrix name, matrix rotation x/y/z vector>
124-
public Dictionary<string, Vector3> ESD_MatrixRotation = new Dictionary<string, Vector3>();
125-
126-
// Handle parameters concerning replacement of string values
127-
protected void ParseReplacementStrings(STFReader stf, ref Dictionary<string, string> renamePairs)
128-
{
129-
stf.MustMatch("(");
130-
// Allow for multiple pairs of replaced and replacement values
131-
while (!stf.EndOfBlock())
132-
{
133-
string replaced = stf.ReadString();
134-
string replacement = stf.ReadString();
135-
// Add pair of values so long as we haven't reached the end of block
136-
if (replaced != ")" && replacement != ")")
137-
renamePairs.Add(replaced, replacement);
138-
}
139-
}
140-
141-
// Handle matrix adjustment parameters
142-
protected void ParseMatrixOverride(STFReader.UNITS units, STFReader stf, ref Dictionary<string, Vector3> matrixParams)
143-
{
144-
Vector3 data = new Vector3(0);
145-
146-
stf.MustMatch("(");
147-
string matName = stf.ReadString();
148-
data = stf.ReadVector3(units, Vector3.Zero);
149-
stf.SkipRestOfBlock();
150-
151-
matrixParams.Add(matName, data);
152-
}
15399
}
154100

155101
public class ESD_Bounding_Box

Source/Orts.Formats.OR/ContainerFile.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public class ContainerParameters
6363
{
6464
public string Name;
6565
public string ShapeFileName;
66-
public string ShapeDescriptor;
6766
public string ContainerType;
6867
public Vector3 IntrinsicShapeOffset = new Vector3(0f, 1.17f, 0f);
6968
public float EmptyMassKG = -1;
@@ -79,12 +78,7 @@ bool TryParse(JsonReader item)
7978
switch (item.Path)
8079
{
8180
case "Name": Name = item.AsString(""); break;
82-
case "Shape":
83-
ShapeFileName = item.AsString(ShapeFileName);
84-
if (string.IsNullOrEmpty(ShapeDescriptor))
85-
ShapeDescriptor = ShapeFileName + "d";
86-
break;
87-
case "ShapeDescriptor": ShapeDescriptor = item.AsString(ShapeDescriptor); break;
81+
case "Shape": ShapeFileName = item.AsString(ShapeFileName); break;
8882
case "ContainerType": ContainerType = item.AsString("40ftHC"); break;
8983
case "IntrinsicShapeOffset[]": IntrinsicShapeOffset = item.AsVector3(Vector3.Zero); break;
9084
case "EmptyMassKG": EmptyMassKG = item.AsFloat(-1); break;

Source/Orts.Simulation/Simulation/Container.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public enum Status
6464

6565
public string Name;
6666
public string ShapeFileName;
67-
public string ShapeDescriptor;
6867
public string BaseShapeFileFolderSlash;
6968
public float MassKG = 2000;
7069
public float EmptyMassKG;
@@ -116,7 +115,6 @@ public virtual void Copy(Container containerCopy)
116115
Name = containerCopy.Name;
117116
BaseShapeFileFolderSlash = containerCopy.BaseShapeFileFolderSlash;
118117
ShapeFileName = containerCopy.ShapeFileName;
119-
ShapeDescriptor = containerCopy.ShapeDescriptor;
120118
IntrinsicShapeOffset = containerCopy.IntrinsicShapeOffset;
121119
ContainerType = containerCopy.ContainerType;
122120
ComputeDimensions();
@@ -133,7 +131,6 @@ public Container(BinaryReader inf, FreightAnimationDiscrete freightAnimDiscrete,
133131
Name = inf.ReadString();
134132
BaseShapeFileFolderSlash = inf.ReadString();
135133
ShapeFileName = inf.ReadString();
136-
ShapeDescriptor = inf.ReadString();
137134
LoadFilePath = inf.ReadString();
138135
IntrinsicShapeOffset.X = inf.ReadSingle();
139136
IntrinsicShapeOffset.Y = inf.ReadSingle();
@@ -234,7 +231,6 @@ public void Save(BinaryWriter outf, bool fromContainerStation = false)
234231
outf.Write(Name);
235232
outf.Write(BaseShapeFileFolderSlash);
236233
outf.Write(ShapeFileName);
237-
outf.Write(ShapeDescriptor);
238234
outf.Write(LoadFilePath);
239235
outf.Write(IntrinsicShapeOffset.X);
240236
outf.Write(IntrinsicShapeOffset.Y);
@@ -259,7 +255,6 @@ public void LoadFromContainerFile(string loadFilePath, string baseFolder)
259255
Name = containerParameters.Name;
260256

261257
ShapeFileName = @"..\" + containerParameters.ShapeFileName;
262-
ShapeDescriptor = @"..\" + containerParameters.ShapeDescriptor;
263258
var workingString = containerParameters.ShapeFileName.Replace(@"\" , @"/");
264259
var root = workingString.Substring(0, workingString.IndexOf(@"/"));
265260
BaseShapeFileFolderSlash = baseFolder + root + @"\";

Source/Orts.Simulation/Simulation/RollingStocks/Coupling/AnimatedAirHose.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,5 @@ public struct AnimatedAirHose
3232
public struct AnimatedAirHoseState
3333
{
3434
public string ShapeFileName;
35-
public string ShapeDescriptor;
3635
}
3736
}

Source/Orts.Simulation/Simulation/RollingStocks/Coupling/AnimatedCoupler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ public struct AnimatedCoupler
3030
public struct AnimatedCouplerState
3131
{
3232
public string ShapeFileName;
33-
public string ShapeDescriptor;
3433
}
3534
}

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -841,33 +841,33 @@ protected CabView BuildCabView(string wagFilePath, string cvfFileName)
841841
|| (viewPointList[0].StartDirection.Y <= -90 && viewPointList[0].StartDirection.Y >= -270)) ? CabViewType.Rear : CabViewType.Front;
842842
var wag = this as MSTSWagon;
843843
var wagFolderSlash = Path.GetDirectoryName(wag.WagFilePath) + @"\";
844-
string shapeDescriptorPath;
844+
string shapeFilePath;
845845
bool boundingLimitsFound = false;
846-
ShapeDescriptorFile shapeDescriptorFile = new ShapeDescriptorFile();
847-
if (wag.FreightShapeDescriptor != null)
846+
ShapeDescriptorFile shapeFile = new ShapeDescriptorFile();
847+
if (wag.FreightShapeFileName != null)
848848
{
849-
shapeDescriptorPath = wagFolderSlash + wag.FreightShapeDescriptor;
850-
if (shapeDescriptorPath != null && File.Exists(shapeDescriptorPath))
849+
shapeFilePath = wagFolderSlash + wag.FreightShapeFileName;
850+
if (shapeFilePath != null && File.Exists(shapeFilePath + "d"))
851851
{
852-
shapeDescriptorFile = new ShapeDescriptorFile(shapeDescriptorPath);
853-
if (shapeDescriptorFile.shape.ESD_Bounding_Box != null) boundingLimitsFound = true;
852+
shapeFile = new ShapeDescriptorFile(shapeFilePath + "d");
853+
if (shapeFile.shape.ESD_Bounding_Box != null) boundingLimitsFound = true;
854854
}
855855
}
856856
if (!boundingLimitsFound)
857857
{
858-
shapeDescriptorPath = wagFolderSlash + wag.MainShapeDescriptor;
859-
if (shapeDescriptorPath != null && File.Exists(shapeDescriptorPath))
858+
shapeFilePath = wagFolderSlash + wag.MainShapeFileName;
859+
if (shapeFilePath != null && File.Exists(shapeFilePath + "d"))
860860
{
861-
shapeDescriptorFile = new ShapeDescriptorFile(shapeDescriptorPath);
862-
if (shapeDescriptorFile.shape.ESD_Bounding_Box != null) boundingLimitsFound = true;
861+
shapeFile = new ShapeDescriptorFile(shapeFilePath + "d");
862+
if (shapeFile.shape.ESD_Bounding_Box != null) boundingLimitsFound = true;
863863
}
864864
}
865865
if (boundingLimitsFound)
866866
{
867867
if (cabViewType == CabViewType.Front)
868-
noseAhead = (viewPointList[0].Location.Z + 0.5f < shapeDescriptorFile.shape.ESD_Bounding_Box.Max.Z) ? true : false;
868+
noseAhead = (viewPointList[0].Location.Z + 0.5f < shapeFile.shape.ESD_Bounding_Box.Max.Z) ? true : false;
869869
else if (cabViewType == CabViewType.Rear)
870-
noseAhead = (viewPointList[0].Location.Z - 0.5f > shapeDescriptorFile.shape.ESD_Bounding_Box.Min.Z) ? true : false;
870+
noseAhead = (viewPointList[0].Location.Z - 0.5f > shapeFile.shape.ESD_Bounding_Box.Min.Z) ? true : false;
871871
}
872872
if (!(this is MSTSSteamLocomotive))
873873
{
@@ -886,7 +886,6 @@ protected CabView3D BuildCab3DView()
886886

887887
var cab3dBasePath = Path.Combine(Path.GetDirectoryName(WagFilePath), "CABVIEW3D");
888888
var shapeFilePath = Path.Combine(cab3dBasePath, Cab3DShapeFileName);
889-
var shapeDescriptorPath = Path.Combine(cab3dBasePath, Cab3DShapeDescriptor);
890889
if (!File.Exists(shapeFilePath))
891890
return null;
892891

@@ -914,7 +913,7 @@ protected CabView3D BuildCab3DView()
914913
if (CabViewpoints.Count == 1 && cabViewType == CabViewType.Rear)
915914
CabViewpoints.Insert(0, new PassengerViewPoint());
916915

917-
return new CabView3D(cvfFile, CabViewpoints, extendedCVF, cabViewType, noseAhead, shapeFilePath, shapeDescriptorPath);
916+
return new CabView3D(cvfFile, CabViewpoints, extendedCVF, cabViewType, noseAhead, shapeFilePath);
918917
}
919918

920919
/// <summary>
@@ -6323,13 +6322,11 @@ public CabView(CabViewFile cvfFile, List<ViewPoint> viewPointList, ExtendedCVF e
63236322
public class CabView3D : CabView
63246323
{
63256324
public string ShapeFilePath;
6326-
public string ShapeDescriptorPath;
63276325

6328-
public CabView3D(CabViewFile cvfFile, List<PassengerViewPoint> cabViewpoints, ExtendedCVF extendedCVF, CabViewType cabViewType, bool noseAhead, string shapeFilePath, string shapeDescriptorPath)
6326+
public CabView3D(CabViewFile cvfFile, List<PassengerViewPoint> cabViewpoints, ExtendedCVF extendedCVF, CabViewType cabViewType, bool noseAhead, string shapeFilePath)
63296327
: base(cvfFile, new List<ViewPoint>(), extendedCVF, cabViewType, noseAhead)
63306328
{
63316329
ShapeFilePath = shapeFilePath;
6332-
ShapeDescriptorPath = shapeDescriptorPath;
63336330
if (cabViewpoints != null)
63346331
foreach (var point in cabViewpoints)
63356332
ViewPointList.Add(point);

0 commit comments

Comments
 (0)