| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- /*
- ** Command & Conquer Generals Zero Hour(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // (c) 2001-2003 Electronic Arts Inc. //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- // FILE: W3DTreeDraw.cpp ////////////////////////////////////////////////////////////////////////
- // Author: Colin Day, December 2001
- // Desc: Tracer drawing
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
- #include <stdlib.h>
- #include "Common/Thing.h"
- #include "Common/ThingTemplate.h"
- #include "Common/Xfer.h"
- #include "GameLogic/Object.h"
- #include "GameClient/Drawable.h"
- #include "W3DDevice/GameClient/Module/W3DTreeDraw.h"
- #include "W3DDevice/GameClient/BaseHeightMap.h"
- #ifdef _INTERNAL
- // for occasional debugging...
- //#pragma optimize("", off)
- //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
- #endif
- //-------------------------------------------------------------------------------------------------
- W3DTreeDrawModuleData::W3DTreeDrawModuleData() :
- m_framesToMoveInward(1),
- m_framesToMoveOutward(1),
- m_darkening(0.0f),
- m_maxOutwardMovement(1.0f)
- {
- // Topple parameters. [7/7/2003]
- const Real START_VELOCITY_PERCENT = 0.2f;
- const Real START_ACCEL_PERCENT = 0.01f;
- const Real VELOCITY_BOUNCE_PERCENT = 0.3f; // multiply the velocity by this when you bounce
- const Real MINIMUM_TOPPLE_SPEED = 0.5f; // Won't let trees fall slower than this
- m_toppleFX = NULL;
- m_bounceFX = NULL;
- m_stumpName.clear();
- m_killWhenToppled = true;
- m_doTopple = false;
- m_doShadow = false;
- m_initialVelocityPercent = START_VELOCITY_PERCENT;
- m_initialAccelPercent = START_ACCEL_PERCENT;
- m_bounceVelocityPercent = VELOCITY_BOUNCE_PERCENT;
- m_minimumToppleSpeed = MINIMUM_TOPPLE_SPEED;
- m_sinkFrames = 10*LOGICFRAMES_PER_SECOND;
- m_sinkDistance = 20.0f;
- }
- //-------------------------------------------------------------------------------------------------
- W3DTreeDrawModuleData::~W3DTreeDrawModuleData()
- {
- }
- //-------------------------------------------------------------------------------------------------
- void W3DTreeDrawModuleData::buildFieldParse(MultiIniFieldParse& p)
- {
- ModuleData::buildFieldParse(p);
- static const FieldParse dataFieldParse[] =
- {
- { "ModelName", INI::parseAsciiString, NULL, offsetof(W3DTreeDrawModuleData, m_modelName) },
- { "TextureName", INI::parseAsciiString, NULL, offsetof(W3DTreeDrawModuleData, m_textureName) },
- { "MoveOutwardTime", INI::parseDurationUnsignedInt, NULL, offsetof(W3DTreeDrawModuleData, m_framesToMoveOutward) },
- { "MoveInwardTime", INI::parseDurationUnsignedInt, NULL, offsetof(W3DTreeDrawModuleData, m_framesToMoveInward) },
- { "MoveOutwardDistanceFactor", INI::parseReal, NULL, offsetof(W3DTreeDrawModuleData, m_maxOutwardMovement) },
- { "DarkeningFactor", INI::parseReal, NULL, offsetof(W3DTreeDrawModuleData, m_darkening) },
- // Topple parameters [7/7/2003]
- { "ToppleFX", INI::parseFXList, NULL, offsetof( W3DTreeDrawModuleData, m_toppleFX ) },
- { "BounceFX", INI::parseFXList, NULL, offsetof( W3DTreeDrawModuleData, m_bounceFX ) },
- { "StumpName", INI::parseAsciiString, NULL, offsetof( W3DTreeDrawModuleData, m_stumpName ) },
- { "KillWhenFinishedToppling", INI::parseBool, NULL, offsetof( W3DTreeDrawModuleData, m_killWhenToppled ) },
- { "DoTopple", INI::parseBool, NULL, offsetof( W3DTreeDrawModuleData, m_doTopple ) },
- { "InitialVelocityPercent", INI::parsePercentToReal, NULL, offsetof( W3DTreeDrawModuleData, m_initialVelocityPercent ) },
- { "InitialAccelPercent", INI::parsePercentToReal, NULL, offsetof( W3DTreeDrawModuleData, m_initialAccelPercent ) },
- { "BounceVelocityPercent", INI::parsePercentToReal, NULL, offsetof( W3DTreeDrawModuleData, m_bounceVelocityPercent ) },
- { "MinimumToppleSpeed", INI::parsePositiveNonZeroReal, NULL, offsetof( W3DTreeDrawModuleData, m_minimumToppleSpeed ) },
- { "SinkDistance", INI::parsePositiveNonZeroReal, NULL, offsetof( W3DTreeDrawModuleData, m_sinkDistance ) },
- { "SinkTime", INI::parseDurationUnsignedInt, NULL, offsetof(W3DTreeDrawModuleData, m_sinkFrames) },
- { "DoShadow", INI::parseBool, NULL, offsetof( W3DTreeDrawModuleData, m_doShadow ) },
- { 0, 0, 0, 0 }
- };
- p.add(dataFieldParse);
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- //-------------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------
- W3DTreeDraw::W3DTreeDraw( Thing *thing, const ModuleData* moduleData ) : DrawModule( thing, moduleData ),
- m_treeAdded(false)
- {
- } // end W3DTreeDraw
- //-------------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------
- W3DTreeDraw::~W3DTreeDraw( void )
- {
- }
- //-------------------------------------------------------------------------------------------------
- void W3DTreeDraw::reactToTransformChange( const Matrix3D *oldMtx,
- const Coord3D *oldPos,
- Real oldAngle )
- {
- Drawable *draw = getDrawable();
- if (m_treeAdded) {
- return;
- }
- if (draw->getPosition()->x==0.0f && draw->getPosition()->y == 0.0f) {
- return;
- }
- m_treeAdded = true;
- const W3DTreeDrawModuleData *moduleData = getW3DTreeDrawModuleData();
- if (!moduleData) {
- return;
- }
- Real scale = draw->getScale();
- Real scaleRandomness = draw->getTemplate()->getInstanceScaleFuzziness();
- scaleRandomness = 0.0f; // We use the scale fuzziness inside WB to generate random scales, so they don't change at load time. jba. [4/22/2003]
- TheTerrainRenderObject->addTree(draw->getID(), *draw->getPosition(),
- scale, draw->getOrientation(), scaleRandomness, moduleData);
-
- }
- //-------------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------
- void W3DTreeDraw::doDrawModule(const Matrix3D* transformMtx)
- {
- return;
- }
- // ------------------------------------------------------------------------------------------------
- /** CRC */
- // ------------------------------------------------------------------------------------------------
- void W3DTreeDraw::crc( Xfer *xfer )
- {
- // extend base class
- DrawModule::crc( xfer );
- } // end crc
- // ------------------------------------------------------------------------------------------------
- /** Xfer method
- * Version Info:
- * 1: Initial version */
- // ------------------------------------------------------------------------------------------------
- void W3DTreeDraw::xfer( Xfer *xfer )
- {
- // version
- XferVersion currentVersion = 1;
- XferVersion version = currentVersion;
- xfer->xferVersion( &version, currentVersion );
- // extend base class
- DrawModule::xfer( xfer );
- // no data to save here, nobody will ever notice
- } // end xfer
- // ------------------------------------------------------------------------------------------------
- /** Load post process */
- // ------------------------------------------------------------------------------------------------
- void W3DTreeDraw::loadPostProcess( void )
- {
- // extend base class
- DrawModule::loadPostProcess();
- } // end loadPostProcess
|