Counter Strike : Global Offensive Source Code
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.

158 lines
5.4 KiB

  1. //====== Copyright � 1996-2008, Valve Corporation, All rights reserved. =======
  2. //
  3. // Declaration of the CDmeTransform control class, a helper for modifying a
  4. // transform.
  5. //
  6. //=============================================================================
  7. #ifndef DMETRANSFORMCONTROL_H
  8. #define DMETRANSFORMCONTROL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "datamodel/dmehandle.h"
  13. //-----------------------------------------------------------------------------
  14. // Forward declarations
  15. //-----------------------------------------------------------------------------
  16. class CDmeChannel;
  17. class CDmeTransform;
  18. class CDmeDag;
  19. //-----------------------------------------------------------------------------
  20. // The CDmeTransformControl class is a helper for modifying a transform, it is
  21. // attached to a control CDmElement which has the transform bool set to true.
  22. // It stores information about how the a transform is to be modified, such as
  23. // the relative pivot offset, manipulation transform, and rotation delta
  24. // information. The CDmeTransformControl class may be
  25. //-----------------------------------------------------------------------------
  26. class CDmeTransformControl : public CDmElement
  27. {
  28. DEFINE_ELEMENT( CDmeTransformControl, CDmElement );
  29. public:
  30. // Get the manipulation transform matrix
  31. void GetManipulationTransform( matrix3x4_t &transform ) const;
  32. // Set the manipulation transform matrix
  33. void SetManipulationTransform( const matrix3x4_t &transform );
  34. // Get the manipulation rotation amount in the local space of the transform
  35. void GetManipulationRotationLocal( Quaternion &rotation ) const;
  36. // Set the manipulation rotation amount in the local space of the transform
  37. void SetManipulationRotationLocal( const Quaternion &rotation );
  38. // Get the manipulation rotation amount in the parent space of the transform
  39. void GetManipulationRotationParent( Quaternion &rotation ) const;
  40. // Set the manipulation rotation amount in the parent space of the transform
  41. void SetManipulationRotationParent( const Quaternion &rotation );
  42. // Get the manipulation pivot position, this may differ from the pivot offset
  43. void GetManipulationPivot( Vector &pivotPosition ) const;
  44. // Set the manipulation pivot position
  45. void SetManipulationPivot( const Vector &pivotPosition );
  46. // Get the current local space pivot offset
  47. const Vector &GetPivotOffset() const;
  48. // Set the current local space pivot offset
  49. void SetPivotOffset( const Vector &localOffset );
  50. // Get the transform associated with the transform control
  51. CDmeTransform *GetTransform() const;
  52. // Get the dag node associated with the transform control
  53. CDmeDag *GetDag() const;
  54. // Get the position attribute of the control
  55. CDmAttribute *GetPositionAttr();
  56. // Get the orientation attribute of the control
  57. CDmAttribute *GetOrientationAttr();
  58. // Get the position value of the control
  59. const Vector &GetPosition() const;
  60. // Get the orientation value of the control
  61. const Quaternion &GetOrientation() const;
  62. // Determine if the control currently has a default position set
  63. bool HasDefaultPosition() const;
  64. // Determine if the control currently has a default orientation set
  65. bool HasDefaultOrientation() const;
  66. // Get the default position of the control
  67. const Vector &GetDefaultPosition() const;
  68. // Get the default orientation of the control
  69. const Quaternion &GetDefaultOrientation() const;
  70. // Get the default position attribute
  71. const CDmAttribute *GetDefaultPositionAttr() const;
  72. // Get the default position attribute
  73. const CDmAttribute *GetDefaultOrientationAttr() const;
  74. // Get the position channel targeting the control
  75. CDmeChannel *GetPositionChannel() const;
  76. // Get the orientation channel targeting the control
  77. CDmeChannel *GetOrientationChannel() const;
  78. // Set the position value of the control
  79. void SetPosition( const Vector &position );
  80. // Set the orientation value of the control
  81. void SetOrientation( const Quaternion &orientation );
  82. // Set the default position of the control
  83. void SetDefaultPosition( const Vector &position );
  84. // Set the default orientation of the control
  85. void SetDefaultOrientation( const Quaternion &orientation );
  86. // Set the position channel that is targeting the control
  87. void SetPositionChannel( CDmeChannel *pChannel );
  88. // Get the orientation channel that is targeting the control
  89. void SetOrientationChannel( CDmeChannel *pChannel );
  90. private:
  91. // Allocate and initialize the manipulation parameters
  92. bool InitManipulationParams();
  93. struct ManipulationParams_t
  94. {
  95. matrix3x4_t Transform; // Transform used to apply the manipulation
  96. Quaternion RotationLocal; // Rotation applied in manipulation ( Local space )
  97. Quaternion RotationParent; // Rotation applied in manipulation ( Parent space )
  98. Vector Pivot; // Pivot used in manipulation
  99. };
  100. Vector m_PivotOffset; // Current pivot offset to be used when manipulating the transform
  101. ManipulationParams_t *m_pManipulationParams; // Parameters describing the last manipulation performed on the transform
  102. CDmaVar< Vector > m_PositionValue; // "valuePosition": current position value of the control
  103. CDmaVar< Quaternion > m_OrientationValue; // "valueOrientation": current orientation value of the control
  104. CDmaElement< CDmeChannel > m_PositionChannel; // "positionChannel": channel which connects the position value to the transform
  105. CDmaElement< CDmeChannel > m_OrientationChannel; // "orientationChannel": channel which connects the orientation value to the transform
  106. };
  107. #endif // DMETRANSFORMCONTROL_H