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 );
226 void SetThrown( bool isThrown );
227 virtual bool Collide( const trace_t &collision, const idVec3 &velocity );
229 virtual void SpawnGibs( const idVec3 &dir, const char *damageDefName );
232 bool IsGibbed() { return gibbed; };
236 idRenderModel * skeletonModel;
237 int skeletonModelDefHandle;
244 virtual void Gib( const idVec3 &dir, const char *damageDefName );
245 void InitSkeletonModel( void );
247 void Event_Gib( const char *damageDefName );
251 ===============================================================================
255 ===============================================================================
258 class idAFEntity_Generic : public idAFEntity_Gibbable {
260 CLASS_PROTOTYPE( idAFEntity_Generic );
262 idAFEntity_Generic( void );
263 ~idAFEntity_Generic( void );
267 void Save( idSaveGame *savefile ) const;
268 void Restore( idRestoreGame *savefile );
270 virtual void Think( void );
271 void KeepRunningPhysics( void ) { keepRunningPhysics = true; }
274 void Event_Activate( idEntity *activator );
276 bool keepRunningPhysics;
281 ===============================================================================
283 idAFEntity_WithAttachedHead
285 ===============================================================================
288 class idAFEntity_WithAttachedHead : public idAFEntity_Gibbable {
290 CLASS_PROTOTYPE( idAFEntity_WithAttachedHead );
292 idAFEntity_WithAttachedHead();
293 ~idAFEntity_WithAttachedHead();
297 void Save( idSaveGame *savefile ) const;
298 void Restore( idRestoreGame *savefile );
300 void SetupHead( void );
302 virtual void Think( void );
304 virtual void Hide( void );
305 virtual void Show( void );
306 virtual void ProjectOverlay( const idVec3 &origin, const idVec3 &dir, float size, const char *material );
308 virtual void LinkCombat( void );
309 virtual void UnlinkCombat( void );
312 virtual void Gib( const idVec3 &dir, const char *damageDefName );
319 idEntityPtr<idAFAttachment> head;
321 void Event_Gib( const char *damageDefName );
322 void Event_Activate( idEntity *activator );
327 ===============================================================================
331 ===============================================================================
334 class idAFEntity_Vehicle : public idAFEntity_Base {
336 CLASS_PROTOTYPE( idAFEntity_Vehicle );
338 idAFEntity_Vehicle( void );
341 void Use( idPlayer *player );
345 jointHandle_t eyesJoint;
346 jointHandle_t steeringWheelJoint;
350 const idDeclParticle * dustSmoke;
352 float GetSteerAngle( void );
357 ===============================================================================
359 idAFEntity_VehicleSimple
361 ===============================================================================
364 class idAFEntity_VehicleSimple : public idAFEntity_Vehicle {
366 CLASS_PROTOTYPE( idAFEntity_VehicleSimple );
368 idAFEntity_VehicleSimple( void );
369 ~idAFEntity_VehicleSimple( void );
372 virtual void Think( void );
375 idClipModel * wheelModel;
376 idAFConstraint_Suspension * suspension[4];
377 jointHandle_t wheelJoints[4];
378 float wheelAngles[4];
383 ===============================================================================
385 idAFEntity_VehicleFourWheels
387 ===============================================================================
390 class idAFEntity_VehicleFourWheels : public idAFEntity_Vehicle {
392 CLASS_PROTOTYPE( idAFEntity_VehicleFourWheels );
394 idAFEntity_VehicleFourWheels( void );
397 virtual void Think( void );
400 idAFBody * wheels[4];
401 idAFConstraint_Hinge * steering[2];
402 jointHandle_t wheelJoints[4];
403 float wheelAngles[4];
408 ===============================================================================
410 idAFEntity_VehicleSixWheels
412 ===============================================================================
415 class idAFEntity_VehicleSixWheels : public idAFEntity_Vehicle {
417 CLASS_PROTOTYPE( idAFEntity_VehicleSixWheels );
419 idAFEntity_VehicleSixWheels( void );
422 virtual void Think( void );
431 idAFBody * wheels[6];
432 idAFConstraint_Hinge * steering[4];
433 jointHandle_t wheelJoints[6];
434 float wheelAngles[6];
439 ===============================================================================
441 idAFEntity_VehicleAutomated
443 ===============================================================================
446 class idAFEntity_VehicleAutomated : public idAFEntity_VehicleSixWheels {
448 CLASS_PROTOTYPE( idAFEntity_VehicleAutomated );
451 void PostSpawn( void );
452 virtual void Think( void );
458 float currentSteering;
462 void Event_SetVelocity( float _velocity );
463 void Event_SetTorque( float _torque );
464 void Event_SetSteeringSpeed( float _steeringSpeed );
465 void Event_SetWayPoint( idEntity *_waypoint );
470 ===============================================================================
474 ===============================================================================
477 class idAFEntity_SteamPipe : public idAFEntity_Base {
479 CLASS_PROTOTYPE( idAFEntity_SteamPipe );
481 idAFEntity_SteamPipe( void );
482 ~idAFEntity_SteamPipe( void );
485 void Save( idSaveGame *savefile ) const;
486 void Restore( idRestoreGame *savefile );
488 virtual void Think( void );
494 idForce_Constant force;
495 renderEntity_t steamRenderEntity;
496 qhandle_t steamModelDefHandle;
498 void InitSteamRenderEntity( void );
503 ===============================================================================
505 idAFEntity_ClawFourFingers
507 ===============================================================================
510 class idAFEntity_ClawFourFingers : public idAFEntity_Base {
512 CLASS_PROTOTYPE( idAFEntity_ClawFourFingers );
514 idAFEntity_ClawFourFingers( void );
517 void Save( idSaveGame *savefile ) const;
518 void Restore( idRestoreGame *savefile );
521 idAFConstraint_Hinge * fingers[4];
523 void Event_SetFingerAngle( float angle );
524 void Event_StopFingers( void );
530 * idHarvestable contains all of the code required to turn an entity into a harvestable
531 * entity. The entity must create an instance of this class and call the appropriate
532 * interface methods at the correct time.
534 class idHarvestable : public idEntity {
536 CLASS_PROTOTYPE( idHarvestable );
542 void Init(idEntity* parent);
543 void Save( idSaveGame *savefile ) const;
544 void Restore( idRestoreGame *savefile );
546 void SetParent(idEntity* parent);
552 idEntityPtr<idEntity> parentEnt;
554 idClipModel * trigger;
559 idEntityPtr<idPlayer> player;
563 idEntityPtr<idEntityFx> fx;
569 void CalcTriggerBounds( float size, idBounds &bounds );
571 bool GetFxOrientationAxis(idMat3& mat);
573 void Event_SpawnHarvestTrigger( void );
574 void Event_Touch( idEntity *other, trace_t *trace );
579 ===============================================================================
583 ===============================================================================
588 class idAFEntity_Harvest : public idAFEntity_WithAttachedHead {
590 CLASS_PROTOTYPE( idAFEntity_Harvest );
592 idAFEntity_Harvest();
593 ~idAFEntity_Harvest();
597 void Save( idSaveGame *savefile ) const;
598 void Restore( idRestoreGame *savefile );
600 virtual void Think( void );
602 virtual void Gib( const idVec3 &dir, const char *damageDefName );
605 idEntityPtr<idHarvestable> harvestEnt;
607 void Event_SpawnHarvestEntity( void );
612 #endif /* !__GAME_AFENTITY_H__ */