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.

82 lines
2.1 KiB

  1. //========= Copyright 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. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. //-----------------------------------------------------------------------------
  14. // Expose this class to the scene database
  15. //-----------------------------------------------------------------------------
  16. IMPLEMENT_ELEMENT_FACTORY( DmeTransform, CDmeTransform );
  17. //-----------------------------------------------------------------------------
  18. // Constructor, destructor
  19. //-----------------------------------------------------------------------------
  20. void CDmeTransform::OnConstruction()
  21. {
  22. m_Position.Init( this, "position" );
  23. m_Orientation.Init( this, "orientation" );
  24. }
  25. void CDmeTransform::OnDestruction()
  26. {
  27. }
  28. //-----------------------------------------------------------------------------
  29. // FIXME: Replace this with actual methods to do editing
  30. //-----------------------------------------------------------------------------
  31. void CDmeTransform::SetTransform( const matrix3x4_t &transform )
  32. {
  33. Vector origin;
  34. Quaternion angles;
  35. MatrixAngles( transform, angles, origin );
  36. m_Orientation.Set( angles );
  37. m_Position.Set( origin );
  38. }
  39. void CDmeTransform::GetTransform( matrix3x4_t &transform )
  40. {
  41. QuaternionMatrix( m_Orientation.Get(), m_Position.Get(), transform );
  42. }
  43. const Vector &CDmeTransform::GetPosition() const
  44. {
  45. return m_Position.Get();
  46. }
  47. void CDmeTransform::SetPosition( const Vector &vecPosition )
  48. {
  49. m_Position = vecPosition;
  50. }
  51. const Quaternion &CDmeTransform::GetOrientation() const
  52. {
  53. return m_Orientation.Get();
  54. }
  55. void CDmeTransform::SetOrientation( const Quaternion &orientation )
  56. {
  57. m_Orientation = orientation;
  58. }
  59. CDmAttribute *CDmeTransform::GetPositionAttribute()
  60. {
  61. return m_Position.GetAttribute();
  62. }
  63. CDmAttribute *CDmeTransform::GetOrientationAttribute()
  64. {
  65. return m_Orientation.GetAttribute();
  66. }