Physics_Actor.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  17. 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.
  18. ===========================================================================
  19. */
  20. #ifndef __PHYSICS_ACTOR_H__
  21. #define __PHYSICS_ACTOR_H__
  22. /*
  23. ===================================================================================
  24. Actor physics base class
  25. An actor typically uses one collision model which is aligned with the gravity
  26. direction. The collision model is usually a simple box with the origin at the
  27. bottom center.
  28. ===================================================================================
  29. */
  30. class idPhysics_Actor : public idPhysics_Base {
  31. public:
  32. CLASS_PROTOTYPE( idPhysics_Actor );
  33. idPhysics_Actor( void );
  34. ~idPhysics_Actor( void );
  35. void Save( idSaveGame *savefile ) const;
  36. void Restore( idRestoreGame *savefile );
  37. // get delta yaw of master
  38. float GetMasterDeltaYaw( void ) const;
  39. // returns the ground entity
  40. idEntity * GetGroundEntity( void ) const;
  41. // align the clip model with the gravity direction
  42. void SetClipModelAxis( void );
  43. public: // common physics interface
  44. void SetClipModel( idClipModel *model, float density, int id = 0, bool freeOld = true );
  45. idClipModel * GetClipModel( int id = 0 ) const;
  46. int GetNumClipModels( void ) const;
  47. void SetMass( float mass, int id = -1 );
  48. float GetMass( int id = -1 ) const;
  49. void SetContents( int contents, int id = -1 );
  50. int GetContents( int id = -1 ) const;
  51. const idBounds & GetBounds( int id = -1 ) const;
  52. const idBounds & GetAbsBounds( int id = -1 ) const;
  53. bool IsPushable( void ) const;
  54. const idVec3 & GetOrigin( int id = 0 ) const;
  55. const idMat3 & GetAxis( int id = 0 ) const;
  56. void SetGravity( const idVec3 &newGravity );
  57. const idMat3 & GetGravityAxis( void ) const;
  58. void ClipTranslation( trace_t &results, const idVec3 &translation, const idClipModel *model ) const;
  59. void ClipRotation( trace_t &results, const idRotation &rotation, const idClipModel *model ) const;
  60. int ClipContents( const idClipModel *model ) const;
  61. void DisableClip( void );
  62. void EnableClip( void );
  63. void UnlinkClip( void );
  64. void LinkClip( void );
  65. bool EvaluateContacts( void );
  66. protected:
  67. idClipModel * clipModel; // clip model used for collision detection
  68. idMat3 clipModelAxis; // axis of clip model aligned with gravity direction
  69. // derived properties
  70. float mass;
  71. float invMass;
  72. // master
  73. idEntity * masterEntity;
  74. float masterYaw;
  75. float masterDeltaYaw;
  76. // results of last evaluate
  77. idEntityPtr<idEntity> groundEntityPtr;
  78. };
  79. #endif /* !__PHYSICS_ACTOR_H__ */