doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ModelDecal.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
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.
13 
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.
18 
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/>.
21 
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.
23 
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.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __MODELDECAL_H__
30 #define __MODELDECAL_H__
31 
32 /*
33 ===============================================================================
34 
35  Decals are lightweight primitives for bullet / blood marks.
36  Decals with common materials will be merged together, but additional
37  decals will be allocated as needed. The material should not be
38  one that receives lighting, because no interactions are generated
39  for these lightweight surfaces.
40 
41  FIXME: Decals on models in portalled off areas do not get freed
42  until the area becomes visible again.
43 
44 ===============================================================================
45 */
46 
48 
49 typedef struct decalProjectionInfo_s {
56  bool parallel;
57  float fadeDepth;
58  int startTime;
59  bool force;
61 
62 
64 public:
65  idRenderModelDecal( void );
66  ~idRenderModelDecal( void );
67 
68  static idRenderModelDecal * Alloc( void );
69  static void Free( idRenderModelDecal *decal );
70 
71  // Creates decal projection info.
72  static bool CreateProjectionInfo( decalProjectionInfo_t &info, const idFixedWinding &winding, const idVec3 &projectionOrigin, const bool parallel, const float fadeDepth, const idMaterial *material, const int startTime );
73 
74  // Transform the projection info from global space to local.
75  static void GlobalProjectionInfoToLocal( decalProjectionInfo_t &localInfo, const decalProjectionInfo_t &info, const idVec3 &origin, const idMat3 &axis );
76 
77  // Creates a deal on the given model.
78  void CreateDecal( const idRenderModel *model, const decalProjectionInfo_t &localInfo );
79 
80  // Remove decals that are completely faded away.
81  static idRenderModelDecal * RemoveFadedDecals( idRenderModelDecal *decals, int time );
82 
83  // Updates the vertex colors, removing any faded indexes,
84  // then copy the verts to temporary vertex cache and adds a drawSurf.
85  void AddDecalDrawSurf( struct viewEntity_s *space );
86 
87  // Returns the next decal in the chain.
88  idRenderModelDecal * Next( void ) const { return nextDecal; }
89 
90  void ReadFromDemoFile( class idDemoFile *f );
91  void WriteToDemoFile( class idDemoFile *f ) const;
92 
93 private:
94  static const int MAX_DECAL_VERTS = 40;
95  static const int MAX_DECAL_INDEXES = 60;
96 
104 
105  // Adds the winding triangles to the appropriate decal in the
106  // chain, creating a new one if necessary.
107  void AddWinding( const idWinding &w, const idMaterial *decalMaterial, const idPlane fadePlanes[2], float fadeDepth, int startTime );
108 
109  // Adds depth faded triangles for the winding to the appropriate
110  // decal in the chain, creating a new one if necessary.
111  // The part of the winding at the front side of both fade planes is not faded.
112  // The parts at the back sides of the fade planes are faded with the given depth.
113  void AddDepthFadedWinding( const idWinding &w, const idMaterial *decalMaterial, const idPlane fadePlanes[2], float fadeDepth, int startTime );
114 };
115 
116 #endif /* !__MODELDECAL_H__ */
idBounds projectionBounds
Definition: ModelDecal.h:51
void ReadFromDemoFile(class idDemoFile *f)
Definition: ModelDecal.cpp:526
static bool CreateProjectionInfo(decalProjectionInfo_t &info, const idFixedWinding &winding, const idVec3 &projectionOrigin, const bool parallel, const float fadeDepth, const idMaterial *material, const int startTime)
Definition: ModelDecal.cpp:88
int indexStartTime[MAX_DECAL_INDEXES]
Definition: ModelDecal.h:102
Definition: Vector.h:316
void AddDepthFadedWinding(const idWinding &w, const idMaterial *decalMaterial, const idPlane fadePlanes[2], float fadeDepth, int startTime)
Definition: ModelDecal.cpp:275
srfTriangles_t tri
Definition: ModelDecal.h:98
static const int MAX_DECAL_INDEXES
Definition: ModelDecal.h:95
const idMaterial * material
Definition: ModelDecal.h:97
const int NUM_DECAL_BOUNDING_PLANES
Definition: ModelDecal.h:47
idPlane boundingPlanes[6]
Definition: ModelDecal.h:52
void WriteToDemoFile(class idDemoFile *f) const
Definition: ModelDecal.cpp:535
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:3454
static const int MAX_DECAL_VERTS
Definition: ModelDecal.h:94
const idMaterial * material
Definition: ModelDecal.h:55
void AddWinding(const idWinding &w, const idMaterial *decalMaterial, const idPlane fadePlanes[2], float fadeDepth, int startTime)
Definition: ModelDecal.cpp:209
int glIndex_t
Definition: Model.h:52
Definition: Plane.h:71
idPlane fadePlanes[2]
Definition: ModelDecal.h:53
void AddDecalDrawSurf(struct viewEntity_s *space)
Definition: ModelDecal.cpp:464
static idRenderModelDecal * RemoveFadedDecals(idRenderModelDecal *decals, int time)
Definition: ModelDecal.cpp:389
float vertDepthFade[MAX_DECAL_VERTS]
Definition: ModelDecal.h:100
Definition: Matrix.h:333
tuple f
Definition: idal.py:89
void CreateDecal(const idRenderModel *model, const decalProjectionInfo_t &localInfo)
Definition: ModelDecal.cpp:295
idRenderModelDecal * Next(void) const
Definition: ModelDecal.h:88
struct decalProjectionInfo_s decalProjectionInfo_t
static idRenderModelDecal * Alloc(void)
Definition: ModelDecal.cpp:70
static void GlobalProjectionInfoToLocal(decalProjectionInfo_t &localInfo, const decalProjectionInfo_t &info, const idVec3 &origin, const idMat3 &axis)
Definition: ModelDecal.cpp:181
idDrawVert verts[MAX_DECAL_VERTS]
Definition: ModelDecal.h:99
glIndex_t indexes[MAX_DECAL_INDEXES]
Definition: ModelDecal.h:101
idRenderModelDecal * nextDecal
Definition: ModelDecal.h:103
idPlane textureAxis[2]
Definition: ModelDecal.h:54
static void Free(idRenderModelDecal *decal)
Definition: ModelDecal.cpp:79