doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Physics_Static.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 __PHYSICS_STATIC_H__
30 #define __PHYSICS_STATIC_H__
31 
32 /*
33 ===============================================================================
34 
35  Physics for a non moving object using at most one collision model.
36 
37 ===============================================================================
38 */
39 
40 typedef struct staticPState_s {
46 
47 class idPhysics_Static : public idPhysics {
48 
49 public:
51 
52  idPhysics_Static( void );
53  ~idPhysics_Static( void );
54 
55  void Save( idSaveGame *savefile ) const;
56  void Restore( idRestoreGame *savefile );
57 
58 public: // common physics interface
59  void SetSelf( idEntity *e );
60 
61  void SetClipModel( idClipModel *model, float density, int id = 0, bool freeOld = true );
62  idClipModel * GetClipModel( int id = 0 ) const;
63  int GetNumClipModels( void ) const;
64 
65  void SetMass( float mass, int id = -1 );
66  float GetMass( int id = -1 ) const;
67 
68  void SetContents( int contents, int id = -1 );
69  int GetContents( int id = -1 ) const;
70 
71  void SetClipMask( int mask, int id = -1 );
72  int GetClipMask( int id = -1 ) const;
73 
74  const idBounds & GetBounds( int id = -1 ) const;
75  const idBounds & GetAbsBounds( int id = -1 ) const;
76 
77  bool Evaluate( int timeStepMSec, int endTimeMSec );
78  void UpdateTime( int endTimeMSec );
79  int GetTime( void ) const;
80 
81  void GetImpactInfo( const int id, const idVec3 &point, impactInfo_t *info ) const;
82  void ApplyImpulse( const int id, const idVec3 &point, const idVec3 &impulse );
83  void AddForce( const int id, const idVec3 &point, const idVec3 &force );
84  void Activate( void );
85  void PutToRest( void );
86  bool IsAtRest( void ) const;
87  int GetRestStartTime( void ) const;
88  bool IsPushable( void ) const;
89 
90  void SaveState( void );
91  void RestoreState( void );
92 
93  void SetOrigin( const idVec3 &newOrigin, int id = -1 );
94  void SetAxis( const idMat3 &newAxis, int id = -1 );
95 
96  void Translate( const idVec3 &translation, int id = -1 );
97  void Rotate( const idRotation &rotation, int id = -1 );
98 
99  const idVec3 & GetOrigin( int id = 0 ) const;
100  const idMat3 & GetAxis( int id = 0 ) const;
101 
102  void SetLinearVelocity( const idVec3 &newLinearVelocity, int id = 0 );
103  void SetAngularVelocity( const idVec3 &newAngularVelocity, int id = 0 );
104 
105  const idVec3 & GetLinearVelocity( int id = 0 ) const;
106  const idVec3 & GetAngularVelocity( int id = 0 ) const;
107 
108  void SetGravity( const idVec3 &newGravity );
109  const idVec3 & GetGravity( void ) const;
110  const idVec3 & GetGravityNormal( void ) const;
111 
112  void ClipTranslation( trace_t &results, const idVec3 &translation, const idClipModel *model ) const;
113  void ClipRotation( trace_t &results, const idRotation &rotation, const idClipModel *model ) const;
114  int ClipContents( const idClipModel *model ) const;
115 
116  void DisableClip( void );
117  void EnableClip( void );
118 
119  void UnlinkClip( void );
120  void LinkClip( void );
121 
122  bool EvaluateContacts( void );
123  int GetNumContacts( void ) const;
124  const contactInfo_t & GetContact( int num ) const;
125  void ClearContacts( void );
126  void AddContactEntity( idEntity *e );
127  void RemoveContactEntity( idEntity *e );
128 
129  bool HasGroundContacts( void ) const;
130  bool IsGroundEntity( int entityNum ) const;
131  bool IsGroundClipModel( int entityNum, int id ) const;
132 
133  void SetPushed( int deltaTime );
134  const idVec3 & GetPushedLinearVelocity( const int id = 0 ) const;
135  const idVec3 & GetPushedAngularVelocity( const int id = 0 ) const;
136 
137  void SetMaster( idEntity *master, const bool orientated = true );
138 
139  const trace_t * GetBlockingInfo( void ) const;
140  idEntity * GetBlockingEntity( void ) const;
141 
142  int GetLinearEndTime( void ) const;
143  int GetAngularEndTime( void ) const;
144 
145  void WriteToSnapshot( idBitMsgDelta &msg ) const;
146  void ReadFromSnapshot( const idBitMsgDelta &msg );
147 
148 protected:
149  idEntity * self; // entity using this physics object
150  staticPState_t current; // physics state
151  idClipModel * clipModel; // collision model
152 
153  // master
154  bool hasMaster;
156 };
157 
158 #endif /* !__PHYSICS_STATIC_H__ */
const idVec3 & GetGravity(void) const
void Translate(const idVec3 &translation, int id=-1)
void SetClipMask(int mask, int id=-1)
void SetMaster(idEntity *master, const bool orientated=true)
void SetGravity(const idVec3 &newGravity)
void RestoreState(void)
bool HasGroundContacts(void) const
struct staticPState_s staticPState_t
void UpdateTime(int endTimeMSec)
void SetPushed(int deltaTime)
void RemoveContactEntity(idEntity *e)
GLenum GLint GLuint mask
Definition: glext.h:5864
void SetAxis(const idMat3 &newAxis, int id=-1)
void ApplyImpulse(const int id, const idVec3 &point, const idVec3 &impulse)
void SetSelf(idEntity *e)
const idVec3 & GetGravityNormal(void) const
bool IsAtRest(void) const
Definition: Vector.h:316
void SetContents(int contents, int id=-1)
const idVec3 & GetPushedLinearVelocity(const int id=0) const
int GetClipMask(int id=-1) const
const idVec3 & GetLinearVelocity(int id=0) const
GLuint GLuint num
Definition: glext.h:5390
const idBounds & GetBounds(int id=-1) const
bool Evaluate(int timeStepMSec, int endTimeMSec)
const idVec3 & GetOrigin(int id=0) const
idClipModel * GetClipModel(int id=0) const
bool EvaluateContacts(void)
void SetClipModel(idClipModel *model, float density, int id=0, bool freeOld=true)
int ClipContents(const idClipModel *model) const
void ClipRotation(trace_t &results, const idRotation &rotation, const idClipModel *model) const
void AddForce(const int id, const idVec3 &point, const idVec3 &force)
int GetTime(void) const
bool IsGroundEntity(int entityNum) const
void SetOrigin(const idVec3 &newOrigin, int id=-1)
idClipModel * clipModel
const idMat3 & GetAxis(int id=0) const
void SetAngularVelocity(const idVec3 &newAngularVelocity, int id=0)
void AddContactEntity(idEntity *e)
void Restore(idRestoreGame *savefile)
int GetRestStartTime(void) const
staticPState_t current
void ReadFromSnapshot(const idBitMsgDelta &msg)
const idBounds & GetAbsBounds(int id=-1) const
void SetMass(float mass, int id=-1)
const idVec3 & GetAngularVelocity(int id=0) const
void DisableClip(void)
int GetLinearEndTime(void) const
Definition: Matrix.h:333
const trace_t * GetBlockingInfo(void) const
float GetMass(int id=-1) const
void ClipTranslation(trace_t &results, const idVec3 &translation, const idClipModel *model) const
bool IsPushable(void) const
void WriteToSnapshot(idBitMsgDelta &msg) const
void Rotate(const idRotation &rotation, int id=-1)
void GetImpactInfo(const int id, const idVec3 &point, impactInfo_t *info) const
void ClearContacts(void)
int GetContents(int id=-1) const
bool IsGroundClipModel(int entityNum, int id) const
const idVec3 & GetPushedAngularVelocity(const int id=0) const
void Save(idSaveGame *savefile) const
void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)
int GetNumClipModels(void) const
const contactInfo_t & GetContact(int num) const
idEntity * GetBlockingEntity(void) const
int GetNumContacts(void) const
CLASS_PROTOTYPE(idPhysics_Static)
int GetAngularEndTime(void) const