home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / game / BrittleFracture.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  3KB  |  104 lines

  1.  
  2. #ifndef __GAME_BRITTLEFRACTURE_H__
  3. #define __GAME_BRITTLEFRACTURE_H__
  4.  
  5.  
  6. /*
  7. ===============================================================================
  8.  
  9. B-rep Brittle Fracture - Static entity using the boundary representation
  10. of the render model which can fracture.
  11.  
  12. ===============================================================================
  13. */
  14.  
  15. typedef struct shard_s {
  16.     idClipModel *                clipModel;
  17.     idFixedWinding                winding;
  18.     idList<idFixedWinding *>    decals;
  19.     idList<bool>                edgeHasNeighbour;
  20.     idList<struct shard_s *>    neighbours;
  21.     idPhysics_RigidBody            physicsObj;
  22.     int                            droppedTime;
  23.     bool                        atEdge;
  24.     int                            islandNum;
  25. } shard_t;
  26.  
  27.  
  28. class idBrittleFracture : public idEntity {
  29.  
  30. public:
  31.     CLASS_PROTOTYPE( idBrittleFracture );
  32.  
  33.                                 idBrittleFracture( void );
  34.     virtual                        ~idBrittleFracture( void );
  35.  
  36.     void                        Save( idSaveGame *savefile ) const;
  37.     void                        Restore( idRestoreGame *savefile );
  38.  
  39.     void                        Spawn( void );
  40.  
  41.     virtual void                Present( void );
  42.     virtual void                Think( void );
  43.     virtual void                ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse, bool splash = false );
  44.     virtual void                AddForce( idEntity *ent, int id, const idVec3 &point, const idVec3 &force );
  45.     virtual void                AddDamageEffect( const trace_t &collision, const idVec3 &velocity, const char *damageDefName, idEntity* inflictor );
  46.     virtual void                Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
  47.  
  48.     void                        ProjectDecal( const idVec3 &point, const idVec3 &dir, const int time, const char *damageDefName );
  49.     bool                        IsBroken( void ) const;
  50.  
  51.     enum {
  52.         EVENT_PROJECT_DECAL = idEntity::EVENT_MAXEVENTS,
  53.         EVENT_SHATTER,
  54.         EVENT_MAXEVENTS
  55.     };
  56.  
  57.     virtual void                ClientPredictionThink( void );
  58.     virtual bool                ClientReceiveEvent( int event, int time, const idBitMsg &msg );
  59.  
  60. private:
  61.     // setttings
  62.     const idMaterial *            material;
  63.     const idMaterial *            decalMaterial;
  64.     float                        decalSize;
  65.     float                        maxShardArea;
  66.     float                        maxShatterRadius;
  67.     float                        minShatterRadius;
  68.     float                        linearVelocityScale;
  69.     float                        angularVelocityScale;
  70.     float                        shardMass;
  71.     float                        density;
  72.     float                        friction;
  73.     float                        bouncyness;
  74.     idStr                        fxFracture;
  75.  
  76.     // state
  77.     idPhysics_StaticMulti        physicsObj;
  78.     idList<shard_t *>            shards;
  79.     idBounds                    bounds;
  80.     bool                        disableFracture;
  81.  
  82.     // for rendering
  83.     mutable int                    lastRenderEntityUpdate;
  84.     mutable bool                changed;
  85.  
  86.     bool                        UpdateRenderEntity( renderEntity_s *renderEntity, const renderView_t *renderView ) const;
  87.     static bool                    ModelCallback( renderEntity_s *renderEntity, const renderView_t *renderView );
  88.  
  89.     void                        AddShard( idClipModel *clipModel, idFixedWinding &w );
  90.     void                        RemoveShard( int index );
  91.     void                        DropShard( shard_t *shard, const idVec3 &point, const idVec3 &dir, const float impulse, const int time );
  92.     void                        Shatter( const idVec3 &point, const idVec3 &impulse, const int time );
  93.     void                        DropFloatingIslands( const idVec3 &point, const idVec3 &impulse, const int time );
  94.     void                        Break( void );
  95.     void                        Fracture_r( idFixedWinding &w );
  96.     void                        CreateFractures( const idRenderModel *renderModel );
  97.     void                        FindNeighbours( void );
  98.  
  99.     void                        Event_Activate( idEntity *activator );
  100.     void                        Event_Touch( idEntity *other, trace_t *trace );
  101. };
  102.  
  103. #endif /* !__GAME_BRITTLEFRACTURE_H__ */
  104.