W3DPropDraw.cpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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: W3DPropDraw.cpp ////////////////////////////////////////////////////////////////////////
  24. // Author: John Ahlquist, June 2--3
  25. // Desc: Simple prop drawing code.
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include <stdlib.h>
  29. #include "Common/Thing.h"
  30. #include "Common/ThingTemplate.h"
  31. #include "Common/Xfer.h"
  32. #include "GameLogic/Object.h"
  33. #include "GameClient/Drawable.h"
  34. #include "W3DDevice/GameClient/Module/W3DPropDraw.h"
  35. #include "W3DDevice/GameClient/BaseHeightMap.h"
  36. #ifdef _INTERNAL
  37. // for occasional debugging...
  38. //#pragma optimize("", off)
  39. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  40. #endif
  41. //-------------------------------------------------------------------------------------------------
  42. W3DPropDrawModuleData::W3DPropDrawModuleData()
  43. {
  44. }
  45. //-------------------------------------------------------------------------------------------------
  46. W3DPropDrawModuleData::~W3DPropDrawModuleData()
  47. {
  48. }
  49. //-------------------------------------------------------------------------------------------------
  50. void W3DPropDrawModuleData::buildFieldParse(MultiIniFieldParse& p)
  51. {
  52. ModuleData::buildFieldParse(p);
  53. static const FieldParse dataFieldParse[] =
  54. {
  55. { "ModelName", INI::parseAsciiString, NULL, offsetof(W3DPropDrawModuleData, m_modelName) },
  56. { 0, 0, 0, 0 }
  57. };
  58. p.add(dataFieldParse);
  59. }
  60. ///////////////////////////////////////////////////////////////////////////////////////////////////
  61. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////////////////////////
  62. ///////////////////////////////////////////////////////////////////////////////////////////////////
  63. //-------------------------------------------------------------------------------------------------
  64. //-------------------------------------------------------------------------------------------------
  65. W3DPropDraw::W3DPropDraw( Thing *thing, const ModuleData* moduleData ) : DrawModule( thing, moduleData ),
  66. m_propAdded(false)
  67. {
  68. } // end W3DPropDraw
  69. //-------------------------------------------------------------------------------------------------
  70. //-------------------------------------------------------------------------------------------------
  71. W3DPropDraw::~W3DPropDraw( void )
  72. {
  73. }
  74. //-------------------------------------------------------------------------------------------------
  75. void W3DPropDraw::reactToTransformChange( const Matrix3D *oldMtx,
  76. const Coord3D *oldPos,
  77. Real oldAngle )
  78. {
  79. Drawable *draw = getDrawable();
  80. if (m_propAdded) {
  81. return;
  82. }
  83. if (draw->getPosition()->x==0.0f && draw->getPosition()->y == 0.0f) {
  84. return;
  85. }
  86. m_propAdded = true;
  87. const W3DPropDrawModuleData *moduleData = getW3DPropDrawModuleData();
  88. if (!moduleData) {
  89. return;
  90. }
  91. Real scale = draw->getScale();
  92. TheTerrainRenderObject->addProp((Int)draw->getID(), *draw->getPosition(),
  93. draw->getOrientation(), scale, moduleData->m_modelName);
  94. }
  95. //-------------------------------------------------------------------------------------------------
  96. //-------------------------------------------------------------------------------------------------
  97. void W3DPropDraw::doDrawModule(const Matrix3D* transformMtx)
  98. {
  99. return;
  100. }
  101. // ------------------------------------------------------------------------------------------------
  102. /** CRC */
  103. // ------------------------------------------------------------------------------------------------
  104. void W3DPropDraw::crc( Xfer *xfer )
  105. {
  106. // extend base class
  107. DrawModule::crc( xfer );
  108. } // end crc
  109. // ------------------------------------------------------------------------------------------------
  110. /** Xfer method
  111. * Version Info:
  112. * 1: Initial version */
  113. // ------------------------------------------------------------------------------------------------
  114. void W3DPropDraw::xfer( Xfer *xfer )
  115. {
  116. // version
  117. XferVersion currentVersion = 1;
  118. XferVersion version = currentVersion;
  119. xfer->xferVersion( &version, currentVersion );
  120. // extend base class
  121. DrawModule::xfer( xfer );
  122. // no data to save here, nobody will ever notice
  123. } // end xfer
  124. // ------------------------------------------------------------------------------------------------
  125. /** Load post process */
  126. // ------------------------------------------------------------------------------------------------
  127. void W3DPropDraw::loadPostProcess( void )
  128. {
  129. // extend base class
  130. DrawModule::loadPostProcess();
  131. } // end loadPostProcess