-
Notifications
You must be signed in to change notification settings - Fork 1
/
blitz_psi.bt
126 lines (104 loc) · 2.2 KB
/
blitz_psi.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
124
125
126
// Blitz, PSI format
// Template created by Mark "hogsy" Sowden <markelswo@gmail.com>
struct RGB
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t padding;
};
struct
{
int32_t magic; // 'PSI\0'
int32_t version;// 1
int32_t flags;
char name[ 32 ];// typically seems to be blank...
int32_t numMeshes;
int32_t numVertices;
int32_t numPolygons;
int32_t polygonOffset;
uint16_t firstFrame;
uint16_t lastFrame;
int32_t numSegments;
int32_t segmentOffset;
int32_t numTextures;
int32_t textureOffset;
int32_t meshOffset;
int32_t radius;
} header;
// textures
if ( header.numTextures > 0 )
{
FSeek( header.textureOffset );
struct
{
char name[ 32 ];
} textures[ header.numTextures ];
}
/**
* meshes
* unfortunately rehex will choke on the below,
* as some of these have both a child and next,
* and there's no way for me to handle such a case
* easily right now, blarrrghh...
*/
local int hitEnd = 0;
FSeek( header.meshOffset );
struct Mesh( int &hitEnd )
{
if ( hitEnd == 0 )
{
local int pos = FTell();
uint32_t verticesOffset;// pos + vertexOffset
uint32_t numVertices;
uint32_t normalsOffset;// pos + normalsOffset
uint32_t numNormals;
uint32_t scale;
char name[ 16 ];
uint32_t childOffset;// pos + childOffset
uint32_t nextOffset; // pos + nextOffset
// todo: rest of the data, though, non-crucial...
struct Vertex
{
int16_t x;
int16_t y;
int16_t z;
int16_t u;
int16_t v;
};
FSeek( pos + verticesOffset );
struct Vertex vertices[ numVertices ];
FSeek( pos + normalsOffset );
struct Vertex normals[ numNormals ];
if ( nextOffset > 0 )
FSeek( pos + nextOffset );
else if ( childOffset > 0 )
FSeek( pos + childOffset );
else
hitEnd = 1;
}
};
struct Mesh meshes[ 0 ];
ArrayResize( meshes, header.numMeshes, hitEnd );
// polygons
if ( header.numPolygons > 0 )
{
FSeek( header.polygonOffset );
struct
{
char u0[ 7 ];
uint8_t type;
// todo: handle below by type...
struct RGB colours[ 3 ];
char u1[ 12 ];
} polygons[ header.numPolygons ];
}
// segments
// todo: yet to find a model that has these...
if ( header.numSegments > 0 )
{
FSeek( header.segmentOffset );
struct
{
} segments[ header.numSegments ];
}