doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BrittleFracture.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 __GAME_BRITTLEFRACTURE_H__
30 #define __GAME_BRITTLEFRACTURE_H__
31 
32 
33 /*
34 ===============================================================================
35 
36 B-rep Brittle Fracture - Static entity using the boundary representation
37 of the render model which can fracture.
38 
39 ===============================================================================
40 */
41 
42 typedef struct shard_s {
50  bool atEdge;
51  int islandNum;
52 } shard_t;
53 
54 
55 class idBrittleFracture : public idEntity {
56 
57 public:
59 
60  idBrittleFracture( void );
61  virtual ~idBrittleFracture( void );
62 
63  void Save( idSaveGame *savefile ) const;
64  void Restore( idRestoreGame *savefile );
65 
66  void Spawn( void );
67 
68  virtual void Present( void );
69  virtual void Think( void );
70  virtual void ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse );
71  virtual void AddForce( idEntity *ent, int id, const idVec3 &point, const idVec3 &force );
72  virtual void AddDamageEffect( const trace_t &collision, const idVec3 &velocity, const char *damageDefName );
73  virtual void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
74 
75  void ProjectDecal( const idVec3 &point, const idVec3 &dir, const int time, const char *damageDefName );
76  bool IsBroken( void ) const;
77 
78  enum {
82  };
83 
84  virtual void ClientPredictionThink( void );
85  virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
86 
87 private:
88  // setttings
91  float decalSize;
92  float maxShardArea;
97  float shardMass;
98  float density;
99  float friction;
100  float bouncyness;
102 
103 #ifdef _D3XP
104  bool isXraySurface;
105 #endif
106 
107  // state
112 
113  // for rendering
115  mutable bool changed;
116 
119 
120  void AddShard( idClipModel *clipModel, idFixedWinding &w );
121  void RemoveShard( int index );
122  void DropShard( shard_t *shard, const idVec3 &point, const idVec3 &dir, const float impulse, const int time );
123  void Shatter( const idVec3 &point, const idVec3 &impulse, const int time );
124  void DropFloatingIslands( const idVec3 &point, const idVec3 &impulse, const int time );
125  void Break( void );
126  void Fracture_r( idFixedWinding &w );
127  void CreateFractures( const idRenderModel *renderModel );
128  void FindNeighbours( void );
129 
130  void Event_Activate( idEntity *activator );
131  void Event_Touch( idEntity *other, trace_t *trace );
132 };
133 
134 #endif /* !__GAME_BRITTLEFRACTURE_H__ */
CLASS_PROTOTYPE(idBrittleFracture)
virtual ~idBrittleFracture(void)
renderEntity_t renderEntity
Definition: Entity.h:371
idList< bool > edgeHasNeighbour
bool UpdateRenderEntity(renderEntity_s *renderEntity, const renderView_t *renderView) const
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
void RemoveShard(int index)
GLint location
Definition: glext.h:3631
virtual void AddForce(idEntity *ent, int id, const idVec3 &point, const idVec3 &force)
Definition: Vector.h:316
void Event_Touch(idEntity *other, trace_t *trace)
idPhysics_StaticMulti physicsObj
bool IsBroken(void) const
idPhysics_RigidBody physicsObj
virtual void ClientPredictionThink(void)
void Restore(idRestoreGame *savefile)
GLuint index
Definition: glext.h:3476
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:3454
void Shatter(const idVec3 &point, const idVec3 &impulse, const int time)
idList< idFixedWinding * > decals
virtual void Think(void)
virtual void Present(void)
void Fracture_r(idFixedWinding &w)
static bool ModelCallback(renderEntity_s *renderEntity, const renderView_t *renderView)
struct shard_s shard_t
idClipModel * clipModel
void ProjectDecal(const idVec3 &point, const idVec3 &dir, const int time, const char *damageDefName)
idFixedWinding winding
void DropFloatingIslands(const idVec3 &point, const idVec3 &impulse, const int time)
renderView_t * renderView
Definition: Entity.h:129
void AddShard(idClipModel *clipModel, idFixedWinding &w)
const idMaterial * decalMaterial
const idMaterial * material
virtual void Killed(idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location)
idList< shard_t * > shards
Definition: Str.h:116
int droppedTime
idList< struct shard_s * > neighbours
virtual void ApplyImpulse(idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse)
void Event_Activate(idEntity *activator)
void CreateFractures(const idRenderModel *renderModel)
virtual void AddDamageEffect(const trace_t &collision, const idVec3 &velocity, const char *damageDefName)
void DropShard(shard_t *shard, const idVec3 &point, const idVec3 &dir, const float impulse, const int time)
void Save(idSaveGame *savefile) const