]> icculus.org git repositories - divverent/darkplaces.git/blob - model_shared.h
a big change with a little description...
[divverent/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 typedef struct model_s
56 {
57         char            name[MAX_QPATH];
58         qboolean        needload;               // bmodels don't cache normally
59
60         modtype_t       type;
61         int                     aliastype; // LordHavoc: Q2 model support
62         int                     fullbright; // LordHavoc: if true (normally only for sprites) the model/sprite/bmodel is always rendered fullbright
63         int                     numframes;
64         synctype_t      synctype;
65         
66         int                     flags;
67
68 // volume occupied by the model graphics
69         vec3_t          mins, maxs;
70         float           radius;
71
72 // solid volume for clipping 
73         qboolean        clipbox;
74         vec3_t          clipmins, clipmaxs;
75
76 // brush model
77         int                     firstmodelsurface, nummodelsurfaces;
78
79         int                     numsubmodels;
80         dmodel_t        *submodels;
81
82         int                     numplanes;
83         mplane_t        *planes;
84
85         int                     numleafs;               // number of visible leafs, not counting 0
86         mleaf_t         *leafs;
87
88         int                     numvertexes;
89         mvertex_t       *vertexes;
90
91         int                     numedges;
92         medge_t         *edges;
93
94         int                     numnodes;
95         mnode_t         *nodes;
96
97         int                     numtexinfo;
98         mtexinfo_t      *texinfo;
99
100         int                     numsurfaces;
101         msurface_t      *surfaces;
102
103         int                     numsurfedges;
104         int                     *surfedges;
105
106         int                     numclipnodes;
107         dclipnode_t     *clipnodes;
108
109         int                     nummarksurfaces;
110         msurface_t      **marksurfaces;
111
112         hull_t          hulls[MAX_MAP_HULLS];
113
114         int                     numtextures;
115         texture_t       **textures;
116
117         byte            *visdata;
118         byte            *lightdata;
119         char            *entities;
120
121         // LordHavoc: useful for sprites and models
122         int                     numtris;
123         int                     numskins;
124         int                     skinanimrange[MAX_SKINS*2]; // array of start and length pairs
125         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)
126         int                     ofs_scenes; // offset from Mod_ExtraData(model) memory to array of animscene_t structs
127         // these are used simply to simplify model/sprite/whatever processing and are specific to each type
128         int                     ofs_frames; // offset from Mod_ExtraData(model) memory to array of model specific frame structs
129         int                     framesize; // size of model specific frame structs
130
131 // additional model data
132         cache_user_t    cache;          // only access through Mod_Extradata
133         int                     cachesize;              // size of cached data (zero if not cached)
134
135 } model_t;
136
137 //============================================================================
138
139 void    Mod_Init (void);
140 void    Mod_ClearAll (void);
141 model_t *Mod_ForName (char *name, qboolean crash);
142 void    *Mod_Extradata (model_t *mod);  // handles caching
143 void    Mod_TouchModel (char *name);
144
145 mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
146 byte    *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
147
148 extern model_t  *loadmodel;
149 extern char     loadname[32];   // for hunk tags
150
151 extern model_t *Mod_LoadModel (model_t *mod, qboolean crash);
152
153 extern float RadiusFromBounds (vec3_t mins, vec3_t maxs);
154 extern model_t *Mod_FindName (char *name);
155 #endif  // __MODEL__