Skip to content
This repository was archived by the owner on Jun 7, 2021. It is now read-only.

Commit 4477df2

Browse files
Known flags values implemented
1 parent 403f521 commit 4477df2

File tree

11 files changed

+170
-31
lines changed

11 files changed

+170
-31
lines changed
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
11
namespace FastMDX {
22
public struct CollisionShape : IDataRW {
33
public Node Node;
4-
public uint Type;
4+
public ShapeType Type;
55
public Vec3 Vertices1, Vertices2;
66
public float Radius;
77

88
void IDataRW.ReadFrom(DataStream ds) {
99
ds.ReadData(ref Node);
1010
ds.ReadStruct(ref Type);
1111

12-
if(Type > 3)
12+
if((uint)Type > 3)
1313
throw new ParsingException();
1414

1515
ds.ReadStruct(ref Vertices1);
1616

17-
if(Type != 2)
17+
if(Type != ShapeType.Sphere)
1818
ds.ReadStruct(ref Vertices2);
1919

20-
if(Type > 1)
20+
if((Type == ShapeType.Sphere) || (Type == ShapeType.Cylinder))
2121
ds.ReadStruct(ref Radius);
2222
}
2323

2424
void IDataRW.WriteTo(DataStream ds) {
25-
if(Type > 3)
26-
throw new ParsingException();
27-
2825
ds.WriteData(ref Node);
2926
ds.WriteStruct(Type);
3027
ds.WriteStruct(ref Vertices1);
3128

32-
if(Type != 2)
29+
if(Type != ShapeType.Sphere)
3330
ds.WriteStruct(ref Vertices2);
3431

35-
if(Type > 1)
32+
if((Type == ShapeType.Sphere) || (Type == ShapeType.Cylinder))
3633
ds.WriteStruct(Radius);
3734
}
35+
36+
public enum ShapeType : uint {
37+
Box,
38+
Plane,
39+
Sphere,
40+
Cylinder,
41+
}
3842
}
3943
}

FastMDX/src/Objects/Geoset.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ namespace FastMDX {
55

66
public struct Geoset : IDataRW {
77
public Vec3[] VertexPositions, VertexNormals;
8-
public uint[] FaceTypeGroups, FaceGroups, MatrixGroups, MatrixIndices;
8+
public FaceTypeGroup[] FaceTypeGroups;
9+
public uint[] FaceGroups, MatrixGroups, MatrixIndices;
910
public ushort[] Faces;
1011
public byte[] VertexGroups;
1112
public LocalProperties Properties;
@@ -22,7 +23,7 @@ void IDataRW.ReadFrom(DataStream ds) {
2223
VertexNormals = ds.ReadStructArray<Vec3>();
2324

2425
ds.CheckTag(PTYP);
25-
FaceTypeGroups = ds.ReadStructArray<uint>();
26+
FaceTypeGroups = ds.ReadStructArray<FaceTypeGroup>();
2627

2728
ds.CheckTag(PCNT);
2829
FaceGroups = ds.ReadStructArray<uint>();
@@ -88,8 +89,27 @@ void IDataRW.WriteTo(DataStream ds) {
8889
[StructLayout(LayoutKind.Sequential, Pack = 1)]
8990
public struct LocalProperties {
9091
public int MaterialId;
91-
public uint SelectionGroup, SelectionFlags;
92+
public uint SelectionGroup;
93+
public SelectionType SelectionType;
9294
public Extent Extent;
9395
}
96+
97+
public enum FaceTypeGroup : uint {
98+
Points,
99+
Lines,
100+
LineLoop,
101+
LineStrip,
102+
Triangles,
103+
TriangleStrip,
104+
TriangleFan,
105+
Quads,
106+
QuadStrip,
107+
Polygons,
108+
}
109+
110+
public enum SelectionType : uint {
111+
None,
112+
Unselectable = 4,
113+
}
94114
}
95115
}

FastMDX/src/Objects/GeosetAnimation.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
23

34
namespace FastMDX {
45
using static OptionalBlocks;
@@ -31,9 +32,16 @@ void IDataRW.WriteTo(DataStream ds) {
3132
[StructLayout(LayoutKind.Sequential, Pack = 1)]
3233
public struct LocalProperties {
3334
public float Alpha;
34-
public uint Flags;
35+
public Flags Flags;
3536
public Color Color;
3637
public int GeosetId;
3738
}
39+
40+
[Flags]
41+
public enum Flags : uint {
42+
None = 0x0,
43+
DropShadow = 0x1,
44+
Color = 0x2,
45+
}
3846
}
3947
}

FastMDX/src/Objects/Layer.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
23

34
namespace FastMDX {
45
using static OptionalBlocks;
@@ -30,9 +31,30 @@ void IDataRW.WriteTo(DataStream ds) {
3031

3132
[StructLayout(LayoutKind.Sequential, Pack = 1)]
3233
public struct LocalProperties {
33-
public uint FilterMode, ShadingFlags;
34+
public FilterMode FilterMode;
35+
public ShadingFlags ShadingFlags;
3436
public int TextureId, TextureAnimationId, CoordId;
3537
public float Alpha;
3638
}
39+
40+
public enum FilterMode : uint {
41+
None,
42+
Transparent,
43+
Blend,
44+
Additive,
45+
AddAlpha,
46+
Modulate,
47+
Modulate2x,
48+
}
49+
50+
[Flags]
51+
public enum ShadingFlags : uint {
52+
Unshaded = 0x1,
53+
SphereEnvironmentMap = 0x2,
54+
TwoSided = 0x10,
55+
Unfogged = 0x20,
56+
NoDepthTest = 0x40,
57+
NoDepthSet = 0x80,
58+
}
3759
}
3860
}

FastMDX/src/Objects/Light.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,18 @@ void IDataRW.WriteTo(DataStream ds) {
3939

4040
[StructLayout(LayoutKind.Sequential, Pack = 1)]
4141
public struct LocalProperties {
42-
public uint Type;
42+
public Type Type;
4343
public float AttenuationStart, AttenuationEnd;
4444
public Color Color;
4545
public float Intensity;
4646
public Color AmbientColor;
4747
public float AmbientIntensity;
4848
}
49+
50+
public enum Type : uint {
51+
Omni,
52+
Directional,
53+
Ambient,
54+
}
4955
}
5056
}

FastMDX/src/Objects/Material.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
23

34
namespace FastMDX {
45
using static InnerBlocks;
@@ -26,7 +27,16 @@ void IDataRW.WriteTo(DataStream ds) {
2627

2728
[StructLayout(LayoutKind.Sequential, Pack = 1)]
2829
public struct LocalProperties {
29-
public uint PriorityPlane, Flags;
30+
public uint PriorityPlane;
31+
public Flags Flags;
32+
}
33+
34+
[Flags]
35+
public enum Flags : uint {
36+
None = 0x0,
37+
ConstantColor = 0x1,
38+
SortPrimitivesFarZ = 0x10,
39+
FullResolution = 0x20,
3040
}
3141
}
3242
}

FastMDX/src/Objects/Node.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
23

34
namespace FastMDX {
45
using static OptionalBlocks;
@@ -35,7 +36,7 @@ public struct LocalProperties {
3536

3637
fixed byte name[(int)NAME_LEN];
3738
public int ObjectId, ParentId;
38-
public uint Flags;
39+
public Flags Flags;
3940

4041
public string Name {
4142
get {
@@ -48,5 +49,31 @@ public string Name {
4849
}
4950
}
5051
}
52+
53+
[Flags]
54+
public enum Flags : uint {
55+
Helper = 0x0,
56+
DontInheritTranslation = 0x1,
57+
DontInheritRotation = 0x2,
58+
DontInheritScaling = 0x4,
59+
Billboarded = 0x8,
60+
BillboardedLockX = 0x10,
61+
BillboardedLockY = 0x20,
62+
BillboardedLockZ = 0x40,
63+
CameraAnchored = 0x80,
64+
Bone = 0x100,
65+
Light = 0x200,
66+
EventObject = 0x400,
67+
Attachment = 0x800,
68+
ParticleEmitter = 0x1000,
69+
CollisionShape = 0x2000,
70+
RibbonEmitter = 0x4000,
71+
PEUsesMdlPE2Unshaded = 0x8000,
72+
PEUsesTgaPE2SortPrimitivesFarZ = 0x10000,
73+
LineEmitter = 0x20000,
74+
Unfogged = 0x40000,
75+
ModelSpace = 0x80000,
76+
XYQuad = 0x100000,
77+
}
5178
}
5279
}

FastMDX/src/Objects/ParticleEmitter2.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ void IDataRW.WriteTo(DataStream ds) {
3939
[StructLayout(LayoutKind.Sequential, Pack = 1)]
4040
public struct LocalProperties {
4141
public float Speed, Variation, Latitude, Gravity, Lifespan, EmissionRate, Length, Width;
42-
public uint FilterMode, Rows, Columns, Flag;
42+
public FilterMode FilterMode;
43+
public uint Rows, Columns;
44+
public HeadTailType HeadTailType;
4345
public float TailLength, Time;
4446
public SegmentColor SegmentColor;
4547
public SegmentAlpha SegmentAlpha;
4648
public Vec3 SegmentScaling;
4749
public Interval HeadInterval, HeadDecayInterval, TailInterval, TailDecayInterval;
4850
public int TextureId;
49-
public uint Squirt, PriorityPlane;
51+
public Squirt Squirt;
52+
public uint PriorityPlane;
5053
public int ReplaceableId;
5154
}
5255

@@ -64,5 +67,24 @@ public struct SegmentAlpha {
6467
public struct Interval {
6568
public uint Start, End, Repeat;
6669
}
70+
71+
public enum FilterMode : uint {
72+
Blend,
73+
Additive,
74+
Modulate,
75+
Modulate2x,
76+
AddAlpha,
77+
}
78+
79+
public enum HeadTailType : uint {
80+
Head,
81+
Tail,
82+
Both,
83+
}
84+
85+
public enum Squirt : uint {
86+
NoSquirt,
87+
Squirt,
88+
}
6789
}
6890
}

FastMDX/src/Objects/Sequence.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public unsafe struct Sequence {
88
fixed byte name[(int)NAME_LEN];
99
public uint IntervalStart, IntervalEnd;
1010
public float MoveSpeed;
11-
public uint Flags;
11+
public LoopType Type;
1212
public float Rarity;
1313
public uint SyncPoint;
1414
public Extent Extent;
@@ -23,5 +23,10 @@ public string Name {
2323
BinaryString.Encode(value, n, NAME_LEN);
2424
}
2525
}
26+
27+
public enum LoopType : uint {
28+
Looping,
29+
NonLooping,
30+
}
2631
}
2732
}

FastMDX/src/Objects/Texture.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
23

34
namespace FastMDX {
45
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -7,7 +8,7 @@ public unsafe struct Texture {
78

89
public int ReplaceableId;
910
fixed byte name[(int)NAME_LEN];
10-
public uint Flags;
11+
public WrapFlags Flags;
1112

1213
public string Name {
1314
get {
@@ -19,5 +20,12 @@ public string Name {
1920
BinaryString.Encode(value, n, NAME_LEN);
2021
}
2122
}
23+
24+
[Flags]
25+
public enum WrapFlags : uint {
26+
None = 0x0,
27+
WrapWidth = 0x1,
28+
WrapHeight = 0x2,
29+
}
2230
}
2331
}

0 commit comments

Comments
 (0)