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 ===========================================================================
29 #ifndef __GAME_AFENTITY_H__
30 #define __GAME_AFENTITY_H__
34 ===============================================================================
38 Entity using multiple separate visual models animated with a single
39 articulated figure. Only used for debugging!
41 ===============================================================================
43 const int GIB_DELAY = 200; // only gib this often to keep performace hits when blowing up several mobs
45 class idMultiModelAF : public idEntity {
47 CLASS_PROTOTYPE( idMultiModelAF );
50 ~idMultiModelAF( void );
52 virtual void Think( void );
53 virtual void Present( void );
56 idPhysics_AF physicsObj;
58 void SetModelForId( int id, const idStr &modelName );
61 idList<idRenderModel *> modelHandles;
62 idList<int> modelDefHandles;
67 ===============================================================================
71 Chain hanging down from the ceiling. Only used for debugging!
73 ===============================================================================
76 class idChain : public idMultiModelAF {
78 CLASS_PROTOTYPE( idChain );
83 void BuildChain( const idStr &name, const idVec3 &origin, float linkLength, float linkWidth, float density, int numLinks, bool bindToWorld = true );
88 ===============================================================================
92 ===============================================================================
95 class idAFAttachment : public idAnimatedEntity {
97 CLASS_PROTOTYPE( idAFAttachment );
99 idAFAttachment( void );
100 virtual ~idAFAttachment( void );
104 void Save( idSaveGame *savefile ) const;
105 void Restore( idRestoreGame *savefile );
107 void SetBody( idEntity *bodyEnt, const char *headModel, jointHandle_t attachJoint );
108 void ClearBody( void );
109 idEntity * GetBody( void ) const;
111 virtual void Think( void );
113 virtual void Hide( void );
114 virtual void Show( void );
116 void PlayIdleAnim( int blendTime );
118 virtual void GetImpactInfo( idEntity *ent, int id, const idVec3 &point, impactInfo_t *info );
119 virtual void ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse );
120 virtual void AddForce( idEntity *ent, int id, const idVec3 &point, const idVec3 &force );
122 virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
123 virtual void AddDamageEffect( const trace_t &collision, const idVec3 &velocity, const char *damageDefName );
125 void SetCombatModel( void );
126 idClipModel * GetCombatModel( void ) const;
127 virtual void LinkCombat( void );
128 virtual void UnlinkCombat( void );
132 idClipModel * combatModel; // render model for hit detection of head
134 jointHandle_t attachJoint;
139 ===============================================================================
143 ===============================================================================
146 class idAFEntity_Base : public idAnimatedEntity {
148 CLASS_PROTOTYPE( idAFEntity_Base );
150 idAFEntity_Base( void );
151 virtual ~idAFEntity_Base( void );
155 void Save( idSaveGame *savefile ) const;
156 void Restore( idRestoreGame *savefile );
158 virtual void Think( void );
159 virtual void GetImpactInfo( idEntity *ent, int id, const idVec3 &point, impactInfo_t *info );
160 virtual void ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse );
161 virtual void AddForce( idEntity *ent, int id, const idVec3 &point, const idVec3 &force );
162 virtual bool Collide( const trace_t &collision, const idVec3 &velocity );
163 virtual bool GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
164 virtual bool UpdateAnimationControllers( void );
165 virtual void FreeModelDef( void );
167 virtual bool LoadAF( void );
168 bool IsActiveAF( void ) const { return af.IsActive(); }
169 const char * GetAFName( void ) const { return af.GetName(); }
170 idPhysics_AF * GetAFPhysics( void ) { return af.GetPhysics(); }
172 void SetCombatModel( void );
173 idClipModel * GetCombatModel( void ) const;
174 // contents of combatModel can be set to 0 or re-enabled (mp)
175 void SetCombatContents( bool enable );
176 virtual void LinkCombat( void );
177 virtual void UnlinkCombat( void );
179 int BodyForClipModelId( int id ) const;
181 void SaveState( idDict &args ) const;
182 void LoadState( const idDict &args );
184 void AddBindConstraints( void );
185 void RemoveBindConstraints( void );
187 virtual void ShowEditingDialog( void );
189 static void DropAFs( idEntity *ent, const char *type, idList<idEntity *> *list );
192 idAF af; // articulated figure
193 idClipModel * combatModel; // render model for hit detection
194 int combatModelContents;
195 idVec3 spawnOrigin; // spawn origin
196 idMat3 spawnAxis; // rotation axis used when spawned
197 int nextSoundTime; // next time this can make a sound
199 void Event_SetConstraintPosition( const char *name, const idVec3 &pos );
203 ===============================================================================
207 ===============================================================================
210 extern const idEventDef EV_Gib;
211 extern const idEventDef EV_Gibbed;
213 class idAFEntity_Gibbable : public idAFEntity_Base {
215 CLASS_PROTOTYPE( idAFEntity_Gibbable );
217 idAFEntity_Gibbable( void );
218 ~idAFEntity_Gibbable( void );
221 void Save( idSaveGame *savefile ) const;
222 void Restore( idRestoreGame *savefile );
223 virtual void Present( void );
224 virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
225 virtual void SpawnGibs( const idVec3 &dir, const char *damageDefName );
228 idRenderModel * skeletonModel;
229 int skeletonModelDefHandle;
232 virtual void Gib( const idVec3 &dir, const char *damageDefName );
233 void InitSkeletonModel( void );
235 void Event_Gib( const char *damageDefName );
239 ===============================================================================
243 ===============================================================================
246 class idAFEntity_Generic : public idAFEntity_Gibbable {
248 CLASS_PROTOTYPE( idAFEntity_Generic );
250 idAFEntity_Generic( void );
251 ~idAFEntity_Generic( void );
255 void Save( idSaveGame *savefile ) const;
256 void Restore( idRestoreGame *savefile );
258 virtual void Think( void );
259 void KeepRunningPhysics( void ) { keepRunningPhysics = true; }
262 void Event_Activate( idEntity *activator );
264 bool keepRunningPhysics;
269 ===============================================================================
271 idAFEntity_WithAttachedHead
273 ===============================================================================
276 class idAFEntity_WithAttachedHead : public idAFEntity_Gibbable {
278 CLASS_PROTOTYPE( idAFEntity_WithAttachedHead );
280 idAFEntity_WithAttachedHead();
281 ~idAFEntity_WithAttachedHead();
285 void Save( idSaveGame *savefile ) const;
286 void Restore( idRestoreGame *savefile );
288 void SetupHead( void );
290 virtual void Think( void );
292 virtual void Hide( void );
293 virtual void Show( void );
294 virtual void ProjectOverlay( const idVec3 &origin, const idVec3 &dir, float size, const char *material );
296 virtual void LinkCombat( void );
297 virtual void UnlinkCombat( void );
300 virtual void Gib( const idVec3 &dir, const char *damageDefName );
303 idEntityPtr<idAFAttachment> head;
305 void Event_Gib( const char *damageDefName );
306 void Event_Activate( idEntity *activator );
311 ===============================================================================
315 ===============================================================================
318 class idAFEntity_Vehicle : public idAFEntity_Base {
320 CLASS_PROTOTYPE( idAFEntity_Vehicle );
322 idAFEntity_Vehicle( void );
325 void Use( idPlayer *player );
329 jointHandle_t eyesJoint;
330 jointHandle_t steeringWheelJoint;
334 const idDeclParticle * dustSmoke;
336 float GetSteerAngle( void );
341 ===============================================================================
343 idAFEntity_VehicleSimple
345 ===============================================================================
348 class idAFEntity_VehicleSimple : public idAFEntity_Vehicle {
350 CLASS_PROTOTYPE( idAFEntity_VehicleSimple );
352 idAFEntity_VehicleSimple( void );
353 ~idAFEntity_VehicleSimple( void );
356 virtual void Think( void );
359 idClipModel * wheelModel;
360 idAFConstraint_Suspension * suspension[4];
361 jointHandle_t wheelJoints[4];
362 float wheelAngles[4];
367 ===============================================================================
369 idAFEntity_VehicleFourWheels
371 ===============================================================================
374 class idAFEntity_VehicleFourWheels : public idAFEntity_Vehicle {
376 CLASS_PROTOTYPE( idAFEntity_VehicleFourWheels );
378 idAFEntity_VehicleFourWheels( void );
381 virtual void Think( void );
384 idAFBody * wheels[4];
385 idAFConstraint_Hinge * steering[2];
386 jointHandle_t wheelJoints[4];
387 float wheelAngles[4];
392 ===============================================================================
394 idAFEntity_VehicleSixWheels
396 ===============================================================================
399 class idAFEntity_VehicleSixWheels : public idAFEntity_Vehicle {
401 CLASS_PROTOTYPE( idAFEntity_VehicleSixWheels );
403 idAFEntity_VehicleSixWheels( void );
406 virtual void Think( void );
409 idAFBody * wheels[6];
410 idAFConstraint_Hinge * steering[4];
411 jointHandle_t wheelJoints[6];
412 float wheelAngles[6];
417 ===============================================================================
421 ===============================================================================
424 class idAFEntity_SteamPipe : public idAFEntity_Base {
426 CLASS_PROTOTYPE( idAFEntity_SteamPipe );
428 idAFEntity_SteamPipe( void );
429 ~idAFEntity_SteamPipe( void );
432 void Save( idSaveGame *savefile ) const;
433 void Restore( idRestoreGame *savefile );
435 virtual void Think( void );
441 idForce_Constant force;
442 renderEntity_t steamRenderEntity;
443 qhandle_t steamModelDefHandle;
445 void InitSteamRenderEntity( void );
450 ===============================================================================
452 idAFEntity_ClawFourFingers
454 ===============================================================================
457 class idAFEntity_ClawFourFingers : public idAFEntity_Base {
459 CLASS_PROTOTYPE( idAFEntity_ClawFourFingers );
461 idAFEntity_ClawFourFingers( void );
464 void Save( idSaveGame *savefile ) const;
465 void Restore( idRestoreGame *savefile );
468 idAFConstraint_Hinge * fingers[4];
470 void Event_SetFingerAngle( float angle );
471 void Event_StopFingers( void );
474 #endif /* !__GAME_AFENTITY_H__ */