doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Physics_Monster.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_MONSTER_H__
30 #define __PHYSICS_MONSTER_H__
31 
32 /*
33 ===================================================================================
34 
35  Monster physics
36 
37  Simulates the motion of a monster through the environment. The monster motion
38  is typically driven by animations.
39 
40 ===================================================================================
41 */
42 
43 typedef enum {
50 
51 typedef struct monsterPState_s {
52  int atRest;
53  bool onGround;
59 
61 
62 public:
64 
65  idPhysics_Monster( void );
66 
67  void Save( idSaveGame *savefile ) const;
68  void Restore( idRestoreGame *savefile );
69 
70  // maximum step up the monster can take, default 18 units
71  void SetMaxStepHeight( const float newMaxStepHeight );
72  float GetMaxStepHeight( void ) const;
73  // minimum cosine of floor angle to be able to stand on the floor
74  void SetMinFloorCosine( const float newMinFloorCosine );
75  // set delta for next move
76  void SetDelta( const idVec3 &d );
77  // returns true if monster is standing on the ground
78  bool OnGround( void ) const;
79  // returns the movement result
80  monsterMoveResult_t GetMoveResult( void ) const;
81  // overrides any velocity for pure delta movement
82  void ForceDeltaMove( bool force );
83  // whether velocity should be affected by gravity
84  void UseFlyMove( bool force );
85  // don't use delta movement
86  void UseVelocityMove( bool force );
87  // get entity blocking the move
88  idEntity * GetSlideMoveEntity( void ) const;
89  // enable/disable activation by impact
90  void EnableImpact( void );
91  void DisableImpact( void );
92 
93 public: // common physics interface
94  bool Evaluate( int timeStepMSec, int endTimeMSec );
95  void UpdateTime( int endTimeMSec );
96  int GetTime( void ) const;
97 
98  void GetImpactInfo( const int id, const idVec3 &point, impactInfo_t *info ) const;
99  void ApplyImpulse( const int id, const idVec3 &point, const idVec3 &impulse );
100  void Activate( void );
101  void PutToRest( void );
102  bool IsAtRest( void ) const;
103  int GetRestStartTime( void ) const;
104 
105  void SaveState( void );
106  void RestoreState( void );
107 
108  void SetOrigin( const idVec3 &newOrigin, int id = -1 );
109  void SetAxis( const idMat3 &newAxis, int id = -1 );
110 
111  void Translate( const idVec3 &translation, int id = -1 );
112  void Rotate( const idRotation &rotation, int id = -1 );
113 
114  void SetLinearVelocity( const idVec3 &newLinearVelocity, int id = 0 );
115 
116  const idVec3 & GetLinearVelocity( int id = 0 ) const;
117 
118  void SetPushed( int deltaTime );
119  const idVec3 & GetPushedLinearVelocity( const int id = 0 ) const;
120 
121  void SetMaster( idEntity *master, const bool orientated = true );
122 
123  void WriteToSnapshot( idBitMsgDelta &msg ) const;
124  void ReadFromSnapshot( const idBitMsgDelta &msg );
125 
126 private:
127  // monster physics state
130 
131  // properties
132  float maxStepHeight; // maximum step height
133  float minFloorCosine; // minimum cosine of floor angle
134  idVec3 delta; // delta for next move
135 
137  bool fly;
139  bool noImpact; // if true do not activate when another object collides
140 
141  // results of last evaluate
144 
145 private:
146  void CheckGround( monsterPState_t &state );
148  monsterMoveResult_t StepMove( idVec3 &start, idVec3 &velocity, const idVec3 &delta );
149  void Rest( void );
150 };
151 
152 #endif /* !__PHYSICS_MONSTER_H__ */
void UseFlyMove(bool force)
monsterMoveResult_t moveResult
CLASS_PROTOTYPE(idPhysics_Monster)
void SetAxis(const idMat3 &newAxis, int id=-1)
void SetMaxStepHeight(const float newMaxStepHeight)
bool Evaluate(int timeStepMSec, int endTimeMSec)
void ReadFromSnapshot(const idBitMsgDelta &msg)
void SetOrigin(const idVec3 &newOrigin, int id=-1)
Definition: Vector.h:316
void ApplyImpulse(const int id, const idVec3 &point, const idVec3 &impulse)
monsterMoveResult_t SlideMove(idVec3 &start, idVec3 &velocity, const idVec3 &delta)
void UseVelocityMove(bool force)
void SetDelta(const idVec3 &d)
const idVec3 & GetPushedLinearVelocity(const int id=0) const
int GetRestStartTime(void) const
float GetMaxStepHeight(void) const
void SetMinFloorCosine(const float newMinFloorCosine)
monsterMoveResult_t StepMove(idVec3 &start, idVec3 &velocity, const idVec3 &delta)
void Restore(idRestoreGame *savefile)
monsterMoveResult_t
void Rotate(const idRotation &rotation, int id=-1)
void UpdateTime(int endTimeMSec)
idEntity * blockingEntity
monsterPState_t current
void GetImpactInfo(const int id, const idVec3 &point, impactInfo_t *info) const
void SetPushed(int deltaTime)
void ForceDeltaMove(bool force)
void WriteToSnapshot(idBitMsgDelta &msg) const
void CheckGround(monsterPState_t &state)
Definition: Matrix.h:333
void Translate(const idVec3 &translation, int id=-1)
bool OnGround(void) const
void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)
monsterPState_t saved
monsterMoveResult_t GetMoveResult(void) const
idEntity * GetSlideMoveEntity(void) const
const idVec3 & GetLinearVelocity(int id=0) const
struct monsterPState_s monsterPState_t
void Save(idSaveGame *savefile) const
GLuint start
Definition: glext.h:2845
void SetMaster(idEntity *master, const bool orientated=true)
int GetTime(void) const
bool IsAtRest(void) const