2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #ifndef __MODEL_LOCAL_H__
30 #define __MODEL_LOCAL_H__
33 ===============================================================================
37 ===============================================================================
40 class idRenderModelStatic : public idRenderModel {
42 // the inherited public interface
43 static idRenderModel * Alloc();
45 idRenderModelStatic();
46 virtual ~idRenderModelStatic();
48 virtual void InitFromFile( const char *fileName );
49 virtual void PartialInitFromFile( const char *fileName );
50 virtual void PurgeModel();
51 virtual void Reset() {};
52 virtual void LoadModel();
53 virtual bool IsLoaded();
54 virtual void SetLevelLoadReferenced( bool referenced );
55 virtual bool IsLevelLoadReferenced();
56 virtual void TouchData();
57 virtual void InitEmpty( const char *name );
58 virtual void AddSurface( modelSurface_t surface );
59 virtual void FinishSurfaces();
60 virtual void FreeVertexCache();
61 virtual const char * Name() const;
62 virtual void Print() const;
63 virtual void List() const;
64 virtual int Memory() const;
65 virtual ID_TIME_T Timestamp() const;
66 virtual int NumSurfaces() const;
67 virtual int NumBaseSurfaces() const;
68 virtual const modelSurface_t *Surface( int surfaceNum ) const;
69 virtual srfTriangles_t * AllocSurfaceTriangles( int numVerts, int numIndexes ) const;
70 virtual void FreeSurfaceTriangles( srfTriangles_t *tris ) const;
71 virtual srfTriangles_t * ShadowHull() const;
72 virtual bool IsStaticWorldModel() const;
73 virtual dynamicModel_t IsDynamicModel() const;
74 virtual bool IsDefaultModel() const;
75 virtual bool IsReloadable() const;
76 virtual idRenderModel * InstantiateDynamicModel( const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel );
77 virtual int NumJoints( void ) const;
78 virtual const idMD5Joint * GetJoints( void ) const;
79 virtual jointHandle_t GetJointHandle( const char *name ) const;
80 virtual const char * GetJointName( jointHandle_t handle ) const;
81 virtual const idJointQuat * GetDefaultPose( void ) const;
82 virtual int NearestJoint( int surfaceNum, int a, int b, int c ) const;
83 virtual idBounds Bounds( const struct renderEntity_s *ent ) const;
84 virtual void ReadFromDemoFile( class idDemoFile *f );
85 virtual void WriteToDemoFile( class idDemoFile *f );
86 virtual float DepthHack() const;
88 void MakeDefaultModel();
90 bool LoadASE( const char *fileName );
91 bool LoadLWO( const char *fileName );
92 bool LoadFLT( const char *fileName );
93 bool LoadMA( const char *filename );
95 bool ConvertASEToModelSurfaces( const struct aseModel_s *ase );
96 bool ConvertLWOToModelSurfaces( const struct st_lwObject *lwo );
97 bool ConvertMAToModelSurfaces (const struct maModel_s *ma );
99 struct aseModel_s * ConvertLWOToASE( const struct st_lwObject *obj, const char *fileName );
101 bool DeleteSurfaceWithId( int id );
102 void DeleteSurfacesWithNegativeId( void );
103 bool FindSurfaceWithId( int id, int &surfaceNum );
106 idList<modelSurface_t> surfaces;
111 int lastModifiedFrame;
112 int lastArchivedFrame;
115 srfTriangles_t * shadowHull;
116 bool isStaticWorldModel;
118 bool purged; // eventually we will have dynamic reloading
119 bool fastLoad; // don't generate tangents and shadow data
120 bool reloadable; // if not, reloadModels won't check timestamp
121 bool levelLoadReferenced; // for determining if it needs to be freed
124 static idCVar r_mergeModelSurfaces; // combine model surfaces with the same material
125 static idCVar r_slopVertex; // merge xyz coordinates this far apart
126 static idCVar r_slopTexCoord; // merge texture coordinates this far apart
127 static idCVar r_slopNormal; // merge normals that dot less than this
131 ===============================================================================
135 ===============================================================================
139 friend class idRenderModelMD5;
145 void ParseMesh( idLexer &parser, int numJoints, const idJointMat *joints );
146 void UpdateSurface( const struct renderEntity_s *ent, const idJointMat *joints, modelSurface_t *surf );
147 idBounds CalcBounds( const idJointMat *joints );
148 int NearestJoint( int a, int b, int c ) const;
149 int NumVerts( void ) const;
150 int NumTris( void ) const;
151 int NumWeights( void ) const;
154 idList<idVec2> texCoords; // texture coordinates
155 int numWeights; // number of weights
156 idVec4 * scaledWeights; // joint weights
157 int * weightIndex; // pairs of: joint offset + bool true if next weight is for next vertex
158 const idMaterial * shader; // material applied to mesh
159 int numTris; // number of triangles
160 struct deformInfo_s * deformInfo; // used to create srfTriangles_t from base frames and new vertexes
161 int surfaceNum; // number of the static surface created for this mesh
163 void TransformVerts( idDrawVert *verts, const idJointMat *joints );
164 void TransformScaledVerts( idDrawVert *verts, const idJointMat *joints, float scale );
167 class idRenderModelMD5 : public idRenderModelStatic {
169 virtual void InitFromFile( const char *fileName );
170 virtual dynamicModel_t IsDynamicModel() const;
171 virtual idBounds Bounds( const struct renderEntity_s *ent ) const;
172 virtual void Print() const;
173 virtual void List() const;
174 virtual void TouchData();
175 virtual void PurgeModel();
176 virtual void LoadModel();
177 virtual int Memory() const;
178 virtual idRenderModel * InstantiateDynamicModel( const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel );
179 virtual int NumJoints( void ) const;
180 virtual const idMD5Joint * GetJoints( void ) const;
181 virtual jointHandle_t GetJointHandle( const char *name ) const;
182 virtual const char * GetJointName( jointHandle_t handle ) const;
183 virtual const idJointQuat * GetDefaultPose( void ) const;
184 virtual int NearestJoint( int surfaceNum, int a, int b, int c ) const;
187 idList<idMD5Joint> joints;
188 idList<idJointQuat> defaultPose;
189 idList<idMD5Mesh> meshes;
191 void CalculateBounds( const idJointMat *joints );
192 void GetFrameBounds( const renderEntity_t *ent, idBounds &bounds ) const;
193 void DrawJoints( const renderEntity_t *ent, const struct viewDef_s *view ) const;
194 void ParseJoint( idLexer &parser, idMD5Joint *joint, idJointQuat *defaultPose );
198 ===============================================================================
202 ===============================================================================
208 class idRenderModelMD3 : public idRenderModelStatic {
210 virtual void InitFromFile( const char *fileName );
211 virtual dynamicModel_t IsDynamicModel() const;
212 virtual idRenderModel * InstantiateDynamicModel( const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel );
213 virtual idBounds Bounds( const struct renderEntity_s *ent ) const;
216 int index; // model = tr.models[model->index]
217 int dataSize; // just for listing purposes
218 struct md3Header_s * md3; // only if type == MOD_MESH
221 void LerpMeshVertexes( srfTriangles_t *tri, const struct md3Surface_s *surf, const float backlerp, const int frame, const int oldframe ) const;
225 ===============================================================================
229 ===============================================================================
232 class idRenderModelLiquid : public idRenderModelStatic {
234 idRenderModelLiquid();
236 virtual void InitFromFile( const char *fileName );
237 virtual dynamicModel_t IsDynamicModel() const;
238 virtual idRenderModel * InstantiateDynamicModel( const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel );
239 virtual idBounds Bounds( const struct renderEntity_s *ent ) const;
241 virtual void Reset();
242 void IntersectBounds( const idBounds &bounds, float displacement );
245 modelSurface_t GenerateSurface( float lerp );
246 void WaterDrop( int x, int y, float *page );
260 const idMaterial * shader;
261 struct deformInfo_s * deformInfo; // used to create srfTriangles_t from base frames
273 idList<idDrawVert> verts;
280 ===============================================================================
284 ===============================================================================
287 class idRenderModelPrt : public idRenderModelStatic {
291 virtual void InitFromFile( const char *fileName );
292 virtual void TouchData();
293 virtual dynamicModel_t IsDynamicModel() const;
294 virtual idRenderModel * InstantiateDynamicModel( const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel );
295 virtual idBounds Bounds( const struct renderEntity_s *ent ) const;
296 virtual float DepthHack() const;
297 virtual int Memory() const;
300 const idDeclParticle * particleSystem;
304 ===============================================================================
308 ===============================================================================
311 class idRenderModelBeam : public idRenderModelStatic {
313 virtual dynamicModel_t IsDynamicModel() const;
314 virtual bool IsLoaded() const;
315 virtual idRenderModel * InstantiateDynamicModel( const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel );
316 virtual idBounds Bounds( const struct renderEntity_s *ent ) const;
320 ===============================================================================
324 ===============================================================================
326 #define MAX_TRAIL_PTS 20
332 idVec3 pts[MAX_TRAIL_PTS];
336 class idRenderModelTrail : public idRenderModelStatic {
337 idList<Trail_t> trails;
339 idBounds trailBounds;
342 idRenderModelTrail();
344 virtual dynamicModel_t IsDynamicModel() const;
345 virtual bool IsLoaded() const;
346 virtual idRenderModel * InstantiateDynamicModel( const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel );
347 virtual idBounds Bounds( const struct renderEntity_s *ent ) const;
349 int NewTrail( idVec3 pt, int duration );
350 void UpdateTrail( int index, idVec3 pt );
351 void DrawTrail( int index, const struct renderEntity_s *ent, srfTriangles_t *tri, float globalAlpha );
355 ===============================================================================
359 ===============================================================================
362 class idRenderModelLightning : public idRenderModelStatic {
364 virtual dynamicModel_t IsDynamicModel() const;
365 virtual bool IsLoaded() const;
366 virtual idRenderModel * InstantiateDynamicModel( const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel );
367 virtual idBounds Bounds( const struct renderEntity_s *ent ) const;
371 ================================================================================
375 ================================================================================
377 class idRenderModelSprite : public idRenderModelStatic {
379 virtual dynamicModel_t IsDynamicModel() const;
380 virtual bool IsLoaded() const;
381 virtual idRenderModel * InstantiateDynamicModel( const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel );
382 virtual idBounds Bounds( const struct renderEntity_s *ent ) const;
385 #endif /* !__MODEL_LOCAL_H__ */