doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DeclAF.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 __DECLAF_H__
30 #define __DECLAF_H__
31 
32 /*
33 ===============================================================================
34 
35  Articulated Figure
36 
37 ===============================================================================
38 */
39 
40 class idDeclAF;
41 
42 typedef enum {
51 
52 typedef enum {
57 
58 typedef bool (*getJointTransform_t)( void *model, const idJointMat *frame, const char *jointName, idVec3 &origin, idMat3 &axis );
59 
60 class idAFVector {
61 public:
62  enum {
67  } type;
70 
71 public:
72  idAFVector( void );
73 
74  bool Parse( idLexer &src );
75  bool Finish( const char *fileName, const getJointTransform_t GetJointTransform, const idJointMat *frame, void *model ) const;
76  bool Write( idFile *f ) const;
77  const char * ToString( idStr &str, const int precision = 8 );
78  const idVec3 & ToVec3( void ) const { return vec; }
79  idVec3 & ToVec3( void ) { return vec; }
80 
81 private:
82  mutable idVec3 vec;
83  bool negate;
84 };
85 
87 public:
91  int modelType;
93  int numSides;
94  float width;
95  float density;
98  int contents;
99  int clipMask;
108 public:
109  void SetDefault( const idDeclAF *file );
110 };
111 
113 public:
118  float friction;
119  float stretch;
120  float compress;
121  float damping;
122  float restLength;
123  float minLength;
124  float maxLength;
129  enum {
133  } limit;
135  float limitAngles[3];
136 
137 public:
138  void SetDefault( const idDeclAF *file );
139 };
140 
141 class idDeclAF : public idDecl {
142  friend class idAFFileManager;
143 public:
144  idDeclAF( void );
145  virtual ~idDeclAF( void );
146 
147  virtual size_t Size( void ) const;
148  virtual const char * DefaultDefinition( void ) const;
149  virtual bool Parse( const char *text, const int textLength );
150  virtual void FreeData( void );
151 
152  virtual void Finish( const getJointTransform_t GetJointTransform, const idJointMat *frame, void *model ) const;
153 
154  bool Save( void );
155 
156  void NewBody( const char *name );
157  void RenameBody( const char *oldName, const char *newName );
158  void DeleteBody( const char *name );
159 
160  void NewConstraint( const char *name );
161  void RenameConstraint( const char *oldName, const char *newName );
162  void DeleteConstraint( const char *name );
163 
164  static int ContentsFromString( const char *str );
165  static const char * ContentsToString( const int contents, idStr &str );
166 
167  static declAFJointMod_t JointModFromString( const char *str );
168  static const char * JointModToString( declAFJointMod_t jointMod );
169 
170 public:
171  bool modified;
178  float totalMass;
181  float noMoveTime;
184  float minMoveTime;
185  float maxMoveTime;
186  int contents;
187  int clipMask;
191 
192 private:
193  bool ParseContents( idLexer &src, int &c ) const;
194  bool ParseBody( idLexer &src );
195  bool ParseFixed( idLexer &src );
198  bool ParseHinge( idLexer &src );
199  bool ParseSlider( idLexer &src );
200  bool ParseSpring( idLexer &src );
201  bool ParseSettings( idLexer &src );
202 
203  bool WriteBody( idFile *f, const idDeclAF_Body &body ) const;
204  bool WriteFixed( idFile *f, const idDeclAF_Constraint &c ) const;
205  bool WriteBallAndSocketJoint( idFile *f, const idDeclAF_Constraint &c ) const;
206  bool WriteUniversalJoint( idFile *f, const idDeclAF_Constraint &c ) const;
207  bool WriteHinge( idFile *f, const idDeclAF_Constraint &c ) const;
208  bool WriteSlider( idFile *f, const idDeclAF_Constraint &c ) const;
209  bool WriteSpring( idFile *f, const idDeclAF_Constraint &c ) const;
210  bool WriteConstraint( idFile *f, const idDeclAF_Constraint &c ) const;
211  bool WriteSettings( idFile *f ) const;
212 
213  bool RebuildTextSource( void );
214 };
215 
216 #endif /* !__DECLAF_H__ */
idDeclAF(void)
Definition: DeclAF.cpp:1733
idAFVector contactMotorDirection
Definition: DeclAF.h:107
bool Write(idFile *f) const
Definition: DeclAF.cpp:179
idList< idDeclAF_Constraint * > constraints
Definition: DeclAF.h:190
float defaultLinearFriction
Definition: DeclAF.h:174
float noMoveTime
Definition: DeclAF.h:181
void DeleteBody(const char *name)
Definition: DeclAF.cpp:1661
idAFVector anchor
Definition: DeclAF.h:125
bool ParseHinge(idLexer &src)
Definition: DeclAF.cpp:1166
declAFConstraintType_t type
Definition: DeclAF.h:117
bool WriteBallAndSocketJoint(idFile *f, const idDeclAF_Constraint &c) const
Definition: DeclAF.cpp:419
static int ContentsFromString(const char *str)
Definition: DeclAF.cpp:653
virtual void Finish(const getJointTransform_t GetJointTransform, const idJointMat *frame, void *model) const
Definition: DeclAF.cpp:1590
bool ParseSettings(idLexer &src)
Definition: DeclAF.cpp:1340
declAFConstraintType_t
Definition: DeclAF.h:42
virtual ~idDeclAF(void)
Definition: DeclAF.cpp:1742
float noMoveTranslation
Definition: DeclAF.h:182
void SetDefault(const idDeclAF *file)
Definition: DeclAF.cpp:249
float density
Definition: DeclAF.h:95
idStr name
Definition: DeclAF.h:88
bool Parse(idLexer &src)
Definition: DeclAF.cpp:56
virtual const char * DefaultDefinition(void) const
Definition: DeclAF.cpp:1526
idAFVector(void)
Definition: DeclAF.cpp:45
bool modified
Definition: DeclAF.h:171
int contents
Definition: DeclAF.h:186
int modelType
Definition: DeclAF.h:91
Definition: Vector.h:316
float totalMass
Definition: DeclAF.h:178
bool ParseBody(idLexer &src)
Definition: DeclAF.cpp:793
virtual size_t Size(void) const
Definition: DeclAF.cpp:764
bool ParseUniversalJoint(idLexer &src)
Definition: DeclAF.cpp:1088
idAFVector frictionDirection
Definition: DeclAF.h:106
idStr containedJoints
Definition: DeclAF.h:105
idVec3 vec
Definition: DeclAF.h:82
GLuint src
Definition: glext.h:5390
float width
Definition: DeclAF.h:94
bool WriteSettings(idFile *f) const
Definition: DeclAF.cpp:575
void DeleteConstraint(const char *name)
Definition: DeclAF.cpp:1716
declAFJointMod_t jointMod
Definition: DeclAF.h:90
bool WriteHinge(idFile *f, const idDeclAF_Constraint &c) const
Definition: DeclAF.cpp:482
void NewConstraint(const char *name)
Definition: DeclAF.cpp:1686
idAFVector v2
Definition: DeclAF.h:92
Definition: File.h:50
friend class idAFFileManager
Definition: DeclAF.h:142
bool WriteFixed(idFile *f, const idDeclAF_Constraint &c) const
Definition: DeclAF.cpp:406
declAFJointMod_t
Definition: DeclAF.h:52
Definition: Lexer.h:137
float minMoveTime
Definition: DeclAF.h:184
idStr skin
Definition: DeclAF.h:173
idStr joint1
Definition: DeclAF.h:68
Definition: Vector.h:52
int clipMask
Definition: DeclAF.h:187
const idVec3 & ToVec3(void) const
Definition: DeclAF.h:78
void NewBody(const char *name)
Definition: DeclAF.cpp:1618
const GLubyte * c
Definition: glext.h:4677
idVec3 & ToVec3(void)
Definition: DeclAF.h:79
virtual void FreeData(void)
Definition: DeclAF.cpp:1564
int contents
Definition: DeclAF.h:98
bool WriteUniversalJoint(idFile *f, const idDeclAF_Constraint &c) const
Definition: DeclAF.cpp:450
idAngles angles
Definition: DeclAF.h:97
static declAFJointMod_t JointModFromString(const char *str)
Definition: DeclAF.cpp:726
idAFVector axis
Definition: DeclAF.h:128
float defaultContactFriction
Definition: DeclAF.h:176
idAFVector anchor2
Definition: DeclAF.h:126
bool ParseBallAndSocketJoint(idLexer &src)
Definition: DeclAF.cpp:1009
bool Save(void)
Definition: DeclAF.cpp:641
bool ParseSpring(idLexer &src)
Definition: DeclAF.cpp:1277
int numSides
Definition: DeclAF.h:93
static const char * ContentsToString(const int contents, idStr &str)
Definition: DeclAF.cpp:693
void RenameConstraint(const char *oldName, const char *newName)
Definition: DeclAF.cpp:1700
bool ParseFixed(idLexer &src)
Definition: DeclAF.cpp:970
idStr jointName
Definition: DeclAF.h:89
bool WriteSpring(idFile *f, const idDeclAF_Constraint &c) const
Definition: DeclAF.cpp:524
idAFVector v1
Definition: DeclAF.h:92
bool WriteBody(idFile *f, const idDeclAF_Body &body) const
Definition: DeclAF.cpp:307
float noMoveRotation
Definition: DeclAF.h:183
bool ParseContents(idLexer &src, int &c) const
Definition: DeclAF.cpp:773
float linearFriction
Definition: DeclAF.h:102
float angularFriction
Definition: DeclAF.h:103
float maxMoveTime
Definition: DeclAF.h:185
idAFVector limitAxis
Definition: DeclAF.h:134
idVec2 suspendVelocity
Definition: DeclAF.h:179
Definition: Matrix.h:333
float defaultConstraintFriction
Definition: DeclAF.h:177
idAFVector origin
Definition: DeclAF.h:96
bool WriteConstraint(idFile *f, const idDeclAF_Constraint &c) const
Definition: DeclAF.cpp:550
bool negate
Definition: DeclAF.h:83
float limitAngles[3]
Definition: DeclAF.h:135
idVec2 suspendAcceleration
Definition: DeclAF.h:180
idMat3 inertiaScale
Definition: DeclAF.h:101
idList< idDeclAF_Body * > bodies
Definition: DeclAF.h:189
tuple f
Definition: idal.py:89
float contactFriction
Definition: DeclAF.h:104
idStr model
Definition: DeclAF.h:172
enum idDeclAF_Constraint::@49 limit
bool selfCollision
Definition: DeclAF.h:100
const GLcharARB * name
Definition: glext.h:3629
Definition: Str.h:116
virtual bool Parse(const char *text, const int textLength)
Definition: DeclAF.cpp:1430
enum idAFVector::@48 type
unsigned char bool
Definition: setup.h:74
const char * ToString(idStr &str, const int precision=8)
Definition: DeclAF.cpp:213
void RenameBody(const char *oldName, const char *newName)
Definition: DeclAF.cpp:1635
float defaultAngularFriction
Definition: DeclAF.h:175
bool WriteSlider(idFile *f, const idDeclAF_Constraint &c) const
Definition: DeclAF.cpp:507
idAFVector shaft[2]
Definition: DeclAF.h:127
bool RebuildTextSource(void)
Definition: DeclAF.cpp:602
bool selfCollision
Definition: DeclAF.h:188
void SetDefault(const idDeclAF *file)
Definition: DeclAF.cpp:279
static const char * JointModToString(declAFJointMod_t jointMod)
Definition: DeclAF.cpp:744
bool Finish(const char *fileName, const getJointTransform_t GetJointTransform, const idJointMat *frame, void *model) const
Definition: DeclAF.cpp:122
bool(* getJointTransform_t)(void *model, const idJointMat *frame, const char *jointName, idVec3 &origin, idMat3 &axis)
Definition: DeclAF.h:58
int clipMask
Definition: DeclAF.h:99
idStr joint2
Definition: DeclAF.h:69
bool ParseSlider(idLexer &src)
Definition: DeclAF.cpp:1230