W3DOverlordAircraftDraw.cpp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  24. //
  25. // FILE: W3DOverlordAircraftDraw.h
  26. // Author: Mark Lorenzen, April 2003
  27. // Desc: Units that recieve portable structure upgrades (like the OverlordTnk) have a super specific special need.
  28. // He needs his rider to draw explicitly after him,
  29. // and he needs direct access to get that rider when everyone else can't see it because of the OverlordContain.
  30. // In the case of aircraft (Helix, SpectreGunship, etc.) we need this draw module which mimics the OverlordTnkDraw
  31. // but does not draw treads, trackmarks, turrets, etc. Whee!
  32. //
  33. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  34. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  35. #include "Common/Xfer.h"
  36. #include "GameClient/Drawable.h"
  37. #include "GameLogic/Object.h"
  38. #include "GameLogic/Module/ContainModule.h"
  39. #include "W3DDevice/GameClient/Module/W3DOverlordAircraftDraw.h"
  40. #ifdef _INTERNAL
  41. // for occasional debugging...
  42. //#pragma optimize("", off)
  43. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  44. #endif
  45. //-------------------------------------------------------------------------------------------------
  46. W3DOverlordAircraftDrawModuleData::W3DOverlordAircraftDrawModuleData()
  47. {
  48. }
  49. //-------------------------------------------------------------------------------------------------
  50. W3DOverlordAircraftDrawModuleData::~W3DOverlordAircraftDrawModuleData()
  51. {
  52. }
  53. //-------------------------------------------------------------------------------------------------
  54. void W3DOverlordAircraftDrawModuleData::buildFieldParse(MultiIniFieldParse& p)
  55. {
  56. W3DModelDrawModuleData::buildFieldParse(p);
  57. static const FieldParse dataFieldParse[] =
  58. {
  59. { 0, 0, 0, 0 }
  60. };
  61. p.add(dataFieldParse);
  62. }
  63. //-------------------------------------------------------------------------------------------------
  64. //-------------------------------------------------------------------------------------------------
  65. W3DOverlordAircraftDraw::W3DOverlordAircraftDraw( Thing *thing, const ModuleData* moduleData )
  66. : W3DModelDraw( thing, moduleData )
  67. {
  68. }
  69. //-------------------------------------------------------------------------------------------------
  70. //-------------------------------------------------------------------------------------------------
  71. W3DOverlordAircraftDraw::~W3DOverlordAircraftDraw()
  72. {
  73. }
  74. //-------------------------------------------------------------------------------------------------
  75. void W3DOverlordAircraftDraw::doDrawModule(const Matrix3D* transformMtx)
  76. {
  77. W3DModelDraw::doDrawModule(transformMtx);
  78. // Our big thing is that we get our specific passenger (the turret thing) and then wake it up and make it draw
  79. // It depends on us because our renderObject is only made correct in the act of drawing.
  80. Object *me = getDrawable()->getObject();
  81. if( me
  82. && me->getContain()
  83. && me->getContain()->friend_getRider()
  84. && me->getContain()->friend_getRider()->getDrawable()
  85. )
  86. {
  87. Drawable *riderDraw = me->getContain()->friend_getRider()->getDrawable();
  88. if ( riderDraw )
  89. {
  90. TintEnvelope *env = getDrawable()->getColorTintEnvelope();
  91. if ( env )
  92. riderDraw->setColorTintEnvelope( *env );
  93. riderDraw->notifyDrawableDependencyCleared();
  94. riderDraw->draw( NULL );// What the hell? This param isn't used for anything
  95. }
  96. DEBUG_ASSERTCRASH( riderDraw, ("OverlordAircraftDraw finds no rider's drawable") );
  97. }
  98. }
  99. //-------------------------------------------------------------------------------------------------
  100. void W3DOverlordAircraftDraw::setHidden(Bool h)
  101. {
  102. W3DModelDraw::setHidden(h);
  103. // We need to hide our rider, since he won't realize he's being contained in a contained container
  104. Object *me = getDrawable()->getObject();
  105. if( me
  106. && me->getContain()
  107. && me->getContain()->friend_getRider()
  108. && me->getContain()->friend_getRider()->getDrawable()
  109. )
  110. {
  111. me->getContain()->friend_getRider()->getDrawable()->setDrawableHidden(h);
  112. }
  113. }
  114. //-------------------------------------------------------------------------------------------------
  115. // ------------------------------------------------------------------------------------------------
  116. /** CRC */
  117. // ------------------------------------------------------------------------------------------------
  118. void W3DOverlordAircraftDraw::crc( Xfer *xfer )
  119. {
  120. // extend base class
  121. W3DModelDraw::crc( xfer );
  122. } // end crc
  123. // ------------------------------------------------------------------------------------------------
  124. /** Xfer method
  125. * Version Info:
  126. * 1: Initial version */
  127. // ------------------------------------------------------------------------------------------------
  128. void W3DOverlordAircraftDraw::xfer( Xfer *xfer )
  129. {
  130. // version
  131. XferVersion currentVersion = 1;
  132. XferVersion version = currentVersion;
  133. xfer->xferVersion( &version, currentVersion );
  134. // extend base class
  135. W3DModelDraw::xfer( xfer );
  136. } // end xfer
  137. // ------------------------------------------------------------------------------------------------
  138. /** Load post process */
  139. // ------------------------------------------------------------------------------------------------
  140. void W3DOverlordAircraftDraw::loadPostProcess( void )
  141. {
  142. // extend base class
  143. W3DModelDraw::loadPostProcess();
  144. } // end loadPostProcess