]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - model_shared.h
rewrote RecursiveHullCheck, no longer gets stuck on angle changes, and is generally...
[xonotic/darkplaces.git] / model_shared.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__
22 #define __MODEL__
23
24 #ifndef SYNCTYPE_T
25 #define SYNCTYPE_T
26 typedef enum {ST_SYNC=0, ST_RAND } synctype_t;
27 #endif
28
29 /*
30
31 d*_t structures are on-disk representations
32 m*_t structures are in-memory
33
34 */
35
36 typedef enum {mod_brush, mod_sprite, mod_alias} modtype_t;
37
38 typedef struct animscene_s
39 {
40         char name[32]; // for viewthing support
41         int firstframe;
42         int framecount;
43         int loop; // true or false
44         float framerate;
45 }
46 animscene_t;
47
48 #define MAX_SKINS 256
49
50
51 #include "model_brush.h"
52 #include "model_sprite.h"
53 #include "model_alias.h"
54
55 #define MODF_TRANSPARENT 1
56
57 typedef struct model_s
58 {
59         char            name[MAX_QPATH];
60         qboolean        needload;               // bmodels don't cache normally
61
62         modtype_t       type;
63         int                     aliastype; // LordHavoc: Q2 model support
64         int                     fullbright; // LordHavoc: if true (normally only for sprites) the model/sprite/bmodel is always rendered fullbright
65         int                     numframes;
66         synctype_t      synctype;
67
68         int                     flags;
69         int                     flags2; // engine calculated flags, ones that can not be set in the file
70
71 // volume occupied by the model graphics
72         vec3_t          normalmins, normalmaxs; // bounding box at angles '0 0 0'
73         vec3_t          yawmins, yawmaxs; // bounding box if yaw angle is not 0, but pitch and roll are
74         vec3_t          rotatedmins, rotatedmaxs; // bounding box if pitch or roll are used
75 //      float           modelradius; // usable at any angles
76
77 // solid volume for clipping
78         qboolean        clipbox;
79         vec3_t          clipmins, clipmaxs;
80
81 // brush model
82         int                     firstmodelsurface, nummodelsurfaces;
83
84         int                     numsubmodels;
85         dmodel_t        *submodels;
86
87         int                     numplanes;
88         mplane_t        *planes;
89
90         int                     numleafs;               // number of visible leafs, not counting 0
91         mleaf_t         *leafs;
92
93         int                     numvertexes;
94         mvertex_t       *vertexes;
95
96         int                     numedges;
97         medge_t         *edges;
98
99         int                     numnodes;
100         mnode_t         *nodes;
101
102         int                     numtexinfo;
103         mtexinfo_t      *texinfo;
104
105         int                     numsurfaces;
106         msurface_t      *surfaces;
107
108         int                     numsurfedges;
109         int                     *surfedges;
110
111         int                     numclipnodes;
112         dclipnode_t     *clipnodes;
113
114         int                     nummarksurfaces;
115         msurface_t      **marksurfaces;
116
117         hull_t          hulls[MAX_MAP_HULLS];
118
119         int                     numtextures;
120         texture_t       **textures;
121
122         byte            *visdata;
123         byte            *lightdata;
124         char            *entities;
125
126         int                     numportals;
127         mportal_t       *portals;
128
129         int                     numportalpoints;
130         mvertex_t       *portalpoints;
131
132         // LordHavoc: useful for sprites and models
133         int                     numtris;
134         int                     numskins;
135
136         int                     skinanimrange[MAX_SKINS*2]; // array of start and length pairs
137         rtexture_t      *skinanim[MAX_SKINS*5]; // texture numbers for each frame (indexed by animrange), note: normal pants shirt glow body (normal contains no shirt/pants/glow colors and body is normal + pants + shirt, but not glow)
138
139         int                     ofs_scenes; // offset from Mod_ExtraData(model) memory to array of animscene_t structs
140         // these are used simply to simplify model/sprite/whatever processing and are specific to each type
141         int                     ofs_frames; // offset from Mod_ExtraData(model) memory to array of model specific frame structs
142         int                     framesize; // size of model specific frame structs
143
144         void (*SERAddEntity)(void);
145         void (*DrawEarly)(void);
146         void (*DrawLate)(void);
147         void (*DrawShadow)(void);
148
149 // additional model data
150         cache_user_t    cache;          // only access through Mod_Extradata
151         int                     cachesize;              // size of cached data (zero if not cached)
152
153 } model_t;
154
155 //============================================================================
156
157 // used to avoid setting up submodels in non-world bmodels
158 extern qboolean isworldmodel;
159 // model loading
160 extern model_t *loadmodel;
161 extern byte     *mod_base;
162 // sky/water subdivision
163 extern cvar_t gl_subdivide_size;
164 // texture fullbrights
165 extern cvar_t r_fullbrights;
166
167 void Mod_Init (void);
168 void Mod_ClearAll (void);
169 model_t *Mod_ForName (char *name, qboolean crash);
170 void *Mod_Extradata (model_t *mod);     // handles caching
171 void Mod_TouchModel (char *name);
172
173 mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
174 byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
175
176 extern model_t *loadmodel;
177 extern char loadname[32];       // for hunk tags
178
179 extern model_t *Mod_LoadModel (model_t *mod, qboolean crash);
180
181 extern float RadiusFromBounds (vec3_t mins, vec3_t maxs);
182 extern model_t *Mod_FindName (char *name);
183
184 #endif  // __MODEL__