doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Physics_Actor.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_ACTOR_H__
30 #define __PHYSICS_ACTOR_H__
31 
32 /*
33 ===================================================================================
34 
35  Actor physics base class
36 
37  An actor typically uses one collision model which is aligned with the gravity
38  direction. The collision model is usually a simple box with the origin at the
39  bottom center.
40 
41 ===================================================================================
42 */
43 
45 
46 public:
48 
49  idPhysics_Actor( void );
50  ~idPhysics_Actor( void );
51 
52  void Save( idSaveGame *savefile ) const;
53  void Restore( idRestoreGame *savefile );
54 
55  // get delta yaw of master
56  float GetMasterDeltaYaw( void ) const;
57  // returns the ground entity
58  idEntity * GetGroundEntity( void ) const;
59  // align the clip model with the gravity direction
60  void SetClipModelAxis( void );
61 
62 public: // common physics interface
63  void SetClipModel( idClipModel *model, float density, int id = 0, bool freeOld = true );
64  idClipModel * GetClipModel( int id = 0 ) const;
65  int GetNumClipModels( void ) const;
66 
67  void SetMass( float mass, int id = -1 );
68  float GetMass( int id = -1 ) const;
69 
70  void SetContents( int contents, int id = -1 );
71  int GetContents( int id = -1 ) const;
72 
73  const idBounds & GetBounds( int id = -1 ) const;
74  const idBounds & GetAbsBounds( int id = -1 ) const;
75 
76  bool IsPushable( void ) const;
77 
78  const idVec3 & GetOrigin( int id = 0 ) const;
79  const idMat3 & GetAxis( int id = 0 ) const;
80 
81  void SetGravity( const idVec3 &newGravity );
82  const idMat3 & GetGravityAxis( void ) const;
83 
84  void ClipTranslation( trace_t &results, const idVec3 &translation, const idClipModel *model ) const;
85  void ClipRotation( trace_t &results, const idRotation &rotation, const idClipModel *model ) const;
86  int ClipContents( const idClipModel *model ) const;
87 
88  void DisableClip( void );
89  void EnableClip( void );
90 
91  void UnlinkClip( void );
92  void LinkClip( void );
93 
94  bool EvaluateContacts( void );
95 
96 protected:
97  idClipModel * clipModel; // clip model used for collision detection
98  idMat3 clipModelAxis; // axis of clip model aligned with gravity direction
99 
100  // derived properties
101  float mass;
102  float invMass;
103 
104  // master
106  float masterYaw;
108 
109  // results of last evaluate
111 };
112 
113 #endif /* !__PHYSICS_ACTOR_H__ */
void SetClipModel(idClipModel *model, float density, int id=0, bool freeOld=true)
int GetContents(int id=-1) const
bool EvaluateContacts(void)
void SetMass(float mass, int id=-1)
void Save(idSaveGame *savefile) const
void LinkClip(void)
void DisableClip(void)
Definition: Vector.h:316
void ClipRotation(trace_t &results, const idRotation &rotation, const idClipModel *model) const
const idVec3 & GetOrigin(int id=0) const
CLASS_PROTOTYPE(idPhysics_Actor)
void SetContents(int contents, int id=-1)
idClipModel * GetClipModel(int id=0) const
bool IsPushable(void) const
void SetClipModelAxis(void)
void UnlinkClip(void)
void ClipTranslation(trace_t &results, const idVec3 &translation, const idClipModel *model) const
idEntity * masterEntity
idMat3 clipModelAxis
Definition: Physics_Actor.h:98
const idBounds & GetAbsBounds(int id=-1) const
const idMat3 & GetAxis(int id=0) const
float GetMasterDeltaYaw(void) const
int ClipContents(const idClipModel *model) const
Definition: Matrix.h:333
idEntity * GetGroundEntity(void) const
void SetGravity(const idVec3 &newGravity)
float GetMass(int id=-1) const
idEntityPtr< idEntity > groundEntityPtr
idClipModel * clipModel
Definition: Physics_Actor.h:97
const idMat3 & GetGravityAxis(void) const
void Restore(idRestoreGame *savefile)
const idBounds & GetBounds(int id=-1) const
void EnableClip(void)
int GetNumClipModels(void) const