pivot.cpp 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /Commando/Code/ww3d2/pivot.cpp 1 1/22/01 3:36p Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando / G 3D Library *
  24. * *
  25. * $Archive:: /Commando/Code/ww3d2/pivot.cpp $*
  26. * *
  27. * Author:: Greg_h *
  28. * *
  29. * $Modtime:: 1/08/01 10:04a $*
  30. * *
  31. * $Revision:: 1 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * PivotClass::PivotClass -- Constructor for PivotClass *
  36. * PivotClass::Compute_Transform -- Update the pivot's transformation matrix *
  37. * PivotClass::Compute_Transform -- Update the pivot's transformation matrix *
  38. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  39. #include "pivot.h"
  40. #include "wwmath.h"
  41. /***********************************************************************************************
  42. * PivotClass::PivotClass -- Constructor for PivotClass *
  43. * *
  44. * INPUT: *
  45. * *
  46. * OUTPUT: *
  47. * *
  48. * WARNINGS: *
  49. * *
  50. * HISTORY: *
  51. * 07/24/1997 GH : Created. *
  52. *=============================================================================================*/
  53. PivotClass::PivotClass(void) :
  54. Index(0),
  55. Parent(NULL),
  56. BaseTransform(1),
  57. Transform(1),
  58. IsVisible(true),
  59. IsCaptured(false),
  60. CapTransform(1),
  61. WorldSpaceTranslation(false)
  62. {
  63. }
  64. void PivotClass::Capture_Update(void)
  65. {
  66. if ( WorldSpaceTranslation ) {
  67. // The Translation of CapTransform is meant to be in world space,
  68. // so remove before applying orientation
  69. Matrix3D CapOrientation = CapTransform;
  70. CapOrientation.Set_Translation( Vector3( 0,0,0 ) );
  71. Matrix3D::Multiply(Transform,CapOrientation,&(Transform));
  72. // Now apply translation in world space
  73. Transform.Adjust_Translation( CapTransform.Get_Translation() );
  74. } else {
  75. Matrix3D::Multiply(Transform,CapTransform,&(Transform));
  76. }
  77. }