doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AF.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_AF_H__
30 #define __GAME_AF_H__
31 
32 
33 /*
34 ===============================================================================
35 
36  Articulated figure controller.
37 
38 ===============================================================================
39 */
40 
41 typedef struct jointConversion_s {
42  int bodyId; // id of the body
43  jointHandle_t jointHandle; // handle of joint this body modifies
44  AFJointModType_t jointMod; // modify joint axis, origin or both
45  idVec3 jointBodyOrigin; // origin of body relative to joint
46  idMat3 jointBodyAxis; // axis of body relative to joint
48 
49 typedef struct afTouch_s {
53 } afTouch_t;
54 
55 class idAF {
56 public:
57  idAF( void );
58  ~idAF( void );
59 
60  void Save( idSaveGame *savefile ) const;
61  void Restore( idRestoreGame *savefile );
62 
63  void SetAnimator( idAnimator *a ) { animator = a; }
64  bool Load( idEntity *ent, const char *fileName );
65  bool IsLoaded( void ) const { return isLoaded && self != NULL; }
66  const char * GetName( void ) const { return name.c_str(); }
67  void SetupPose( idEntity *ent, int time );
68  void ChangePose( idEntity *ent, int time );
69  int EntitiesTouchingAF( afTouch_t touchList[ MAX_GENTITIES ] ) const;
70  void Start( void );
71  void StartFromCurrentPose( int inheritVelocityTime );
72  void Stop( void );
73  void Rest( void );
74  bool IsActive( void ) const { return isActive; }
75  void SetConstraintPosition( const char *name, const idVec3 &pos );
76 
77  idPhysics_AF * GetPhysics( void ) { return &physicsObj; }
78  const idPhysics_AF * GetPhysics( void ) const { return &physicsObj; }
79  idBounds GetBounds( void ) const;
80  bool UpdateAnimation( void );
81 
82  void GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis ) const;
83  void GetImpactInfo( idEntity *ent, int id, const idVec3 &point, impactInfo_t *info );
84  void ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse );
85  void AddForce( idEntity *ent, int id, const idVec3 &point, const idVec3 &force );
86  int BodyForClipModelId( int id ) const;
87 
88  void SaveState( idDict &args ) const;
89  void LoadState( const idDict &args );
90 
91  void AddBindConstraints( void );
92  void RemoveBindConstraints( void );
93 
94 protected:
95  idStr name; // name of the loaded .af file
96  idPhysics_AF physicsObj; // articulated figure physics
97  idEntity * self; // entity using the animated model
98  idAnimator * animator; // animator on entity
99  int modifiedAnim; // anim to modify
100  idVec3 baseOrigin; // offset of base body relative to skeletal model origin
101  idMat3 baseAxis; // axis of base body relative to skeletal model origin
102  idList<jointConversion_t>jointMods; // list with transforms from skeletal model joints to articulated figure bodies
103  idList<int> jointBody; // table to find the nearest articulated figure body for a joint of the skeletal model
104  int poseTime; // last time the articulated figure was transformed to reflect the current animation pose
105  int restStartTime; // time the articulated figure came to rest
106  bool isLoaded; // true when the articulated figure is properly loaded
107  bool isActive; // true if the articulated figure physics is active
108  bool hasBindConstraints; // true if the bind constraints have been added
109 
110 protected:
111  void SetBase( idAFBody *body, const idJointMat *joints );
112  void AddBody( idAFBody *body, const idJointMat *joints, const char *jointName, const AFJointModType_t mod );
113 
114  bool LoadBody( const idDeclAF_Body *fb, const idJointMat *joints );
115  bool LoadConstraint( const idDeclAF_Constraint *fc );
116 
117  bool TestSolid( void ) const;
118 };
119 
120 #endif /* !__GAME_AF_H__ */
jointHandle_t
Definition: Model.h:156
void SetupPose(idEntity *ent, int time)
Definition: AF.cpp:231
int bodyId
Definition: AF.h:42
Definition: AF.h:55
AFJointModType_t
Definition: Anim.h:457
void Stop(void)
Definition: AF.cpp:1042
#define MAX_GENTITIES
Definition: Game_local.h:83
void ChangePose(idEntity *ent, int time)
Definition: AF.cpp:284
void LoadState(const idDict &args)
Definition: AF.cpp:1128
idBounds GetBounds(void) const
Definition: AF.cpp:195
bool UpdateAnimation(void)
Definition: AF.cpp:137
idAnimator * animator
Definition: AF.h:98
idClipModel * touchedClipModel
Definition: AF.h:51
struct jointConversion_s jointConversion_t
idList< int > jointBody
Definition: AF.h:103
int BodyForClipModelId(int id) const
Definition: AF.cpp:386
void AddBindConstraints(void)
Definition: AF.cpp:1160
Definition: Vector.h:316
idPhysics_AF * GetPhysics(void)
Definition: AF.h:77
void Start(void)
Definition: AF.cpp:941
int restStartTime
Definition: AF.h:105
void SetAnimator(idAnimator *a)
Definition: AF.h:63
void RemoveBindConstraints(void)
Definition: AF.cpp:1248
void Restore(idRestoreGame *savefile)
Definition: AF.cpp:94
bool Load(idEntity *ent, const char *fileName)
Definition: AF.cpp:795
void GetPhysicsToVisualTransform(idVec3 &origin, idMat3 &axis) const
Definition: AF.cpp:404
void AddForce(idEntity *ent, int id, const idVec3 &point, const idVec3 &force)
Definition: AF.cpp:434
struct afTouch_s afTouch_t
void Rest(void)
Definition: AF.cpp:1053
idList< jointConversion_t > jointMods
Definition: AF.h:102
int modifiedAnim
Definition: AF.h:99
idPhysics_AF physicsObj
Definition: AF.h:96
bool TestSolid(void) const
Definition: AF.cpp:961
void GetImpactInfo(idEntity *ent, int id, const idVec3 &point, impactInfo_t *info)
Definition: AF.cpp:414
bool hasBindConstraints
Definition: AF.h:108
int EntitiesTouchingAF(afTouch_t touchList[MAX_GENTITIES]) const
Definition: AF.cpp:336
void SetConstraintPosition(const char *name, const idVec3 &pos)
Definition: AF.cpp:1064
void SetBase(idAFBody *body, const idJointMat *joints)
Definition: AF.cpp:477
AFJointModType_t jointMod
Definition: AF.h:44
idVec3 baseOrigin
Definition: AF.h:100
Definition: AF.h:49
Definition: Dict.h:65
#define NULL
Definition: Lib.h:88
~idAF(void)
Definition: AF.cpp:68
int poseTime
Definition: AF.h:104
idEntity * touchedEnt
Definition: AF.h:50
GLubyte GLubyte GLubyte a
Definition: glext.h:4662
bool isLoaded
Definition: AF.h:106
idVec3 jointBodyOrigin
Definition: AF.h:45
bool IsLoaded(void) const
Definition: AF.h:65
Definition: Matrix.h:333
bool LoadConstraint(const idDeclAF_Constraint *fc)
Definition: AF.cpp:621
void StartFromCurrentPose(int inheritVelocityTime)
Definition: AF.cpp:999
const idPhysics_AF * GetPhysics(void) const
Definition: AF.h:78
idMat3 baseAxis
Definition: AF.h:101
const GLcharARB * name
Definition: glext.h:3629
void Save(idSaveGame *savefile) const
Definition: AF.cpp:76
Definition: Str.h:116
idStr name
Definition: AF.h:95
idAFBody * touchedByBody
Definition: AF.h:52
void ApplyImpulse(idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse)
Definition: AF.cpp:424
idAF(void)
Definition: AF.cpp:50
void SaveState(idDict &args) const
Definition: AF.cpp:1107
Definition: List.h:84
const char * GetName(void) const
Definition: AF.h:66
bool IsActive(void) const
Definition: AF.h:74
jointHandle_t jointHandle
Definition: AF.h:43
bool isActive
Definition: AF.h:107
void AddBody(idAFBody *body, const idJointMat *joints, const char *jointName, const AFJointModType_t mod)
Definition: AF.cpp:446
bool LoadBody(const idDeclAF_Body *fb, const idJointMat *joints)
Definition: AF.cpp:489
idMat3 jointBodyAxis
Definition: AF.h:46