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.

94 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Dme version of a skeletal model (gets compiled into a MDL)
  4. //
  5. //===========================================================================//
  6. #ifndef DMEMODEL_H
  7. #define DMEMODEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier1/utlstack.h"
  12. #include "movieobjects/dmejoint.h"
  13. #include "movieobjects/dmetransformlist.h"
  14. class CDmeDrawSettings;
  15. //-----------------------------------------------------------------------------
  16. // A class representing a skeletal model
  17. //-----------------------------------------------------------------------------
  18. class CDmeModel : public CDmeDag
  19. {
  20. DEFINE_ELEMENT( CDmeModel, CDmeDag );
  21. public:
  22. // Add joint
  23. CDmeJoint *AddJoint( const char *pJointName, CDmeDag *pParent = NULL );
  24. int AddJoint( CDmeDag *pJoint );
  25. // Returns the number of joint transforms we know about
  26. int GetJointTransformCount() const;
  27. // Determines joint transform index given a joint name
  28. int GetJointTransformIndex( CDmeTransform *pTransform ) const;
  29. // Determines joint transform index given a joint
  30. int GetJointTransformIndex( CDmeDag *pJoint ) const;
  31. // Determines joint transform index given a joint name
  32. CDmeTransform *GetJointTransform( int nIndex );
  33. const CDmeTransform *GetJointTransform( int nIndex ) const;
  34. // Captures the current joint transforms into a base state
  35. void CaptureJointsToBaseState( const char *pBaseStateName );
  36. // Finds a base state by name, returns NULL if not found
  37. CDmeTransformList *FindBaseState( const char *pBaseStateName );
  38. // Recursively render the Dag hierarchy
  39. virtual void Draw( CDmeDrawSettings *pDrawSettings = NULL );
  40. // Set if Z is the up axis of the model
  41. void ZUp( bool bYUp );
  42. // Returns true if the DmeModel is Z Up.
  43. bool IsZUp() const;
  44. protected:
  45. // The order in which the joint transform names appear in this list
  46. // indicates the joint index for each dag
  47. CDmaElementArray<CDmeTransform> m_JointTransforms;
  48. // Stores a list of base poses for all the joint transforms
  49. CDmaElementArray<CDmeTransformList> m_BaseStates;
  50. private:
  51. enum SetupBoneRetval_t
  52. {
  53. NO_SKIN_DATA = 0,
  54. TOO_MANY_BONES,
  55. BONES_SET_UP
  56. };
  57. // Sets up the render state for the model
  58. SetupBoneRetval_t SetupBoneMatrixState( const matrix3x4_t& shapeToWorld, bool bForceSoftwareSkin );
  59. // Loads up joint transforms for this model
  60. void LoadJointTransform( CDmeDag *pJoint, CDmeTransformList *pBindPose, const matrix3x4_t &parentToWorld, const matrix3x4_t &parentToBindPose, bool bSetHardwareState );
  61. // Sets up the render state for the model
  62. static matrix3x4_t *SetupModelRenderState( const matrix3x4_t& shapeToWorld, bool bHasSkinningData, bool bForceSoftwareSkin );
  63. static void CleanupModelRenderState();
  64. // Stack of DmeModels currently being rendered. Used to set up render state
  65. static CUtlStack< CDmeModel * > s_ModelStack;
  66. friend class CDmeMesh;
  67. };
  68. #endif // DMEMODEL_H