]> icculus.org git repositories - divverent/darkplaces.git/blob - model_alias.h
fixed gl_combine so it is enabled by default (if present)
[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 typedef struct {
65         int                     ident;
66         int                     version;
67         vec3_t          scale;
68         vec3_t          scale_origin;
69         float           boundingradius;
70         vec3_t          eyeposition;
71         int                     numskins;
72         int                     skinwidth;
73         int                     skinheight;
74         int                     numverts;
75         int                     numtris;
76         int                     numframes;
77         synctype_t      synctype;
78         int                     flags;
79         float           size;
80 } daliashdr_t;
81
82 typedef struct
83 {
84         vec3_t          scale;
85         vec3_t          scale_origin;
86         int                     numverts;
87         int                     numtris;
88         int                     numframes;
89         int                     numposes;
90         int                     texdata; // LordHavoc: texture coordinate array
91         int                     posedata; // LordHavoc: vertex data for all the poses
92         int                     tridata; // LordHavoc: vertex indices for the triangles
93 } maliashdr_t;
94
95 #define MAXALIASVERTS   4096
96 #define MAXALIASFRAMES  1024
97 #define MAXALIASTRIS    4096
98
99 /*
100 ========================================================================
101
102 .MD2 triangle model file format
103
104 ========================================================================
105 */
106
107 // LordHavoc: grabbed this from the Q2 utility source,
108 // renamed a things to avoid conflicts
109
110 #define MD2IDALIASHEADER                (('2'<<24)+('P'<<16)+('D'<<8)+'I')
111 #define MD2ALIAS_VERSION        8
112
113 #define MD2MAX_TRIANGLES        4096
114 #define MD2MAX_VERTS            4096
115 #define MD2MAX_FRAMES           1024
116 #define MD2MAX_SKINNAME 64
117 // sanity checking size
118 #define MD2MAX_SIZE     (16777216)
119
120 typedef struct
121 {
122         short   s;
123         short   t;
124 } md2stvert_t;
125
126 typedef struct 
127 {
128         short   index_xyz[3];
129         short   index_st[3];
130 } md2triangle_t;
131
132 typedef struct
133 {
134         float           scale[3];       // multiply byte verts by this
135         float           translate[3];   // then add this
136         char            name[16];       // frame name from grabbing
137         trivertx_t      verts[1];       // variable sized
138 } md2frame_t;
139
140 // must match md2frame_t, this is just used for sizeof()
141 typedef struct
142 {
143         float           scale[3];       // multiply byte verts by this
144         float           translate[3];   // then add this
145 } md2framesize_t;
146
147
148 // the glcmd format:
149 // a positive integer starts a tristrip command, followed by that many
150 // vertex structures.
151 // a negative integer starts a trifan command, followed by -x vertexes
152 // a zero indicates the end of the command list.
153 // a vertex consists of a floating point s, a floating point t,
154 // and an integer vertex index.
155
156
157 typedef struct
158 {
159         int                     ident;
160         int                     version;
161
162         int                     skinwidth;
163         int                     skinheight;
164         int                     framesize;              // byte size of each frame
165
166         int                     num_skins;
167         int                     num_xyz;
168         int                     num_st;                 // greater than num_xyz for seams
169         int                     num_tris;
170         int                     num_glcmds;             // dwords in strip/fan command list
171         int                     num_frames;
172
173         int                     ofs_skins;              // each skin is a MAX_SKINNAME string
174         int                     ofs_st;                 // byte offset from start for stverts
175         int                     ofs_tris;               // offset for dtriangles
176         int                     ofs_frames;             // offset for first frame
177         int                     ofs_glcmds;     
178         int                     ofs_end;                // end of file
179 } md2_t;
180
181 typedef struct
182 {
183         int                     framesize;              // byte size of each frame
184
185         int                     num_skins;
186         int                     num_xyz;
187         int                     num_st;                 // greater than num_xyz for seams
188         int                     num_tris;
189         int                     num_glcmds;             // dwords in strip/fan command list
190         int                     num_frames;
191
192         int                     ofs_tris;               // offset for dtriangles
193         int                     ofs_frames;             // offset for first frame
194         int                     ofs_glcmds;     
195 } md2mem_t;
196
197 #define ALIASTYPE_MDL 1
198 #define ALIASTYPE_MD2 2
199 #define ALIASTYPE_ZYM 3
200
201 extern void Mod_LoadAliasModel (struct model_s *mod, void *buffer);
202 extern void Mod_LoadQ2AliasModel (struct model_s *mod, void *buffer);
203
204 extern void Mod_AliasInit(void);
205
206 #include "model_zymotic.h"