]> git.xonotic.org Git - xonotic/darkplaces.git/blob - model_alias.h
Add a proper README with build instructions and links to the available chats. To...
[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 #ifndef MODEL_ALIAS_H
22 #define MODEL_ALIAS_H
23
24 #include <stddef.h>
25 #include "qtypes.h"
26 /*
27 ==============================================================================
28
29 ALIAS MODELS
30
31 Alias models are position independent, so the cache manager can move them.
32 ==============================================================================
33 */
34
35 #include "modelgen.h"
36
37 typedef struct daliashdr_s
38 {
39         int                     ident;
40         int                     version;
41         vec3_t          scale;
42         vec3_t          scale_origin;
43         float           boundingradius;
44         vec3_t          eyeposition;
45         int                     numskins;
46         int                     skinwidth;
47         int                     skinheight;
48         int                     numverts;
49         int                     numtris;
50         int                     numframes;
51         int                     synctype;
52         int                     flags;
53         float           size;
54 }
55 daliashdr_t;
56
57 /*
58 ========================================================================
59
60 .MD2 triangle model file format
61
62 ========================================================================
63 */
64
65 // LadyHavoc: grabbed this from the Q2 utility source,
66 // renamed a things to avoid conflicts
67
68 #define MD2ALIAS_VERSION        8
69 #define MD2_SKINNAME    64
70
71 typedef struct md2stvert_s
72 {
73         short   s;
74         short   t;
75 } md2stvert_t;
76
77 typedef struct md2triangle_s
78 {
79         short   index_xyz[3];
80         short   index_st[3];
81 } md2triangle_t;
82
83 typedef struct md2frame_s
84 {
85         float           scale[3];       // multiply byte verts by this
86         float           translate[3];   // then add this
87         char            name[16];       // frame name from grabbing
88 } md2frame_t;
89
90 // the glcmd format:
91 // a positive integer starts a tristrip command, followed by that many
92 // vertex structures.
93 // a negative integer starts a trifan command, followed by -x vertexes
94 // a zero indicates the end of the command list.
95 // a vertex consists of a floating point s, a floating point t,
96 // and an integer vertex index.
97
98
99 typedef struct md2_s
100 {
101         int                     ident;
102         int                     version;
103
104         int                     skinwidth;
105         int                     skinheight;
106         int                     framesize;              // byte size of each frame
107
108         int                     num_skins;
109         int                     num_xyz;
110         int                     num_st;                 // greater than num_xyz for seams
111         int                     num_tris;
112         int                     num_glcmds;             // dwords in strip/fan command list
113         int                     num_frames;
114
115         int                     ofs_skins;              // each skin is a MAX_SKINNAME string
116         int                     ofs_st;                 // byte offset from start for stverts
117         int                     ofs_tris;               // offset for dtriangles
118         int                     ofs_frames;             // offset for first frame
119         int                     ofs_glcmds;
120         int                     ofs_end;                // end of file
121 } md2_t;
122
123 // all md3 ints, floats, and shorts, are little endian, and thus need to be
124 // passed through LittleLong/LittleFloat/LittleShort to avoid breaking on
125 // bigendian machines
126 #define MD3VERSION 15
127 #define MD3NAME 64
128 #define MD3FRAMENAME 16
129
130 // the origin is at 1/64th scale
131 // the pitch and yaw are encoded as 8 bits each
132 typedef struct md3vertex_s
133 {
134         short origin[3];
135         unsigned char pitch;
136         unsigned char yaw;
137 }
138 md3vertex_t;
139
140 // one per frame
141 typedef struct md3frameinfo_s
142 {
143         float mins[3];
144         float maxs[3];
145         float origin[3];
146         float radius;
147         char name[MD3FRAMENAME];
148 }
149 md3frameinfo_t;
150
151 // one per tag per frame
152 typedef struct md3tag_s
153 {
154         char name[MD3NAME];
155         float origin[3];
156         float rotationmatrix[9];
157 }
158 md3tag_t;
159
160 // one per shader per mesh
161 typedef struct md3shader_s
162 {
163         char name[MD3NAME];
164         // engine field (yes this empty int does exist in the file)
165         int shadernum;
166 }
167 md3shader_t;
168
169 // one per mesh per model
170 //
171 // note that the lump_ offsets in this struct are relative to the beginning
172 // of the mesh struct
173 //
174 // to find the next mesh in the file, you must go to lump_end, which puts you
175 // at the beginning of the next mesh
176 typedef struct md3mesh_s
177 {
178         char identifier[4]; // "IDP3"
179         char name[MD3NAME];
180         int flags;
181         int num_frames;
182         int num_shaders;
183         int num_vertices;
184         int num_triangles;
185         int lump_elements;
186         int lump_shaders;
187         int lump_texcoords;
188         int lump_framevertices;
189         int lump_end;
190 }
191 md3mesh_t;
192
193 // this struct is at the beginning of the md3 file
194 //
195 // note that the lump_ offsets in this struct are relative to the beginning
196 // of the header struct (which is the beginning of the file)
197 typedef struct md3modelheader_s
198 {
199         char identifier[4]; // "IDP3"
200         int version; // 15
201         char name[MD3NAME];
202         int flags;
203         int num_frames;
204         int num_tags;
205         int num_meshes;
206         int num_skins;
207         int lump_frameinfo;
208         int lump_tags;
209         int lump_meshes;
210         int lump_end;
211 }
212 md3modelheader_t;
213
214 typedef struct aliastag_s
215 {
216         char name[MD3NAME];
217         float matrixgl[12];
218 }
219 aliastag_t;
220
221 typedef struct aliasbone_s
222 {
223         char name[MD3NAME];
224         int flags;
225         int parent; // -1 for no parent
226 }
227 aliasbone_t;
228
229 #include "model_zymotic.h"
230
231 #include "model_dpmodel.h"
232
233 #include "model_psk.h"
234
235 #include "model_iqm.h"
236
237 // for decoding md3 model latlong vertex normals
238 extern float mod_md3_sin[320];
239
240 extern struct cvar_s r_skeletal_debugbone;
241 extern struct cvar_s r_skeletal_debugbonecomponent;
242 extern struct cvar_s r_skeletal_debugbonevalue;
243 extern struct cvar_s r_skeletal_debugtranslatex;
244 extern struct cvar_s r_skeletal_debugtranslatey;
245 extern struct cvar_s r_skeletal_debugtranslatez;
246
247 struct model_s;
248 struct frameblend_s;
249 struct skeleton_s;
250
251 void *Mod_Skeletal_AnimateVertices_AllocBuffers(size_t nbytes);
252 void Mod_Skeletal_BuildTransforms(const struct model_s * RESTRICT model, const struct frameblend_s * RESTRICT frameblend, const struct skeleton_s *skeleton, float * RESTRICT bonepose, float * RESTRICT boneposerelative);
253
254 #endif
255