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.

93 lines
2.4 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "movieobjects/dmetransform.h"
  7. #include "tier0/dbg.h"
  8. #include "datamodel/dmelementfactoryhelper.h"
  9. #include "mathlib/vector.h"
  10. #include "mathlib/mathlib.h"
  11. #include "datamodel/dmattributevar.h"
  12. #include "movieobjects/dmedag.h"
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. //-----------------------------------------------------------------------------
  16. // Expose this class to the scene database
  17. //-----------------------------------------------------------------------------
  18. IMPLEMENT_ELEMENT_FACTORY( DmeTransform, CDmeTransform );
  19. //-----------------------------------------------------------------------------
  20. // Constructor, destructor
  21. //-----------------------------------------------------------------------------
  22. void CDmeTransform::OnConstruction()
  23. {
  24. m_Position.Init( this, TRANSFORM_POSITION, FATTRIB_HAS_CALLBACK );
  25. m_Orientation.Init( this, TRANSFORM_ORIENTATION, FATTRIB_HAS_CALLBACK );
  26. }
  27. void CDmeTransform::OnDestruction()
  28. {
  29. }
  30. void CDmeTransform::OnAttributeChanged( CDmAttribute *pAttribute )
  31. {
  32. BaseClass::OnAttributeChanged( pAttribute );
  33. InvokeOnAttributeChangedOnReferrers( GetHandle(), pAttribute );
  34. }
  35. void CDmeTransform::SetTransform( const matrix3x4_t &transform )
  36. {
  37. Vector origin;
  38. Quaternion angles;
  39. MatrixAngles( transform, angles, origin );
  40. m_Orientation.Set( angles );
  41. m_Position.Set( origin );
  42. }
  43. void CDmeTransform::GetTransform( matrix3x4_t &transform )
  44. {
  45. QuaternionMatrix( m_Orientation.Get(), m_Position.Get(), transform );
  46. }
  47. const Vector &CDmeTransform::GetPosition() const
  48. {
  49. return m_Position.Get();
  50. }
  51. void CDmeTransform::SetPosition( const Vector &vecPosition )
  52. {
  53. m_Position = vecPosition;
  54. }
  55. const Quaternion &CDmeTransform::GetOrientation() const
  56. {
  57. return m_Orientation.Get();
  58. }
  59. void CDmeTransform::SetOrientation( const Quaternion &orientation )
  60. {
  61. m_Orientation = orientation;
  62. }
  63. CDmAttribute *CDmeTransform::GetPositionAttribute()
  64. {
  65. return m_Position.GetAttribute();
  66. }
  67. CDmAttribute *CDmeTransform::GetOrientationAttribute()
  68. {
  69. return m_Orientation.GetAttribute();
  70. }
  71. CDmeDag *CDmeTransform::GetDag()
  72. {
  73. static CUtlSymbolLarge symTransform = g_pDataModel->GetSymbol( "transform" );
  74. CDmeDag *pDag = FindReferringElement< CDmeDag >( this, symTransform );
  75. return pDag;
  76. }