]> icculus.org git repositories - divverent/darkplaces.git/blob - model_alias.h
improved TraceLine in chase.c to be more generally useful (should move it to another...
[divverent/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[1];       // 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         char            name[16];       // LordHavoc: kept for viewthing
163         trivert2        verts[1];       // variable sized
164 } md2memframe_t;
165
166 // must match md2memframe_t, this is just used for sizeof()
167 typedef struct
168 {
169         float           scale[3];       // multiply byte verts by this
170         float           translate[3];   // then add this
171 } md2memframesize_t;
172
173
174 // the glcmd format:
175 // a positive integer starts a tristrip command, followed by that many
176 // vertex structures.
177 // a negative integer starts a trifan command, followed by -x vertexes
178 // a zero indicates the end of the command list.
179 // a vertex consists of a floating point s, a floating point t,
180 // and an integer vertex index.
181
182
183 typedef struct
184 {
185         int                     ident;
186         int                     version;
187
188         int                     skinwidth;
189         int                     skinheight;
190         int                     framesize;              // byte size of each frame
191
192         int                     num_skins;
193         int                     num_xyz;
194         int                     num_st;                 // greater than num_xyz for seams
195         int                     num_tris;
196         int                     num_glcmds;             // dwords in strip/fan command list
197         int                     num_frames;
198
199         int                     ofs_skins;              // each skin is a MAX_SKINNAME string
200         int                     ofs_st;                 // byte offset from start for stverts
201         int                     ofs_tris;               // offset for dtriangles
202         int                     ofs_frames;             // offset for first frame
203         int                     ofs_glcmds;     
204         int                     ofs_end;                // end of file
205 } md2_t;
206
207 typedef struct
208 {
209         int                     framesize;              // byte size of each frame
210
211         int                     num_skins;
212         int                     num_xyz;
213         int                     num_st;                 // greater than num_xyz for seams
214         int                     num_tris;
215         int                     num_glcmds;             // dwords in strip/fan command list
216         int                     num_frames;
217
218         int                     ofs_tris;               // offset for dtriangles
219         int                     ofs_frames;             // offset for first frame
220         int                     ofs_glcmds;     
221 } md2mem_t;
222
223 #define ALIASTYPE_MDL 1
224 #define ALIASTYPE_MD2 2
225 #define ALIASTYPE_ZYM 3
226
227 #include "model_zymotic.h"