W3DTankTruckDraw.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. ** Command & Conquer Generals(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. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: W3DTankTruckDraw.h ////////////////////////////////////////////////////////////////////////////
  24. // Draw a vehicle with treads and wheels.
  25. // Author: Mark Wilczynski, August 2002
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef _W3D_TANKTRUCK_DRAW_H_
  29. #define _W3D_TANKTRUCK_DRAW_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "Common/DrawModule.h"
  32. #include "Common/AudioEventRTS.h"
  33. #include "GameClient/ParticleSys.h"
  34. #include "W3DDevice/GameClient/Module/W3DModelDraw.h"
  35. #include "WW3D2/HAnim.h"
  36. #include "WW3D2/RendObj.h"
  37. #include "WW3D2/Part_Emt.h"
  38. //-------------------------------------------------------------------------------------------------
  39. class W3DTankTruckDrawModuleData : public W3DModelDrawModuleData
  40. {
  41. public:
  42. AsciiString m_dustEffectName;
  43. AsciiString m_dirtEffectName;
  44. AsciiString m_powerslideEffectName;
  45. AsciiString m_frontLeftTireBoneName;
  46. AsciiString m_frontRightTireBoneName;
  47. AsciiString m_rearLeftTireBoneName;
  48. AsciiString m_rearRightTireBoneName;
  49. //4 extra tires to support up to 8 tires.
  50. AsciiString m_midFrontLeftTireBoneName;
  51. AsciiString m_midFrontRightTireBoneName;
  52. AsciiString m_midRearLeftTireBoneName;
  53. AsciiString m_midRearRightTireBoneName;
  54. Real m_rotationSpeedMultiplier;
  55. Real m_powerslideRotationAddition;
  56. //Tank data
  57. AsciiString m_treadDebrisNameLeft;
  58. AsciiString m_treadDebrisNameRight;
  59. Real m_treadAnimationRate; ///<amount of tread texture to scroll per sec. 1.0 == full width.
  60. Real m_treadPivotSpeedFraction; ///<fraction of locomotor speed below which we allow pivoting.
  61. Real m_treadDriveSpeedFraction; ///<fraction of locomotor speed below which treads stop animating.
  62. W3DTankTruckDrawModuleData();
  63. ~W3DTankTruckDrawModuleData();
  64. static void buildFieldParse(MultiIniFieldParse& p);
  65. };
  66. //-------------------------------------------------------------------------------------------------
  67. class W3DTankTruckDraw : public W3DModelDraw
  68. {
  69. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DTankTruckDraw, "W3DTankTruckDraw" )
  70. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DTankTruckDraw, W3DTankTruckDrawModuleData )
  71. public:
  72. W3DTankTruckDraw( Thing *thing, const ModuleData* moduleData );
  73. // virtual destructor prototype provided by memory pool declaration
  74. virtual void setHidden(Bool h);
  75. virtual void doDrawModule(const Matrix3D* transformMtx);
  76. virtual void setFullyObscuredByShroud(Bool fullyObscured);
  77. virtual void reactToGeometryChange() { }
  78. protected:
  79. virtual void onRenderObjRecreated(void);
  80. protected:
  81. Bool m_effectsInitialized;
  82. Bool m_wasAirborne;
  83. Bool m_isPowersliding;
  84. /// debris emitters for when tank is moving
  85. ParticleSystem* m_dustEffect;
  86. ParticleSystem* m_dirtEffect;
  87. ParticleSystem* m_powerslideEffect;
  88. Real m_frontWheelRotation;
  89. Real m_rearWheelRotation;
  90. Real m_midFrontWheelRotation;
  91. Real m_midRearWheelRotation;
  92. Int m_frontLeftTireBone;
  93. Int m_frontRightTireBone;
  94. Int m_rearLeftTireBone;
  95. Int m_rearRightTireBone;
  96. //4 extra tires to support up to 8 tires
  97. Int m_midFrontLeftTireBone;
  98. Int m_midFrontRightTireBone;
  99. Int m_midRearLeftTireBone;
  100. Int m_midRearRightTireBone;
  101. AudioEventRTS m_powerslideSound;
  102. AudioEventRTS m_landingSound;
  103. //Tank Data
  104. /// debris emitters for when tank is moving
  105. ParticleSystem* m_treadDebrisLeft;
  106. ParticleSystem* m_treadDebrisRight;
  107. enum TreadType { TREAD_LEFT, TREAD_RIGHT, TREAD_MIDDLE }; //types of treads for different vehicles
  108. enum {MAX_TREADS_PER_TANK=4};
  109. struct TreadObjectInfo
  110. {
  111. RenderObjClass *m_robj; ///<sub-object for tread
  112. TreadType m_type; ///<kind of tread
  113. RenderObjClass::Material_Override m_materialSettings; ///<used to set current uv scroll amount.
  114. };
  115. TreadObjectInfo m_treads[MAX_TREADS_PER_TANK];
  116. Int m_treadCount;
  117. RenderObjClass *m_prevRenderObj;
  118. void createEmitters( void ); ///< Create particle effects.
  119. void tossEmitters( void ); ///< Create particle effects.
  120. void enableEmitters( Bool enable ); ///< stop creating debris from the tank treads
  121. void updateBones( void );
  122. void startMoveDebris( void ); ///< start creating debris from the tank treads
  123. void stopMoveDebris( void ); ///< stop creating debris from the tank treads
  124. void updateTreadObjects(void); ///< update pointers to sub-objects like treads.
  125. void updateTreadPositions(Real uvDelta); ///< update uv coordinates on each tread
  126. };
  127. #endif // _W3D_TANKTRUCK_DRAW_H_