Skip to content

Commit 2b51524

Browse files
committed
support DAT 3D model files of other type (used by the game "Creation")
1 parent 21a85c8 commit 2b51524

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

ObjectsConverter/ObjectDatFile.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private static ObjectDatFile loadFromFile(string filename, ObjectDatFile file)
4646
return file;
4747
}
4848

49+
bool isAnimation = false;
4950
byte[] bytes = File.ReadAllBytes(filename);
5051

5152
#region validate header
@@ -131,12 +132,13 @@ private static ObjectDatFile loadFromFile(string filename, ObjectDatFile file)
131132
#endregion
132133

133134
#region 2 constants (05 and 01, same in all object files)
134-
file.Error = "Constant 1 did not match!";
135-
if (bytes[offset] != 5) return file;
135+
file.Error = "Constant 1 is " + bytes[offset] + ", not 5 or 7!";
136+
if (bytes[offset] != 5 && bytes[offset] != 7) return file;
137+
if (bytes[offset] == 7) isAnimation = true;
136138
offset++;
137139

138-
file.Error = "Constant 2 did not match!";
139-
if (bytes[offset] != 1) return file;
140+
file.Error = "Constant 2 is " + bytes[offset] + ", not 1, 4 or 20!";
141+
if (bytes[offset] != 1 && bytes[offset] != 4 && bytes[offset] != 20) return file;
140142
offset++;
141143
#endregion
142144

@@ -172,6 +174,15 @@ private static ObjectDatFile loadFromFile(string filename, ObjectDatFile file)
172174
for(int i = 0; i < numTriangles; i++)
173175
{
174176
byte type = bytes[offset];
177+
178+
// Animations have some zeros before actual triangle data.
179+
// I couldn't find a regularity in the number of bytes used.
180+
while (isAnimation && type == 0)
181+
{
182+
offset++;
183+
type = bytes[offset];
184+
}
185+
175186
if (type != 5 && type != 4)
176187
{
177188
file.Error = "Triangle #" + (i+1) + "has unknown type " + type;

0 commit comments

Comments
 (0)