Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: A higher level link library for general use in the game and tools.
  4. //
  5. //===========================================================================//
  6. #ifndef MDLUTILS_H
  7. #define MDLUTILS_H
  8. #if defined( _WIN32 )
  9. #pragma once
  10. #endif
  11. #include "datacache/imdlcache.h"
  12. #include "mathlib/vector.h"
  13. #include "Color.h"
  14. #include "studio.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. struct matrix3x4_t;
  19. struct MDLSquenceLayer_t
  20. {
  21. int m_nSequenceIndex;
  22. float m_flWeight;
  23. bool m_bNoLoop;
  24. float m_flCycleBeganAt;
  25. };
  26. //-----------------------------------------------------------------------------
  27. // Class containing simplistic MDL state for use in rendering
  28. //-----------------------------------------------------------------------------
  29. class CMDL
  30. {
  31. public:
  32. CMDL();
  33. ~CMDL();
  34. void SetMDL( MDLHandle_t h );
  35. MDLHandle_t GetMDL() const;
  36. // Simple version of drawing; sets up bones for you
  37. void Draw( const matrix3x4_t& rootToWorld );
  38. // NOTE: This version of draw assumes you've filled in the bone to world
  39. // matrix yourself by calling IStudioRender::LockBoneMatrices. The pointer
  40. // returned by that method needs to be passed into here
  41. void Draw( const matrix3x4_t& rootToWorld, const matrix3x4_t *pBoneToWorld );
  42. void SetUpBones( const matrix3x4_t& shapeToWorld, int nMaxBoneCount, matrix3x4_t *pOutputMatrices, const float *pPoseParameters = NULL, MDLSquenceLayer_t *pSequenceLayers = NULL, int nNumSequenceLayers = 0 );
  43. void SetupBonesWithBoneMerge( const CStudioHdr *pMergeHdr, matrix3x4_t *pMergeBoneToWorld,
  44. const CStudioHdr *pFollow, const matrix3x4_t *pFollowBoneToWorld, const matrix3x4_t &matModelToWorld );
  45. studiohdr_t *GetStudioHdr();
  46. private:
  47. void UnreferenceMDL();
  48. public:
  49. MDLHandle_t m_MDLHandle;
  50. Color m_Color;
  51. int m_nSkin;
  52. int m_nBody;
  53. int m_nSequence;
  54. int m_nLOD;
  55. float m_flPlaybackRate;
  56. float m_flTime;
  57. float m_pFlexControls[ MAXSTUDIOFLEXCTRL * 4 ];
  58. Vector m_vecViewTarget;
  59. bool m_bWorldSpaceViewTarget;
  60. void *m_pProxyData;
  61. };
  62. //-----------------------------------------------------------------------------
  63. // Returns the bounding box for the model
  64. //-----------------------------------------------------------------------------
  65. void GetMDLBoundingBox( Vector *pMins, Vector *pMaxs, MDLHandle_t h, int nSequence );
  66. //-----------------------------------------------------------------------------
  67. // Returns the radius of the model as measured from the origin
  68. //-----------------------------------------------------------------------------
  69. float GetMDLRadius( MDLHandle_t h, int nSequence );
  70. //-----------------------------------------------------------------------------
  71. // Returns a more accurate bounding sphere
  72. //-----------------------------------------------------------------------------
  73. void GetMDLBoundingSphere( Vector *pVecCenter, float *pRadius, MDLHandle_t h, int nSequence );
  74. #endif // MDLUTILS_H