1 /* -----------------------------------------------------------------------------
5 Copyright (c) 2002, Randy Reddig & seaw0lf
8 Redistribution and use in source and binary forms, with or without modification,
9 are permitted provided that the following conditions are met:
11 Redistributions of source code must retain the above copyright notice, this list
12 of conditions and the following disclaimer.
14 Redistributions in binary form must reproduce the above copyright notice, this
15 list of conditions and the following disclaimer in the documentation and/or
16 other materials provided with the distribution.
18 Neither the names of the copyright holders nor the names of its contributors may
19 be used to endorse or promote products derived from this software without
20 specific prior written permission.
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ----------------------------------------------------------------------------- */
35 // This header file is based from the following:
38 FlexModel.H - Header file for FlexModel file structure
41 serotonin@earthlink.net
47 #include "picointernal.h"
51 // Absolute limits (from QData / QMView source)
53 #define MAX_FM_TRIANGLES 2048
54 #define MAX_FM_VERTS 2048
55 #define MAX_FM_FRAMES 2048
56 #define MAX_FM_SKINS 64
57 #define MAX_FM_SKINNAME 64
58 #define MAX_FM_MESH_NODES 16
60 #define DTRIVERTX_V0 0
61 #define DTRIVERTX_V1 1
62 #define DTRIVERTX_V2 2
63 #define DTRIVERTX_LNI 3
64 #define DTRIVERTX_SIZE 4
66 #define SKINPAGE_WIDTH 640
67 #define SKINPAGE_HEIGHT 480
69 #define ENCODED_WIDTH_X 92
70 #define ENCODED_WIDTH_Y 475
71 #define ENCODED_HEIGHT_X 128
72 #define ENCODED_HEIGHT_Y 475
74 #define SCALE_ADJUST_FACTOR 0.96
77 #define INFO_Y ( SKINPAGE_HEIGHT - INFO_HEIGHT )
81 // Generic header on every chunk
83 #define FM_MAXCHUNKIDENT 32L
86 char ident[FM_MAXCHUNKIDENT];
92 // The format of the "header" chunk
94 #define FM_HEADERCHUNKNAME "header"
95 #define FM_HEADERCHUNKVER 2
96 #define FM_HEADERCHUNKSIZE 40
99 int skinWidth; // in pixels
100 int skinHeight; // in pixels
101 int frameSize; // size of each frame (in bytes)
102 int numSkins; // number of skins
103 int numXYZ; // number of unique vertices in 3D space
104 int numST; // number of unique vertices in texture space
105 int numTris; // number of unique triangles
106 int numGLCmds; // # 32-bit elements in strip/fan command list
107 int numFrames; // number of animation frames
108 int numMeshNodes; // number of mesh nodes
112 // The format of an entry in the "skin" chunk.
113 // The number of entries is given in the fmheader chunk
115 #define FM_SKINCHUNKNAME "skin"
116 #define FM_SKINCHUNKVER 1
117 #define FM_MAXPATHLENGTH 64L
118 #define FM_SKINPATHSIZE ( FM_MAXPATHLENGTH )
121 char path[FM_SKINPATHSIZE]; // path, relative to 'base'
125 // The format of the "st coord" chunk. This is a list
126 // of unique skin texture (u, v) coordinates to be mapped
127 // to verteces of the model
129 #define FM_STCOORDCHUNKNAME "st coord"
130 #define FM_STCOORDCHUNKVER 1
131 #define FM_STCOORDUVSIZE ( 2L + 2L )
140 // The format of the "tris" chunk. This is a list of vertex indeces
141 // in 3D space, and the corresponding vertex indeces in texture space.
143 #define FM_TRISCHUNKNAME "tris"
144 #define FM_TRISCHUNKVER 1
145 #define FM_TRISINFOSIZE ( 2L * 3 + 2L * 3 )
155 // The format of the "frames" chunk. This is a list of animation
156 // frames, each specifying the coordinates and "light normal" index
157 // of every vertex of the model in 3D space.
159 #define FM_FRAMESCHUNKNAME "frames"
160 #define FM_FRAMESCHUNKVER 1
162 #define FM_NUMVERTEXNORMALS 162
167 byte v[3]; // scaled by header info
168 byte lightnormalindex; // index in canned table of closest vertex normal
173 float scale[3]; // multiply byte verts by this
174 float translate[3]; // then add this
175 char name[16]; // frame name
180 fm_framehdr_t header; // One header per frame
181 fm_vert_normal_t verts[1]; // variable number of these
186 fm_chunk_header_t *fm_header_hdr;
187 fm_header_t *fm_header;
188 fm_chunk_header_t *fm_skin_hdr;
189 fm_skinpath_t *fm_skin;
190 fm_chunk_header_t *fm_st_hdr;
192 fm_chunk_header_t *fm_tri_hdr;
194 fm_chunk_header_t *fm_frame_hdr;
195 fm_frame_t *fm_frame;
198 float fm_normals[FM_NUMVERTEXNORMALS][3] = {
199 {-0.525731f, 0.000000f, 0.850651f},
200 {-0.442863f, 0.238856f, 0.864188f},
201 {-0.295242f, 0.000000f, 0.955423f},
202 {-0.309017f, 0.500000f, 0.809017f},
203 {-0.162460f, 0.262866f, 0.951056f},
204 {0.000000f, 0.000000f, 1.000000f},
205 {0.000000f, 0.850651f, 0.525731f},
206 {-0.147621f, 0.716567f, 0.681718f},
207 {0.147621f, 0.716567f, 0.681718f},
208 {0.000000f, 0.525731f, 0.850651f},
209 {0.309017f, 0.500000f, 0.809017f},
210 {0.525731f, 0.000000f, 0.850651f},
211 {0.295242f, 0.000000f, 0.955423f},
212 {0.442863f, 0.238856f, 0.864188f},
213 {0.162460f, 0.262866f, 0.951056f},
214 {-0.681718f, 0.147621f, 0.716567f},
215 {-0.809017f, 0.309017f, 0.500000f},
216 {-0.587785f, 0.425325f, 0.688191f},
217 {-0.850651f, 0.525731f, 0.000000f},
218 {-0.864188f, 0.442863f, 0.238856f},
219 {-0.716567f, 0.681718f, 0.147621f},
220 {-0.688191f, 0.587785f, 0.425325f},
221 {-0.500000f, 0.809017f, 0.309017f},
222 {-0.238856f, 0.864188f, 0.442863f},
223 {-0.425325f, 0.688191f, 0.587785f},
224 {-0.716567f, 0.681718f, -0.147621f},
225 {-0.500000f, 0.809017f, -0.309017f},
226 {-0.525731f, 0.850651f, 0.000000f},
227 {0.000000f, 0.850651f, -0.525731f},
228 {-0.238856f, 0.864188f, -0.442863f},
229 {0.000000f, 0.955423f, -0.295242f},
230 {-0.262866f, 0.951056f, -0.162460f},
231 {0.000000f, 1.000000f, 0.000000f},
232 {0.000000f, 0.955423f, 0.295242f},
233 {-0.262866f, 0.951056f, 0.162460f},
234 {0.238856f, 0.864188f, 0.442863f},
235 {0.262866f, 0.951056f, 0.162460f},
236 {0.500000f, 0.809017f, 0.309017f},
237 {0.238856f, 0.864188f, -0.442863f},
238 {0.262866f, 0.951056f, -0.162460f},
239 {0.500000f, 0.809017f, -0.309017f},
240 {0.850651f, 0.525731f, 0.000000f},
241 {0.716567f, 0.681718f, 0.147621f},
242 {0.716567f, 0.681718f, -0.147621f},
243 {0.525731f, 0.850651f, 0.000000f},
244 {0.425325f, 0.688191f, 0.587785f},
245 {0.864188f, 0.442863f, 0.238856f},
246 {0.688191f, 0.587785f, 0.425325f},
247 {0.809017f, 0.309017f, 0.500000f},
248 {0.681718f, 0.147621f, 0.716567f},
249 {0.587785f, 0.425325f, 0.688191f},
250 {0.955423f, 0.295242f, 0.000000f},
251 {1.000000f, 0.000000f, 0.000000f},
252 {0.951056f, 0.162460f, 0.262866f},
253 {0.850651f, -0.525731f, 0.000000f},
254 {0.955423f, -0.295242f, 0.000000f},
255 {0.864188f, -0.442863f, 0.238856f},
256 {0.951056f, -0.162460f, 0.262866f},
257 {0.809017f, -0.309017f, 0.500000f},
258 {0.681718f, -0.147621f, 0.716567f},
259 {0.850651f, 0.000000f, 0.525731f},
260 {0.864188f, 0.442863f, -0.238856f},
261 {0.809017f, 0.309017f, -0.500000f},
262 {0.951056f, 0.162460f, -0.262866f},
263 {0.525731f, 0.000000f, -0.850651f},
264 {0.681718f, 0.147621f, -0.716567f},
265 {0.681718f, -0.147621f, -0.716567f},
266 {0.850651f, 0.000000f, -0.525731f},
267 {0.809017f, -0.309017f, -0.500000f},
268 {0.864188f, -0.442863f, -0.238856f},
269 {0.951056f, -0.162460f, -0.262866f},
270 {0.147621f, 0.716567f, -0.681718f},
271 {0.309017f, 0.500000f, -0.809017f},
272 {0.425325f, 0.688191f, -0.587785f},
273 {0.442863f, 0.238856f, -0.864188f},
274 {0.587785f, 0.425325f, -0.688191f},
275 {0.688191f, 0.587785f, -0.425325f},
276 {-0.147621f, 0.716567f, -0.681718f},
277 {-0.309017f, 0.500000f, -0.809017f},
278 {0.000000f, 0.525731f, -0.850651f},
279 {-0.525731f, 0.000000f, -0.850651f},
280 {-0.442863f, 0.238856f, -0.864188f},
281 {-0.295242f, 0.000000f, -0.955423f},
282 {-0.162460f, 0.262866f, -0.951056f},
283 {0.000000f, 0.000000f, -1.000000f},
284 {0.295242f, 0.000000f, -0.955423f},
285 {0.162460f, 0.262866f, -0.951056f},
286 {-0.442863f, -0.238856f, -0.864188f},
287 {-0.309017f, -0.500000f, -0.809017f},
288 {-0.162460f, -0.262866f, -0.951056f},
289 {0.000000f, -0.850651f, -0.525731f},
290 {-0.147621f, -0.716567f, -0.681718f},
291 {0.147621f, -0.716567f, -0.681718f},
292 {0.000000f, -0.525731f, -0.850651f},
293 {0.309017f, -0.500000f, -0.809017f},
294 {0.442863f, -0.238856f, -0.864188f},
295 {0.162460f, -0.262866f, -0.951056f},
296 {0.238856f, -0.864188f, -0.442863f},
297 {0.500000f, -0.809017f, -0.309017f},
298 {0.425325f, -0.688191f, -0.587785f},
299 {0.716567f, -0.681718f, -0.147621f},
300 {0.688191f, -0.587785f, -0.425325f},
301 {0.587785f, -0.425325f, -0.688191f},
302 {0.000000f, -0.955423f, -0.295242f},
303 {0.000000f, -1.000000f, 0.000000f},
304 {0.262866f, -0.951056f, -0.162460f},
305 {0.000000f, -0.850651f, 0.525731f},
306 {0.000000f, -0.955423f, 0.295242f},
307 {0.238856f, -0.864188f, 0.442863f},
308 {0.262866f, -0.951056f, 0.162460f},
309 {0.500000f, -0.809017f, 0.309017f},
310 {0.716567f, -0.681718f, 0.147621f},
311 {0.525731f, -0.850651f, 0.000000f},
312 {-0.238856f, -0.864188f, -0.442863f},
313 {-0.500000f, -0.809017f, -0.309017f},
314 {-0.262866f, -0.951056f, -0.162460f},
315 {-0.850651f, -0.525731f, 0.000000f},
316 {-0.716567f, -0.681718f, -0.147621f},
317 {-0.716567f, -0.681718f, 0.147621f},
318 {-0.525731f, -0.850651f, 0.000000f},
319 {-0.500000f, -0.809017f, 0.309017f},
320 {-0.238856f, -0.864188f, 0.442863f},
321 {-0.262866f, -0.951056f, 0.162460f},
322 {-0.864188f, -0.442863f, 0.238856f},
323 {-0.809017f, -0.309017f, 0.500000f},
324 {-0.688191f, -0.587785f, 0.425325f},
325 {-0.681718f, -0.147621f, 0.716567f},
326 {-0.442863f, -0.238856f, 0.864188f},
327 {-0.587785f, -0.425325f, 0.688191f},
328 {-0.309017f, -0.500000f, 0.809017f},
329 {-0.147621f, -0.716567f, 0.681718f},
330 {-0.425325f, -0.688191f, 0.587785f},
331 {-0.162460f, -0.262866f, 0.951056f},
332 {0.442863f, -0.238856f, 0.864188f},
333 {0.162460f, -0.262866f, 0.951056f},
334 {0.309017f, -0.500000f, 0.809017f},
335 {0.147621f, -0.716567f, 0.681718f},
336 {0.000000f, -0.525731f, 0.850651f},
337 {0.425325f, -0.688191f, 0.587785f},
338 {0.587785f, -0.425325f, 0.688191f},
339 {0.688191f, -0.587785f, 0.425325f},
340 {-0.955423f, 0.295242f, 0.000000f},
341 {-0.951056f, 0.162460f, 0.262866f},
342 {-1.000000f, 0.000000f, 0.000000f},
343 {-0.850651f, 0.000000f, 0.525731f},
344 {-0.955423f, -0.295242f, 0.000000f},
345 {-0.951056f, -0.162460f, 0.262866f},
346 {-0.864188f, 0.442863f, -0.238856f},
347 {-0.951056f, 0.162460f, -0.262866f},
348 {-0.809017f, 0.309017f, -0.500000f},
349 {-0.864188f, -0.442863f, -0.238856f},
350 {-0.951056f, -0.162460f, -0.262866f},
351 {-0.809017f, -0.309017f, -0.500000f},
352 {-0.681718f, 0.147621f, -0.716567f},
353 {-0.681718f, -0.147621f, -0.716567f},
354 {-0.850651f, 0.000000f, -0.525731f},
355 {-0.688191f, 0.587785f, -0.425325f},
356 {-0.587785f, 0.425325f, -0.688191f},
357 {-0.425325f, 0.688191f, -0.587785f},
358 {-0.425325f, -0.688191f, -0.587785f},
359 {-0.587785f, -0.425325f, -0.688191f},
360 {-0.688191f, -0.587785f, -0.425325f},