]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - model_alias.h
Borland C++ compile fixes
[xonotic/darkplaces.git] / model_alias.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 /*
22 ==============================================================================
23
24 ALIAS MODELS
25
26 Alias models are position independent, so the cache manager can move them.
27 ==============================================================================
28 */
29
30 #include "modelgen.h"
31
32 /*
33 typedef struct
34 {
35         int                                     firstpose;
36         int                                     numposes;
37         float                           interval;
38         trivertx_t                      bboxmin;
39         trivertx_t                      bboxmax;
40         int                                     frame;
41         char                            name[16];
42 } maliasframedesc_t;
43
44 typedef struct
45 {
46         trivertx_t                      bboxmin;
47         trivertx_t                      bboxmax;
48         int                                     frame;
49 } maliasgroupframedesc_t;
50
51 typedef struct
52 {
53         int                                             numframes;
54         int                                             intervals;
55         maliasgroupframedesc_t  frames[1];
56 } maliasgroup_t;
57
58 typedef struct mtriangle_s {
59         int                                     facesfront;
60         int                                     vertindex[3];
61 } mtriangle_t;
62 */
63
64 // LordHavoc: new vertex format
65 typedef struct {
66         byte v[3]; // location
67         signed char n[3]; // surface normal for lighting *127.0
68 } trivert2;
69
70 #define MAX_SKINS       32
71 typedef struct {
72         int                     ident;
73         int                     version;
74         vec3_t          scale;
75         vec3_t          scale_origin;
76         float           boundingradius;
77         vec3_t          eyeposition;
78         int                     numskins;
79         int                     skinwidth;
80         int                     skinheight;
81         int                     numverts;
82         int                     numtris;
83         int                     numframes;
84         synctype_t      synctype;
85         int                     flags;
86         float           size;
87 } daliashdr_t;
88
89 typedef struct
90 {
91         char name[16]; // LordHavoc: only kept this for reasons of viewthing support
92         unsigned short start;
93         unsigned short length;
94         float rate; // in poses per second
95 } maliasframe_t;
96
97 typedef struct
98 {
99         vec3_t          scale;
100         vec3_t          scale_origin;
101         int                     numverts;
102         int                     numtris;
103         int                     numframes;
104         int                     numposes;
105         int                     framedata; // LordHavoc: unsigned short start
106         int                     texdata; // LordHavoc: texture coordinate array
107         int                     posedata; // LordHavoc: vertex data for all the poses
108         int                     tridata; // LordHavoc: vertex indices for the triangles
109 } maliashdr_t;
110
111 #define MAXALIASVERTS   4096
112 #define MAXALIASFRAMES  1024
113 #define MAXALIASTRIS    4096
114
115 /*
116 ========================================================================
117
118 .MD2 triangle model file format
119
120 ========================================================================
121 */
122
123 // LordHavoc: grabbed this from the Q2 utility source,
124 // renamed a things to avoid conflicts
125
126 #define MD2IDALIASHEADER                (('2'<<24)+('P'<<16)+('D'<<8)+'I')
127 #define MD2ALIAS_VERSION        8
128
129 #define MD2MAX_TRIANGLES        4096
130 #define MD2MAX_VERTS            4096
131 #define MD2MAX_FRAMES           1024
132 #define MD2MAX_SKINS    32
133 #define MD2MAX_SKINNAME 64
134 // sanity checking size
135 #define MD2MAX_SIZE     (16777216)
136
137 typedef struct
138 {
139         short   s;
140         short   t;
141 } md2stvert_t;
142
143 typedef struct 
144 {
145         short   index_xyz[3];
146         short   index_st[3];
147 } md2triangle_t;
148
149 typedef struct
150 {
151         float           scale[3];       // multiply byte verts by this
152         float           translate[3];   // then add this
153         char            name[16];       // frame name from grabbing
154         trivertx_t      verts[];        // variable sized
155 } md2frame_t;
156
157 // LordHavoc: memory representation is different than disk
158 typedef struct
159 {
160         float           scale[3];       // multiply byte verts by this
161         float           translate[3];   // then add this
162         trivert2        verts[];        // variable sized
163 } md2memframe_t;
164
165
166 // the glcmd format:
167 // a positive integer starts a tristrip command, followed by that many
168 // vertex structures.
169 // a negative integer starts a trifan command, followed by -x vertexes
170 // a zero indicates the end of the command list.
171 // a vertex consists of a floating point s, a floating point t,
172 // and an integer vertex index.
173
174
175 typedef struct
176 {
177         int                     ident;
178         int                     version;
179
180         int                     skinwidth;
181         int                     skinheight;
182         int                     framesize;              // byte size of each frame
183
184         int                     num_skins;
185         int                     num_xyz;
186         int                     num_st;                 // greater than num_xyz for seams
187         int                     num_tris;
188         int                     num_glcmds;             // dwords in strip/fan command list
189         int                     num_frames;
190
191         int                     ofs_skins;              // each skin is a MAX_SKINNAME string
192         int                     ofs_st;                 // byte offset from start for stverts
193         int                     ofs_tris;               // offset for dtriangles
194         int                     ofs_frames;             // offset for first frame
195         int                     ofs_glcmds;     
196         int                     ofs_end;                // end of file
197 } md2_t;
198
199 typedef struct
200 {
201         int                     framesize;              // byte size of each frame
202
203         int                     num_skins;
204         int                     num_xyz;
205         int                     num_st;                 // greater than num_xyz for seams
206         int                     num_tris;
207         int                     num_glcmds;             // dwords in strip/fan command list
208         int                     num_frames;
209
210         int                     ofs_tris;               // offset for dtriangles
211         int                     ofs_frames;             // offset for first frame
212         int                     ofs_glcmds;     
213 } md2mem_t;
214
215 #define ALIASTYPE_MDL 1
216 #define ALIASTYPE_MD2 2