-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhtre.bt
123 lines (100 loc) · 3.26 KB
/
htre.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "common/common.bt"
#include "common/gr_terrain_common.bt"
typedef struct
{
local uint flags = parentof(this).Flags;
local string name = ReadFoxDataString(parentof(this).Name);
local uint dataSize = parentof(this).DataSize;
// In V3 files, the file structure is completely mangled. It starts with editParam, which has a sane NextNodeOffset and a ChildOffset that points all the way to the end at configrationIds.
// But very node between editParam and configrationIds (lodParameter, maxHeight, minHeight, materialIds) have sane Next/PreviousNodeOffsets *and* all have ParentNodeOffsets that point to editParam.
// It's not clear if we should consider every node as flat or that configrationIds, lodParameter, maxHeight, minHeight, materialIds are all childs of editParam in a list that goes backwards.
// Only one can actually be true, this version has both. Not clear in which way the Fox bug lies.
// The size/sizeof(type)s are hacks. The actual file uses the LayoutDescription struct.
switch (name)
{
case "heightMap":
Assert(Header.Version == 3 ? (flags == 0) : (flags == 0));
// Hack. In V3 files, both the weightMap and heightMap are named "heightMap"
if (GetFoxDataNodeParamIndex(parentof(this), "pitch") > -1)
{
struct
{
float data[dataSize / sizeof(float)];
} HeightMap <bgcolor=0x99aacc>;
}
else
{
Assert(Header.Version == 3);
struct
{
Pixel data[dataSize / sizeof(Pixel)];
} WeightMap <bgcolor=0x111199>;
}
break;
case "comboTexture":
Assert(Header.Version == 4 && flags == 1);
struct
{
Pixel data[dataSize / sizeof(Pixel)];
} ComboTexture <bgcolor=0x111199>;
break;
case "editParam":
Assert(Header.Version == 3 ? (flags == 0) : (flags == 3));
break;
case "lodParameter":
Assert(Header.Version == 3 ? (flags == 0) : (flags == 2));
struct
{
} LodParameter <bgcolor=0x00aaff>;
break;
case "maxHeight":
Assert(Header.Version == 3 ? (flags == 0) : (flags == 4));
struct
{
float data[dataSize / sizeof(float)];
} MaxHeight <bgcolor=0xff00aa>;
break;
case "minHeight":
Assert(Header.Version == 3 ? (flags == 0) : (flags == 3));
struct
{
float data[dataSize / sizeof(float)];
} MinHeight <bgcolor=0xaaff00>;
break;
case "materialIds":
Assert(Header.Version == 3 ? (flags == 0) : (flags == 5));
struct
{
Pixel data[dataSize / sizeof(Pixel)];
} MaterialIds <bgcolor=0x991111>;
break;
case "configrationIds":
Assert(Header.Version == 3 ? (flags == 0) : (flags == 6));
struct
{
uint data[dataSize / sizeof(uint)];
} ConfigrationIds <bgcolor=0x119911>;
break;
case "patchDescription":
Assert(Header.Version == 4 && flags == 9);
struct
{
uint64 UnknownA;
uint64 UnknownB;
uint HeightFormat; Assert(HeightFormat == 1); // Very likely a third copy of heightFormat but I can't confirm that.
uint CommonDescriptionOffset <hidden = true>;
FSeek(startof(this) + 0x14 + CommonDescriptionOffset);
TerrainCommonDescription CommonDescription;
FAlign(16);
} PatchDescription <bgcolor=0x999900>;
break;
default:
Assert(false, "Unknown node");
}
} HTRE;
#define FOX_DATA_PAYLOAD HTRE
#include "common/FoxData_common.bt"
FoxDataHeader Header;
Assert(Header.Version == 3 || Header.Version == 4);
FSeek(Header.NodesOffset);
FoxDataNodes Nodes;