W3DTankDraw.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. // FIEL: W3DTankDraw.h ////////////////////////////////////////////////////////////////////////////
  24. // Draw a tank
  25. // Author: Michael S. Booth, October 2001
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef _W3D_TANK_DRAW_H_
  29. #define _W3D_TANK_DRAW_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "Common/DrawModule.h"
  32. #include "GameClient/ParticleSys.h"
  33. #include "W3DDevice/GameClient/Module/W3DModelDraw.h"
  34. #include "WW3D2/HAnim.h"
  35. #include "WW3D2/RendObj.h"
  36. #include "WW3D2/Part_Emt.h"
  37. //-------------------------------------------------------------------------------------------------
  38. class W3DTankDrawModuleData : public W3DModelDrawModuleData
  39. {
  40. public:
  41. AsciiString m_treadDebrisNameLeft;
  42. AsciiString m_treadDebrisNameRight;
  43. Real m_treadAnimationRate; ///<amount of tread texture to scroll per sec. 1.0 == full width.
  44. Real m_treadPivotSpeedFraction; ///<fraction of locomotor speed below which we allow pivoting.
  45. Real m_treadDriveSpeedFraction; ///<fraction of locomotor speed below which treads stop animating.
  46. W3DTankDrawModuleData();
  47. ~W3DTankDrawModuleData();
  48. static void buildFieldParse(MultiIniFieldParse& p);
  49. };
  50. //-------------------------------------------------------------------------------------------------
  51. class W3DTankDraw : public W3DModelDraw
  52. {
  53. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DTankDraw, "W3DTankDraw" )
  54. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DTankDraw, W3DTankDrawModuleData )
  55. public:
  56. W3DTankDraw( Thing *thing, const ModuleData* moduleData );
  57. // virtual destructor prototype provided by memory pool declaration
  58. virtual void setHidden(Bool h);
  59. virtual void doDrawModule(const Matrix3D* transformMtx);
  60. virtual void setFullyObscuredByShroud(Bool fullyObscured);
  61. protected:
  62. virtual void onRenderObjRecreated(void);
  63. protected:
  64. /// debris emitters for when tank is moving
  65. ParticleSystem* m_treadDebrisLeft;
  66. ParticleSystem* m_treadDebrisRight;
  67. RenderObjClass *m_prevRenderObj;
  68. enum TreadType { TREAD_LEFT, TREAD_RIGHT, TREAD_MIDDLE }; //types of treads for different vehicles
  69. enum {MAX_TREADS_PER_TANK=4};
  70. struct TreadObjectInfo
  71. {
  72. RenderObjClass *m_robj; ///<sub-object for tread
  73. TreadType m_type; ///<kind of tread
  74. RenderObjClass::Material_Override m_materialSettings; ///<used to set current uv scroll amount.
  75. };
  76. TreadObjectInfo m_treads[MAX_TREADS_PER_TANK];
  77. Int m_treadCount;
  78. Coord3D m_lastDirection; ///< orientation of tank last time it was drawn.
  79. void createEmitters( void ); ///< Create particle effects.
  80. void tossEmitters( void ); ///< Create particle effects.
  81. void startMoveDebris( void ); ///< start creating debris from the tank treads
  82. void stopMoveDebris( void ); ///< stop creating debris from the tank treads
  83. void updateTreadObjects(void); ///< update pointers to sub-objects like treads.
  84. void updateTreadPositions(Real uvDelta); ///< update uv coordinates on each tread
  85. };
  86. #endif // _W3D_TANK_DRAW_H_