2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
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.
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.
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/>.
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.
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.
26 ===========================================================================
33 ===============================================================================
37 ===============================================================================
43 DECLAF_CONSTRAINT_INVALID,
44 DECLAF_CONSTRAINT_FIXED,
45 DECLAF_CONSTRAINT_BALLANDSOCKETJOINT,
46 DECLAF_CONSTRAINT_UNIVERSALJOINT,
47 DECLAF_CONSTRAINT_HINGE,
48 DECLAF_CONSTRAINT_SLIDER,
49 DECLAF_CONSTRAINT_SPRING
50 } declAFConstraintType_t;
54 DECLAF_JOINTMOD_ORIGIN,
58 typedef bool (*getJointTransform_t)( void *model, const idJointMat *frame, const char *jointName, idVec3 &origin, idMat3 &axis );
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; }
90 declAFJointMod_t jointMod;
102 float linearFriction;
103 float angularFriction;
104 float contactFriction;
105 idStr containedJoints;
106 idAFVector frictionDirection;
107 idAFVector contactMotorDirection;
109 void SetDefault( const idDeclAF *file );
112 class idDeclAF_Constraint {
117 declAFConstraintType_t type;
134 idAFVector limitAxis;
135 float limitAngles[3];
138 void SetDefault( const idDeclAF *file );
141 class idDeclAF : public idDecl {
142 friend class idAFFileManager;
145 virtual ~idDeclAF( void );
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 );
152 virtual void Finish( const getJointTransform_t GetJointTransform, const idJointMat *frame, void *model ) const;
156 void NewBody( const char *name );
157 void RenameBody( const char *oldName, const char *newName );
158 void DeleteBody( const char *name );
160 void NewConstraint( const char *name );
161 void RenameConstraint( const char *oldName, const char *newName );
162 void DeleteConstraint( const char *name );
164 static int ContentsFromString( const char *str );
165 static const char * ContentsToString( const int contents, idStr &str );
167 static declAFJointMod_t JointModFromString( const char *str );
168 static const char * JointModToString( declAFJointMod_t jointMod );
174 float defaultLinearFriction;
175 float defaultAngularFriction;
176 float defaultContactFriction;
177 float defaultConstraintFriction;
179 idVec2 suspendVelocity;
180 idVec2 suspendAcceleration;
182 float noMoveTranslation;
183 float noMoveRotation;
189 idList<idDeclAF_Body *> bodies;
190 idList<idDeclAF_Constraint *> constraints;
193 bool ParseContents( idLexer &src, int &c ) const;
194 bool ParseBody( idLexer &src );
195 bool ParseFixed( idLexer &src );
196 bool ParseBallAndSocketJoint( idLexer &src );
197 bool ParseUniversalJoint( idLexer &src );
198 bool ParseHinge( idLexer &src );
199 bool ParseSlider( idLexer &src );
200 bool ParseSpring( idLexer &src );
201 bool ParseSettings( idLexer &src );
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;
213 bool RebuildTextSource( void );
216 #endif /* !__DECLAF_H__ */