Initial commit of Command & Conquer Generals and Command & Conquer Generals Zero Hour source code.

This commit is contained in:
LFeenanEA 2025-02-27 17:34:39 +00:00
parent 2e338c00cb
commit 3d0ee53a05
No known key found for this signature in database
GPG key ID: C6EBE8C2EA08F7E0
6072 changed files with 2283311 additions and 0 deletions

View file

@ -0,0 +1,330 @@
/*
** Command & Conquer Generals(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/>.
*/
// FILE: MilesAudioManager.h //////////////////////////////////////////////////////////////////////////
// MilesAudioManager implementation
// Author: John K. McDonald, July 2002
#include "Common/AsciiString.h"
#include "Common/GameAudio.h"
#include "MSS/MSS.h"
class AudioEventRTS;
enum { MAXPROVIDERS = 64 };
enum PlayingAudioType
{
PAT_Sample,
PAT_3DSample,
PAT_Stream,
PAT_INVALID
};
enum PlayingStatus
{
PS_Playing,
PS_Stopped,
PS_Paused
};
enum PlayingWhich
{
PW_Attack,
PW_Sound,
PW_Decay,
PW_INVALID
};
struct PlayingAudio
{
union
{
HSAMPLE m_sample;
H3DSAMPLE m_3DSample;
HSTREAM m_stream;
};
PlayingAudioType m_type;
volatile PlayingStatus m_status; // This member is adjusted by another running thread.
AudioEventRTS *m_audioEventRTS;
void *m_file; // The file that was opened to play this
Bool m_requestStop;
Bool m_cleanupAudioEventRTS;
Int m_framesFaded;
PlayingAudio() :
m_type(PAT_INVALID),
m_audioEventRTS(NULL),
m_requestStop(false),
m_cleanupAudioEventRTS(true),
m_framesFaded(0)
{ }
};
struct ProviderInfo
{
AsciiString name;
HPROVIDER id;
Bool m_isValid;
};
struct OpenAudioFile
{
AILSOUNDINFO m_soundInfo;
void *m_file;
UnsignedInt m_openCount;
UnsignedInt m_fileSize;
Bool m_compressed; // if the file was compressed, then we need to free it with a miles function.
// Note: OpenAudioFile does not own this m_eventInfo, and should not delete it.
const AudioEventInfo *m_eventInfo; // Not mutable, unlike the one on AudioEventRTS.
};
typedef std::hash_map< AsciiString, OpenAudioFile, rts::hash<AsciiString>, rts::equal_to<AsciiString> > OpenFilesHash;
typedef OpenFilesHash::iterator OpenFilesHashIt;
class AudioFileCache
{
public:
AudioFileCache();
// Protected by mutex
virtual ~AudioFileCache();
void *openFile( AudioEventRTS *eventToOpenFrom );
void closeFile( void *fileToClose );
void setMaxSize( UnsignedInt size );
// End Protected by mutex
// Note: These functions should be used for informational purposes only. For speed reasons,
// they are not protected by the mutex, so they are not guarenteed to be valid if called from
// outside the audio cache. They should be used as a rough estimate only.
UnsignedInt getCurrentlyUsedSize() const { return m_currentlyUsedSize; }
UnsignedInt getMaxSize() const { return m_maxSize; }
protected:
void releaseOpenAudioFile( OpenAudioFile *fileToRelease );
// This function will return TRUE if it was able to free enough space, and FALSE otherwise.
Bool freeEnoughSpaceForSample(const OpenAudioFile& sampleThatNeedsSpace);
OpenFilesHash m_openFiles;
UnsignedInt m_currentlyUsedSize;
UnsignedInt m_maxSize;
HANDLE m_mutex;
const char *m_mutexName;
};
class MilesAudioManager : public AudioManager
{
public:
#if defined(_DEBUG) || defined(_INTERNAL)
virtual void audioDebugDisplay(DebugDisplayInterface *dd, void *, FILE *fp = NULL );
virtual AudioHandle addAudioEvent( const AudioEventRTS *eventToAdd ); ///< Add an audio event (event must be declared in an INI file)
#endif
// from AudioDevice
virtual void init();
virtual void postProcessLoad();
virtual void reset();
virtual void update();
MilesAudioManager();
virtual ~MilesAudioManager();
virtual void nextMusicTrack( void );
virtual void prevMusicTrack( void );
virtual Bool isMusicPlaying( void ) const;
virtual Bool hasMusicTrackCompleted( const AsciiString& trackName, Int numberOfTimes ) const;
virtual AsciiString getMusicTrackName( void ) const;
virtual void openDevice( void );
virtual void closeDevice( void );
virtual void *getDevice( void ) { return m_digitalHandle; }
virtual void stopAudio( AudioAffect which );
virtual void pauseAudio( AudioAffect which );
virtual void resumeAudio( AudioAffect which );
virtual void pauseAmbient( Bool shouldPause );
virtual void killAudioEventImmediately( AudioHandle audioEvent );
virtual void stopAllAmbientsBy( Object *objID );
virtual void stopAllAmbientsBy( Drawable *drawID );
///< Return whether the current audio is playing or not.
///< NOTE NOTE NOTE !!DO NOT USE THIS IN FOR GAMELOGIC PURPOSES!! NOTE NOTE NOTE
virtual Bool isCurrentlyPlaying( AudioHandle handle );
virtual void notifyOfAudioCompletion( UnsignedInt audioCompleted, UnsignedInt flags );
virtual PlayingAudio *findPlayingAudioFrom( UnsignedInt audioCompleted, UnsignedInt flags );
virtual UnsignedInt getProviderCount( void ) const;
virtual AsciiString getProviderName( UnsignedInt providerNum ) const;
virtual UnsignedInt getProviderIndex( AsciiString providerName ) const;
virtual void selectProvider( UnsignedInt providerNdx );
virtual void unselectProvider( void );
virtual UnsignedInt getSelectedProvider( void ) const;
virtual void setSpeakerType( UnsignedInt speakerType );
virtual UnsignedInt getSpeakerType( void );
virtual void *getHandleForBink( void );
virtual void releaseHandleForBink( void );
virtual void friend_forcePlayAudioEventRTS(const AudioEventRTS* eventToPlay);
virtual UnsignedInt getNum2DSamples( void ) const;
virtual UnsignedInt getNum3DSamples( void ) const;
virtual UnsignedInt getNumStreams( void ) const;
virtual Bool doesViolateLimit( AudioEventRTS *event ) const;
virtual Bool isPlayingLowerPriority( AudioEventRTS *event ) const;
virtual Bool isPlayingAlready( AudioEventRTS *event ) const;
virtual Bool isObjectPlayingVoice( UnsignedInt objID ) const;
Bool killLowestPrioritySoundImmediately( AudioEventRTS *event );
AudioEventRTS* findLowestPrioritySound( AudioEventRTS *event );
virtual void adjustVolumeOfPlayingAudio(AsciiString eventName, Real newVolume);
virtual void removePlayingAudio( AsciiString eventName );
virtual void removeAllDisabledAudio();
virtual void processRequestList( void );
virtual void processPlayingList( void );
virtual void processFadingList( void );
virtual void processStoppedList( void );
Bool shouldProcessRequestThisFrame( AudioRequest *req ) const;
void adjustRequest( AudioRequest *req );
Bool checkForSample( AudioRequest *req );
virtual void setHardwareAccelerated(Bool accel);
virtual void setSpeakerSurround(Bool surround);
virtual void setPreferredProvider(AsciiString provider) { m_pref3DProvider = provider; }
virtual void setPreferredSpeaker(AsciiString speakerType) { m_prefSpeaker = speakerType; }
virtual Real getFileLengthMS( AsciiString strToLoad ) const;
virtual void closeAnySamplesUsingFile( const void *fileToClose );
protected:
// 3-D functions
virtual void setDeviceListenerPosition( void );
const Coord3D *getCurrentPositionFromEvent( AudioEventRTS *event );
Bool isOnScreen( const Coord3D *pos ) const;
Real getEffectiveVolume(AudioEventRTS *event) const;
// Looping functions
Bool startNextLoop( PlayingAudio *looping );
void playStream( AudioEventRTS *event, HSTREAM stream );
// Returns the file handle for attachment to the PlayingAudio structure
void *playSample( AudioEventRTS *event, HSAMPLE sample );
void *playSample3D( AudioEventRTS *event, H3DSAMPLE sample3D );
protected:
void buildProviderList( void );
void createListener( void );
void initDelayFilter( void );
Bool isValidProvider( void );
void initSamplePools( void );
void processRequest( AudioRequest *req );
void playAudioEvent( AudioEventRTS *event );
void stopAudioEvent( AudioHandle handle );
void pauseAudioEvent( AudioHandle handle );
void *loadFileForRead( AudioEventRTS *eventToLoadFrom );
void closeFile( void *fileRead );
PlayingAudio *allocatePlayingAudio( void );
void releaseMilesHandles( PlayingAudio *release );
void releasePlayingAudio( PlayingAudio *release );
void stopAllAudioImmediately( void );
void freeAllMilesHandles( void );
HSAMPLE getFirst2DSample( AudioEventRTS *event );
H3DSAMPLE getFirst3DSample( AudioEventRTS *event );
void adjustPlayingVolume( PlayingAudio *audio );
void stopAllSpeech( void );
protected:
void initFilters( HSAMPLE sample, const AudioEventRTS *eventInfo );
void initFilters3D( H3DSAMPLE sample, const AudioEventRTS *eventInfo, const Coord3D *pos );
protected:
ProviderInfo m_provider3D[MAXPROVIDERS];
UnsignedInt m_providerCount;
UnsignedInt m_selectedProvider;
UnsignedInt m_lastProvider;
UnsignedInt m_selectedSpeakerType;
AsciiString m_pref3DProvider;
AsciiString m_prefSpeaker;
HDIGDRIVER m_digitalHandle;
H3DPOBJECT m_listener;
HPROVIDER m_delayFilter;
// This is a list of all handles that are forcibly played. They always play as UI sounds.
std::list<HAUDIO> m_audioForcePlayed;
// Available handles for play. Note that there aren't handles open in advance for
// streaming things, only 2-D and 3-D sounds.
std::list<HSAMPLE> m_availableSamples;
std::list<H3DSAMPLE> m_available3DSamples;
// Currently Playing stuff. Useful if we have to preempt it.
// This should rarely if ever happen, as we mirror this in Sounds, and attempt to
// keep preemption from taking place here.
std::list<PlayingAudio *> m_playingSounds;
std::list<PlayingAudio *> m_playing3DSounds;
std::list<PlayingAudio *> m_playingStreams;
// Currently fading stuff. At this point, we just want to let it finish fading, when it is
// done it should be added to the completed list, then "freed" and the counts should be updated
// on the next update
std::list<PlayingAudio *> m_fadingAudio;
// Stuff that is done playing (either because it has finished or because it was killed)
// This stuff should be cleaned up during the next update cycle. This includes updating counts
// in the sound engine
std::list<PlayingAudio *> m_stoppedAudio;
AudioFileCache *m_audioCache;
PlayingAudio *m_binkHandle;
UnsignedInt m_num2DSamples;
UnsignedInt m_num3DSamples;
UnsignedInt m_numStreams;
#if defined(_DEBUG) || defined(_INTERNAL)
typedef std::set<AsciiString> SetAsciiString;
typedef SetAsciiString::iterator SetAsciiStringIt;
SetAsciiString m_allEventsLoaded;
void dumpAllAssetsUsed();
#endif
};

View file

@ -0,0 +1,143 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//----------------------------------------------------------------------------
//
// Project: Generals
//
// File name: GameClient/VideoPlayer.h
//
// Created: 10/22/01
//
//----------------------------------------------------------------------------
#pragma once
#ifndef __VIDEODEVICE_BINKDEVICE_H_
#define __VIDEODEVICE_BINKDEVICE_H_
//----------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------
#include "GameClient/VideoPlayer.h"
#include "bink.h"
//----------------------------------------------------------------------------
// Forward References
//----------------------------------------------------------------------------
class BinkVideoPlayer;
//----------------------------------------------------------------------------
// Type Defines
//----------------------------------------------------------------------------
//===============================
// BinkVideoStream
//===============================
class BinkVideoStream : public VideoStream
{
friend class BinkVideoPlayer;
protected:
HBINK m_handle; ///< Bink streaming handle;
Char *m_memFile; ///< Pointer to memory resident file
BinkVideoStream(); ///< only BinkVideoPlayer can create these
virtual ~BinkVideoStream();
public:
virtual void update( void ); ///< Update bink stream
virtual Bool isFrameReady( void ); ///< Is the frame ready to be displayed
virtual void frameDecompress( void ); ///< Render current frame in to buffer
virtual void frameRender( VideoBuffer *buffer ); ///< Render current frame in to buffer
virtual void frameNext( void ); ///< Advance to next frame
virtual Int frameIndex( void ); ///< Returns zero based index of current frame
virtual Int frameCount( void ); ///< Returns the total number of frames in the stream
virtual void frameGoto( Int index ); ///< Go to the spcified frame index
virtual Int height( void ); ///< Return the height of the video
virtual Int width( void ); ///< Return the width of the video
};
//===============================
// BinkVideoPlayer
//===============================
/**
* Bink video playback code.
*/
//===============================
class BinkVideoPlayer : public VideoPlayer
{
protected:
VideoStreamInterface* createStream( HBINK handle );
public:
// subsytem requirements
virtual void init( void ); ///< Initialize video playback code
virtual void reset( void ); ///< Reset video playback
virtual void update( void ); ///< Services all audio tasks. Should be called frequently
virtual void deinit( void ); ///< Close down player
BinkVideoPlayer();
~BinkVideoPlayer();
// service
virtual void loseFocus( void ); ///< Should be called when application loses focus
virtual void regainFocus( void ); ///< Should be called when application regains focus
virtual VideoStreamInterface* open( AsciiString movieTitle ); ///< Open video file for playback
virtual VideoStreamInterface* load( AsciiString movieTitle ); ///< Load video file in to memory for playback
virtual void notifyVideoPlayerOfNewProvider( Bool nowHasValid );
virtual void initializeBinkWithMiles( void );
};
//----------------------------------------------------------------------------
// Inlining
//----------------------------------------------------------------------------
#endif // __VIDEODEVICE_BINKDEVICE_H_

View file

@ -0,0 +1,68 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
//==============================================================================
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//=============================================================================
//
// Project: RTS3
//
// File name: W3DConvert.h
//
// Created: Colin Day, April 2001
//
//=============================================================================
#pragma once
#ifndef __W3DCONVERT_H_
#define __W3DCONVERT_H_
//=============================================================================
// Includes
//=============================================================================
#include "Lib/BaseType.h"
//=============================================================================
// Forward References
//=============================================================================
extern void W3DLogicalScreenToPixelScreen( Real logX, Real logY,
Int *screenX, Int *screenY,
Int screenWidth, Int screenHeight );
extern void PixelScreenToW3DLogicalScreen( Int screenX, Int screenY,
Real *logX, Real *logY,
Int screenWidth, Int screenHeight );
//=============================================================================
// Type Defines
//=============================================================================
#endif // _W3DCONVERT_H_

View file

@ -0,0 +1,57 @@
/*
** Command & Conquer Generals(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: W3DFunctionLexicon.h /////////////////////////////////////////////////////////////////////
// Created: Colin Day, September 2001
// Desc: Function lexicon for w3d specific funtion pointers
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DFUNCTIONLEXICON_H_
#define __W3DFUNCTIONLEXICON_H_
#include "Common/FunctionLexicon.h"
//-------------------------------------------------------------------------------------------------
/** The function lexicon that can also contain w3d device methods */
//-------------------------------------------------------------------------------------------------
class W3DFunctionLexicon : public FunctionLexicon
{
public:
W3DFunctionLexicon( void );
virtual ~W3DFunctionLexicon( void );
virtual void init( void );
virtual void reset( void );
virtual void update( void );
protected:
};
#endif // __W3DFUNCTIONLEXICON_H_

View file

@ -0,0 +1,53 @@
/*
** Command & Conquer Generals(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: W3DModuleFactory.h ///////////////////////////////////////////////////////////////////////
// Author: Steven Johnson, September 2001
// Colin Day, November 2001
// Desc: W3D game logic class, there shouldn't be a lot of new functionality
// in this class, but there are certain things that need to have close
// knowledge of each other like ther logical and visual terrain
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DMODULEFACTORY_H_
#define __W3DMODULEFACTORY_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/ModuleFactory.h"
//-------------------------------------------------------------------------------------------------
/** W3D specific functionality for the module factory */
//-------------------------------------------------------------------------------------------------
class W3DModuleFactory : public ModuleFactory
{
public:
virtual void init( void );
};
#endif // __W3DMODULEFACTORY_H_

View file

@ -0,0 +1,125 @@
/*
** Command & Conquer Generals(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: W3DRadar.h ///////////////////////////////////////////////////////////////////////////////
// Author: Colin Day, January 2002
// Desc: W3D radar implementation, this has the necessary device dependent drawing
// necessary for the radar
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DRADAR_H_
#define __W3DRADAR_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/Radar.h"
#include "WW3D2/WW3DFormat.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
class TextureClass;
class TerrainLogic;
// PROTOTYPES /////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------------
/** W3D radar class. This has the device specific implementation of the radar such as
* the drawing routines */
//-------------------------------------------------------------------------------------------------
class W3DRadar : public Radar
{
public:
W3DRadar( void );
~W3DRadar( void );
virtual void init( void ); ///< subsystem init
virtual void update( void ); ///< subsystem update
virtual void reset( void ); ///< subsystem reset
virtual void newMap( TerrainLogic *terrain ); ///< reset radar for new map
void draw( Int pixelX, Int pixelY, Int width, Int height ); ///< draw the radar
virtual void clearShroud();
virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting);
virtual void refreshTerrain( TerrainLogic *terrain );
protected:
void drawSingleBeaconEvent( Int pixelX, Int pixelY, Int width, Int height, Int index );
void drawSingleGenericEvent( Int pixelX, Int pixelY, Int width, Int height, Int index );
void initializeTextureFormats( void ); ///< find format to use for the radar texture
void deleteResources( void ); ///< delete resources used
void drawEvents( Int pixelX, Int pixelY, Int width, Int height); ///< draw all of the radar events
void drawHeroIcon( Int pixelX, Int pixelY, Int width, Int height, const Coord3D *pos ); //< draw a hero icon
void drawViewBox( Int pixelX, Int pixelY, Int width, Int height ); ///< draw view box
void buildTerrainTexture( TerrainLogic *terrain ); ///< create the terrain texture of the radar
void drawIcons( Int pixelX, Int pixelY, Int width, Int height ); ///< draw all of the radar icons
void renderObjectList( const RadarObject *listHead, TextureClass *texture, Bool calcHero = FALSE ); ///< render an object list to the texture
void interpolateColorForHeight( RGBColor *color,
Real height,
Real hiZ,
Real midZ,
Real loZ ); ///< "shade" color according to height value
void reconstructViewBox( void ); ///< remake the view box
void radarToPixel( const ICoord2D *radar, ICoord2D *pixel,
Int radarUpperLeftX, Int radarUpperLeftY,
Int radarWidth, Int radarHeight ); ///< convert radar coord to pixel location
WW3DFormat m_terrainTextureFormat; ///< format to use for terrain texture
Image *m_terrainImage; ///< terrain image abstraction for drawing
TextureClass *m_terrainTexture; ///< terrain background texture
WW3DFormat m_overlayTextureFormat; ///< format to use for overlay texture
Image *m_overlayImage; ///< overlay image abstraction for drawing
TextureClass *m_overlayTexture; ///< overlay texture
WW3DFormat m_shroudTextureFormat; ///< format to use for shroud texture
Image *m_shroudImage; ///< shroud image abstraction for drawing
TextureClass *m_shroudTexture; ///< shroud texture
Int m_textureWidth; ///< width for all radar textures
Int m_textureHeight; ///< height for all radar textures
//
// we want to keep a flag that tells us when to reconstruct the view box, we want
// to reconstruct the box on map change, and when the camera changes height
// or orientation. We want to avoid making the view box every frame because
// the 4 points visible on the edge of the screen will "jitter" unevenly as we
// translate real world coords to integer radar spots
//
Bool m_reconstructViewBox; ///< true when we need to reconstruct the box
Real m_viewAngle; ///< camera angle used for the view box we have
Real m_viewZoom; ///< camera zoom used for the view box we have
ICoord2D m_viewBox[ 4 ]; ///< radar cell points for the 4 corners of view box
std::list<const Coord3D *> m_cachedHeroPosList; //< cache of hero positions for drawing icons in radar overlay
};
#endif // __W3DRADAR_H_

View file

@ -0,0 +1,52 @@
/*
** Command & Conquer Generals(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: W3DThingFactory.h ////////////////////////////////////////////////////////////////////////
// Author: Colin Day, February 2002
// Desc: Device dependent thing factory access, for things like post processing the
// Thing database where we might want to look at device dependent stuff like
// model info and such
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DTHINGFACTORY_H_
#define __W3DTHINGFACTORY_H_
// USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
#include "Common/ThingFactory.h"
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
class W3DThingFactory : public ThingFactory
{
public:
W3DThingFactory( void );
virtual ~W3DThingFactory( void );
}; // end W3DThingFactory
#endif // __W3DTHINGFACTORY_H_

View file

@ -0,0 +1,326 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __HEIGHTMAP_H_
#define __HEIGHTMAP_H_
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "dx8wrapper.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#include "common/GameType.h"
#include "WorldHeightMap.h"
#define MAX_ENABLED_DYNAMIC_LIGHTS 20
typedef UnsignedByte HeightSampleType; //type of data to store in heightmap
class W3DTreeBuffer;
class W3DBibBuffer;
class W3DRoadBuffer;
class W3DBridgeBuffer;
class W3DWaypointBuffer;
class W3DTerrainLogic;
class W3DCustomEdging;
class W3DAssetManager;
class SimpleSceneClass;
class W3DShroud;
#define no_TIMING_TESTS 1
#define no_PRE_TRANSFORM_VERTEX // Don't do this, not a performance win. jba.
#define no_USE_TREE_BUFFER ///@todoRe-enable this optimization later... jba.
typedef struct {
Int minX, maxX;
Int minY, maxY;
} TBounds;
#define VERTEX_BUFFER_TILE_LENGTH 32 //tiles of side length 32 (grid of 33x33 vertices).
class LightMapTerrainTextureClass;
class CloudMapTerrainTextureClass;
class W3DDynamicLight;
#if 0
#define USE_NORMALS 1
#define VERTEX_FORMAT VertexFormatXYZNUV2
#else
#define USE_DIFFUSE 1
#define VERTEX_FORMAT VertexFormatXYZDUV2
#define DX8_VERTEX_FORMAT DX8_FVF_XYZDUV2
#endif
#define DO_SCORCH 1
#define DO_ROADS 1
#define TEST_CUSTOM_EDGING 1
// Adjust the triangles to make cliff sides most attractive. jba.
#define FLIP_TRIANGLES 1
#ifdef DO_SCORCH
typedef struct {
Vector3 location;
Real radius;
Int scorchType;
} TScorch;
#endif
/// Custom render object that draws the heightmap and handles intersection tests.
/**
Custom W3D render object that's used to process the terrain. It handles
virtually everything to do with the terrain, including: drawing, lighting,
scorchmarks and intersection tests.
*/
class HeightMapRenderObjClass : public RenderObjClass, public DX8_CleanupHook
{
public:
HeightMapRenderObjClass(void);
~HeightMapRenderObjClass(void);
// DX8_CleanupHook methods
virtual void ReleaseResources(void); ///< Release all dx8 resources so the device can be reset.
virtual void ReAcquireResources(void); ///< Reacquire all resources after device reset.
/////////////////////////////////////////////////////////////////////////////
// Render Object Interface (W3D methods)
/////////////////////////////////////////////////////////////////////////////
virtual RenderObjClass * Clone(void) const;
virtual int Class_ID(void) const;
virtual void Render(RenderInfoClass & rinfo);
virtual bool Cast_Ray(RayCollisionTestClass & raytest); // This CANNOT be Bool, as it will not inherit properly if you make Bool == Int
///@todo: Add methods for collision detection with terrain
// virtual Bool Cast_AABox(AABoxCollisionTestClass & boxtest);
// virtual Bool Cast_OBBox(OBBoxCollisionTestClass & boxtest);
// virtual Bool Intersect_AABox(AABoxIntersectionTestClass & boxtest);
// virtual Bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest);
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const;
virtual void On_Frame_Update(void);
virtual void Notify_Added(SceneClass * scene);
///allocate resources needed to render heightmap
int initHeightData(Int width, Int height, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator);
Int freeMapResources(void); ///< free resources used to render heightmap
inline UnsignedByte getClipHeight(Int x, Int y) const
{
Int xextent = m_map->getXExtent() - 1;
Int yextent = m_map->getYExtent() - 1;
if (x < 0)
x = 0;
else if (x > xextent)
x = xextent;
if (y < 0)
y = 0;
else if (y > yextent)
y = yextent;
return m_map->getDataPtr()[x + y*m_map->getXExtent()];
}
void updateCenter(CameraClass *camera, RefRenderObjListIterator *pLightsIterator);
/// Update the macro texture (pass 3).
void updateMacroTexture(AsciiString textureName);
void doTextures(Bool flag) {m_disableTextures = !flag;};
/// Update the diffuse value from static light info for one vertex.
void doTheLight(VERTEX_FORMAT *vb, Vector3*light, Vector3*normal, RefRenderObjListIterator *pLightsIterator, UnsignedByte alpha);
void addScorch(Vector3 location, Real radius, Scorches type);
void addTree(Coord3D location, Real scale, Real angle, AsciiString name, Bool visibleInMirror);
void renderTrees(CameraClass * camera); ///< renders the tree buffer.
/// Add a bib at location.
void addTerrainBib(Vector3 corners[4], ObjectID id, Bool highlight);
void addTerrainBibDrawable(Vector3 corners[4], DrawableID id, Bool highlight);
/// Remove a bib.
void removeTerrainBib(ObjectID id);
void removeTerrainBibDrawable(DrawableID id);
/// Removes all bibs.
void removeAllTerrainBibs(void);
/// Remove all highlighting.
void removeTerrainBibHighlighting(void);
void renderTerrainPass(CameraClass *pCamera); ///< renders additional terrain pass.
W3DShroud *getShroud() {return m_shroud;}
void renderExtraBlendTiles(void); ///< render 3-way blend tiles that have blend of 3 textures.
void updateShorelineTiles(Int minX, Int minY, Int maxX, Int maxY, WorldHeightMap *pMap); ///<figure out which tiles on this map cross water plane
void updateViewImpassableAreas(Bool partial = FALSE, Int minX = 0, Int maxX = 0, Int minY = 0, Int maxY = 0);
void clearAllScorches(void);
void setTimeOfDay( TimeOfDay tod );
void staticLightingChanged(void);
void loadRoadsAndBridges(W3DTerrainLogic *pTerrainLogic, Bool saveGame); ///< Load the roads from the map objects.
void worldBuilderUpdateBridgeTowers( W3DAssetManager *assetManager, SimpleSceneClass *scene ); ///< for the editor updating of bridge tower visuals
Int getStaticDiffuse(Int x, Int y); ///< Gets the diffuse terrain lighting value for a point on the mesh.
void adjustTerrainLOD(Int adj);
void reset(void);
void doPartialUpdate(const IRegion2D &partialRange, WorldHeightMap *htMap, RefRenderObjListIterator *pLightsIterator);
Int getNumExtraBlendTiles(void) { return m_numExtraBlendTiles;}
Int getNumShoreLineTiles(void) { return m_numShoreLineTiles;}
void setShoreLineDetail(void); ///<update shoreline tiles in case the feature was toggled by user.
Bool getMaximumVisibleBox(const FrustumClass &frustum, AABoxClass *box, Bool ignoreMaxHeight); ///<3d extent of visible terrain.
Real getHeightMapHeight(Real x, Real y, Coord3D* normal) const; ///<return height and normal at given point
Bool isCliffCell(Real x, Real y); ///<return height and normal at given point
Real getMinHeight(void) const {return m_minHeight;} ///<return minimum height of entire terrain
Real getMaxHeight(void) const {return m_maxHeight;} ///<return maximum height of entire terrain
Real getMaxCellHeight(Real x, Real y) const; ///< returns maximum height of the 4 cell corners.
WorldHeightMap *getMap(void) {return m_map;} ///< returns object holding the heightmap samples - need this for fast access.
Bool isClearLineOfSight(const Coord3D& pos, const Coord3D& posOther) const;
Bool getShowImpassableAreas(void) {return m_showImpassableAreas;}
void setShowImpassableAreas(Bool show) {m_showImpassableAreas = show;}
Bool showAsVisibleCliff(Int xIndex, Int yIndex) const;
Bool evaluateAsVisibleCliff(Int xIndex, Int yIndex, Real valuesGreaterThanRad);
void oversizeTerrain(Int tilesToOversize);
Real getViewImpassableAreaSlope(void) const { return m_curImpassableSlope; }
void setViewImpassableAreaSlope(Real viewSlope) { m_curImpassableSlope = viewSlope; }
Bool doesNeedFullUpdate(void) {return m_needFullUpdate;}
protected:
#ifdef DO_SCORCH
enum { MAX_SCORCH_VERTEX=8194,
MAX_SCORCH_INDEX=6*8194,
MAX_SCORCH_MARKS=500,
SCORCH_MARKS_IN_TEXTURE=9,
SCORCH_PER_ROW = 3};
DX8VertexBufferClass *m_vertexScorch; ///<Scorch vertex buffer.
DX8IndexBufferClass *m_indexScorch; ///<indices defining a triangles for the scorch drawing.
TextureClass *m_scorchTexture; ///<Scorch mark texture
Int m_curNumScorchVertices; ///<number of vertices used in m_vertexScorch.
Int m_curNumScorchIndices; ///<number of indices used in m_indexScorch.
TScorch m_scorches[MAX_SCORCH_MARKS];
Int m_numScorches;
Int m_scorchesInBuffer; ///< how many are in the buffers. If less than numScorches, we need to update
// NOTE: This argument (contrary to most of the rest of the engine), is in degrees, not radians.
Real m_curImpassableSlope;
void updateScorches(void); ///<Update m_vertexScorch and m_indexScorch so all scorches will be drawn.
void allocateScorchBuffers(void); ///<allocate static buffers for drawing scorch marks.
void freeScorchBuffers(void); ///< frees up scorch buffers.
void drawScorches(void); ///< Draws the scorch mark polygons in m_vertexScorch.
#endif
WorldHeightMap *m_map;
Int m_x; ///< dimensions of heightmap
Int m_y; ///< dimensions of heightmap
Int m_originX; ///< Origin point in the grid. Slides around.
Int m_originY; ///< Origin point in the grid. Slides around.
Bool m_useDepthFade; ///<fade terrain lighting under water
Vector3 m_depthFade; ///<depth based fall off values for r,g,b
Bool m_disableTextures;
Bool m_needFullUpdate; ///< True if lighting changed, and we need to update all instead of what moved.
Bool m_updating; ///< True if we are updating vertex buffers. (can't draw while buffers are locked.)
Bool m_halfResMesh; ///< True if we are doing half resolution mesh of the terrain.
Bool m_doXNextTime; ///< True if we updated y scroll, and need to do x scroll next frame.
Real m_minHeight; ///<minimum value of height samples in heightmap
Real m_maxHeight; ///<maximum value of height samples in heightmap
Int m_numVBTilesX; ///<dimensions of array containing all the vertex buffers
Int m_numVBTilesY; ///<dimensions of array containing all the vertex buffers
Int m_numVertexBufferTiles; ///<number of vertex buffers needed to store this heightmap
Int m_numBlockColumnsInLastVB;///<a VB tile may be partially filled, this indicates how many 2x2 vertex blocks are filled.
Int m_numBlockRowsInLastVB;///<a VB tile may be partially filled, this indicates how many 2x2 vertex blocks are filled.
Bool m_showImpassableAreas; ///< If true, shade impassable areas.
// STL is "smart." This is a variable sized bitset. Very memory efficient.
std::vector<bool> m_showAsVisibleCliff;
DX8IndexBufferClass *m_indexBuffer; ///<indices defining triangles in a VB tile.
#ifdef PRE_TRANSFORM_VERTEX
IDirect3DVertexBuffer8 **m_xformedVertexBuffer;
#endif
ShaderClass m_shaderClass; ///<shader or rendering state for heightmap
VertexMaterialClass *m_vertexMaterialClass; ///< vertex shader (lighting) for terrain
TextureClass *m_stageZeroTexture; ///<primary texture
TextureClass *m_stageOneTexture; ///<transparent edging texture
CloudMapTerrainTextureClass *m_stageTwoTexture; ///<Cloud map texture
TextureClass *m_stageThreeTexture; ///<light/noise map texture
AsciiString m_macroTextureName; ///< Name for stage 3 texture.
TextureClass *m_destAlphaTexture; ///< Texture holding destination alpha LUT for water depth.
DX8VertexBufferClass **m_vertexBufferTiles; ///<collection of smaller vertex buffers that make up 1 heightmap
char **m_vertexBufferBackup; ///< In memory copy of the vertex buffer data for quick update of dynamic lighting.
W3DTreeBuffer *m_treeBuffer; ///< Class for drawing trees and other alpha objects.
W3DBibBuffer *m_bibBuffer; ///< Class for drawing trees and other alpha objects.
W3DWaypointBuffer *m_waypointBuffer; ///< Draws waypoints.
#ifdef TEST_CUSTOM_EDGING
W3DCustomEdging *m_customEdging; ///< Class for drawing custom edging.
#endif
#ifdef DO_ROADS
W3DRoadBuffer *m_roadBuffer; ///< Class for drawing roads.
#endif
W3DBridgeBuffer *m_bridgeBuffer;
W3DShroud *m_shroud; ///< Class for drawing the shroud over terrain.
Int *m_extraBlendTilePositions; ///<array holding x,y tile positions of all extra blend tiles. (used for 3 textures per tile).
Int m_numExtraBlendTiles; ///<number of blend tiles in m_extraBlendTilePositions.
Int m_extraBlendTilePositionsSize; //<total size of array including unused memory.
struct shoreLineTileInfo
{ Int m_xy; //x,y position of tile
Real t0,t1,t2,t3; //index into water depth alpha LUT.
};
shoreLineTileInfo *m_shoreLineTilePositions; ///<array holding x,y tile positions of all shoreline terrain.
Int m_numShoreLineTiles; ///<number of tiles in m_shoreLineTilePositions.
Int m_shoreLineTilePositionsSize; ///<total size of array including unused memory.
Real m_currentMinWaterOpacity; ///<current value inside the gradient lookup texture.
/// Update the diffuse value from dynamic light info for one vertex.
UnsignedInt doTheDynamicLight(VERTEX_FORMAT *vb, VERTEX_FORMAT *vbMirror, Vector3*light, Vector3*normal, W3DDynamicLight *pLights[], Int numLights);
Int getXWithOrigin(Int x);
Int getYWithOrigin(Int x);
///update vertex diffuse color for dynamic lights inside given rectangle
Int updateVBForLight(DX8VertexBufferClass *pVB, char *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, W3DDynamicLight *pLights[], Int numLights);
Int updateVBForLightOptimized(DX8VertexBufferClass *pVB, char *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, W3DDynamicLight *pLights[], Int numLights);
///update vertex buffer vertices inside given rectangle
Int updateVB(DX8VertexBufferClass *pVB, char *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator);
///upate vertex buffers associated with the given rectangle
int updateBlock(Int x0, Int y0, Int x1, Int y1, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator);
AABoxClass & getTileBoundingBox(AABoxClass *aabox, Int x, Int y); ///<Vertex buffer bounding box
void initDestAlphaLUT(void); ///<initialize water depth LUT stored in m_destAlphaTexture
void renderShoreLines(CameraClass *pCamera); ///<re-render parts of terrain that need custom blending into water edge
};
extern HeightMapRenderObjClass *TheTerrainRenderObject;
#endif // end __HEIGHTMAP_H_

View file

@ -0,0 +1,103 @@
/*
** Command & Conquer Generals(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: W3DDebrisDraw.h //////////////////////////////////////////////////////////////////////////
// Author: Steven Johnson
// Desc: Debris drawing
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3D_DEBRIS_DRAW_H_
#define __W3D_DEBRIS_DRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/GameType.h"
#include "Common/DrawModule.h"
#include "Common/FileSystem.h" // this is only here to pull in LOAD_TEST_ASSETS
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
class Thing;
class RenderObjClass;
class HAnimClass;
class Shadow;
class FXList;
//-------------------------------------------------------------------------------------------------
class W3DDebrisDraw : public DrawModule, public DebrisDrawInterface
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DDebrisDraw, "W3DDebrisDraw" )
MAKE_STANDARD_MODULE_MACRO( W3DDebrisDraw )
public:
W3DDebrisDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
/// the draw method
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void setShadowsEnabled(Bool enable);
virtual void releaseShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void allocateShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void setFullyObscuredByShroud(Bool fullyObscured);
virtual void reactToTransformChange(const Matrix3D* oldMtx, const Coord3D* oldPos, Real oldAngle);
virtual void reactToGeometryChange() { }
virtual void setModelName(AsciiString name, Color color, ShadowType t);
virtual void setAnimNames(AsciiString initial, AsciiString flying, AsciiString final, const FXList* finalFX);
virtual DebrisDrawInterface* getDebrisDrawInterface() { return this; }
virtual const DebrisDrawInterface* getDebrisDrawInterface() const { return this; }
private:
enum AnimStateType
{
INITIAL,
FLYING,
FINAL,
STATECOUNT
};
AsciiString m_modelName;
Color m_modelColor;
AsciiString m_animInitial;
AsciiString m_animFlying;
AsciiString m_animFinal;
RenderObjClass* m_renderObject; ///< W3D Render object for this drawable
HAnimClass* m_anims[STATECOUNT];
const FXList* m_fxFinal;
Int m_state;
Int m_frames;
Bool m_finalStop;
Shadow* m_shadow; ///< Updates/Renders shadows of this object
};
#endif // __W3D_DEBRIS_DRAW_H_

View file

@ -0,0 +1,80 @@
/*
** Command & Conquer Generals(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: W3DModelDraw.h /////////////////////////////////////////////////////////////////////////
// Author: Colin Day, November 2001
// Desc: Default client update module
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DDEFAULTDRAW_H_
#define __W3DDEFAULTDRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/GameType.h"
#include "Common/DrawModule.h"
#include "Common/FileSystem.h" // this is only here to pull in LOAD_TEST_ASSETS
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
class Thing;
class RenderObjClass;
class FXList;
//-------------------------------------------------------------------------------------------------
/** The default client update module */
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
class W3DDefaultDraw : public DrawModule
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DDefaultDraw, "W3DDefaultDraw" )
MAKE_STANDARD_MODULE_MACRO( W3DDefaultDraw )
public:
W3DDefaultDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
/// the draw method
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void setShadowsEnabled(Bool enable);
virtual void releaseShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void allocateShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void setFullyObscuredByShroud(Bool fullyObscured);
virtual void reactToTransformChange(const Matrix3D* oldMtx, const Coord3D* oldPos, Real oldAngle);
virtual void reactToGeometryChange() { }
private:
#ifdef LOAD_TEST_ASSETS
RenderObjClass* m_renderObject; ///< W3D Render object for this drawable
Shadow* m_shadow; ///< Updates/Renders shadows of this object
#endif
};
#endif // __W3DDEFAULTDRAW_H_

View file

@ -0,0 +1,74 @@
/*
** Command & Conquer Generals(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: W3DDependencyModelDraw.h ////////////////////////////////////////////////////////////////////////////
// Author: Graham Smallwood, October 2002
// Desc: Draw module just like Model, except it can't draw unless somebody else explicitly says to, since they
// have to draw first.
//
// This draw module can be used in a general case (although I don't see why), m_attachToDrawableBoneInContainer
// is for the one present and main reason to use this module. Our transport needs to tell us it is okay to
// draw after he draws.
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _W3D_DEPENDENCY_MODEL_DRAW_H_
#define _W3D_DEPENDENCY_MODEL_DRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "W3DDevice/GameClient/Module/W3DModelDraw.h"
//-------------------------------------------------------------------------------------------------
class W3DDependencyModelDrawModuleData : public W3DModelDrawModuleData
{
public:
AsciiString m_attachToDrawableBoneInContainer;// Not just a different draw module, this bone is in our container
W3DDependencyModelDrawModuleData();
~W3DDependencyModelDrawModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
};
//-------------------------------------------------------------------------------------------------
class W3DDependencyModelDraw : public W3DModelDraw
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DDependencyModelDraw, "W3DDependencyModelDraw" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DDependencyModelDraw, W3DDependencyModelDrawModuleData )
public:
W3DDependencyModelDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void notifyDrawModuleDependencyCleared( );///< if you were waiting for something before you drew, it's ready now
virtual void adjustTransformMtx(Matrix3D& mtx) const;
protected:
Bool m_dependencyCleared; // The thing we depend on will clear this, and we will relatch it after we draw.
};
#endif // _W3D_DEPENDENCY_MODEL_DRAW_H_

View file

@ -0,0 +1,104 @@
/*
** Command & Conquer Generals(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: W3DLaserDraw.h ///////////////////////////////////////////////////////////////////////////
// Author:
// Desc:
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DLASERDRAW_H_
#define __W3DLASERDRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/DrawModule.h"
//#include "WW3D2/Line3D.h"
#include "GameClient/Color.h"
class SegmentedLineClass;
class TextureClass;
class W3DLaserDrawModuleData : public ModuleData
{
public:
Color m_innerColor;
Color m_outerColor;
Real m_innerBeamWidth;
Real m_outerBeamWidth;
Real m_scrollRate;
Bool m_tile;
UnsignedInt m_numBeams;
UnsignedInt m_maxIntensityFrames;
UnsignedInt m_fadeFrames;
AsciiString m_textureName;
UnsignedInt m_segments;
Real m_arcHeight;
Real m_segmentOverlapRatio;
Real m_tilingScalar;
W3DLaserDrawModuleData();
~W3DLaserDrawModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
};
//-------------------------------------------------------------------------------------------------
/** W3D laser draw */
//-------------------------------------------------------------------------------------------------
class W3DLaserDraw : public DrawModule, public LaserDrawInterface
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DLaserDraw, "W3DLaserDraw" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DLaserDraw, W3DLaserDrawModuleData )
public:
W3DLaserDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void releaseShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void allocateShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void setShadowsEnabled(Bool enable) { }
virtual void setFullyObscuredByShroud(Bool fullyObscured) { };
virtual void reactToTransformChange(const Matrix3D* oldMtx, const Coord3D* oldPos, Real oldAngle) { }
virtual void reactToGeometryChange() { }
virtual Bool isLaser() const { return true; }
Real getLaserTemplateWidth() const;
virtual LaserDrawInterface* getLaserDrawInterface() { return this; }
virtual const LaserDrawInterface* getLaserDrawInterface() const { return this; }
protected:
SegmentedLineClass **m_line3D; ///< line 3D for effect
TextureClass *m_texture;
Real m_textureAspectRatio; ///< aspect ratio of texture
Bool m_selfDirty; // not saved
};
#endif // __W3DLASERDRAW_H_

View file

@ -0,0 +1,517 @@
/*
** Command & Conquer Generals(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: W3DModelDraw.h /////////////////////////////////////////////////////////////////////////
// Author: Colin Day, November 2001
// Desc: Default client update module
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DModelDraw_H_
#define __W3DModelDraw_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/ModelState.h"
#include "Common/DrawModule.h"
#ifdef BRUTAL_TIMING_HACK // hack for collecting model timing info. jba.
class RenderObjClass {
public:
enum AnimMode
{
ANIM_MODE_MANUAL = 0,
ANIM_MODE_LOOP,
ANIM_MODE_ONCE,
ANIM_MODE_LOOP_PINGPONG,
ANIM_MODE_LOOP_BACKWARDS, //make sure only backwards playing animations after this one
ANIM_MODE_ONCE_BACKWARDS,
};
};
#else
#include "WW3D2/RendObj.h"
#endif
#include "Common/SparseMatchFinder.h"
#include "GameClient/ParticleSys.h"
#include "Common/STLTypedefs.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
class Thing;
class RenderObjClass;
class Shadow;
class TerrainTracksRenderObjClass;
class HAnimClass;
enum GameLODLevel;
//-------------------------------------------------------------------------------------------------
/** The default client update module */
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
typedef UnsignedInt64 TransitionSig;
const TransitionSig NO_TRANSITION = 0;
inline TransitionSig buildTransitionSig(NameKeyType src, NameKeyType dst)
{
return (((UnsignedInt64)src) << 32) | ((UnsignedInt64)dst);
}
inline NameKeyType recoverSrcState(TransitionSig sig)
{
return (NameKeyType)((sig >> 32) & 0xffffffff);
}
inline NameKeyType recoverDstState(TransitionSig sig)
{
return (NameKeyType)((sig) & 0xffffffff);
}
//-------------------------------------------------------------------------------------------------
// please do not define RETAIN_ANIM_HANDLES. It prevents us from ever releasing animations.
// old code should be deleting by mid-Jan 2003. (srj)
#define NO_RETAIN_ANIM_HANDLES
//-------------------------------------------------------------------------------------------------
class W3DAnimationInfo
{
private:
AsciiString m_name;
#ifdef RETAIN_ANIM_HANDLES
mutable HAnimClass* m_handle;
#endif
Real m_distanceCovered; // if nonzero, the distance covered by a single loop of the anim
mutable Real m_naturalDurationInMsec;
Bool m_isIdleAnim; // if true, we pick another animation at random when this one completes
public:
W3DAnimationInfo(const AsciiString& name, Bool isIdle, Real distanceCovered);
W3DAnimationInfo(const W3DAnimationInfo &r);
W3DAnimationInfo &operator=(const W3DAnimationInfo& r);
~W3DAnimationInfo();
HAnimClass* getAnimHandle() const;
const AsciiString& getName() const { return m_name; }
Bool isIdleAnim() const { return m_isIdleAnim; }
Real getDistanceCovered() const { return m_distanceCovered; }
Real getNaturalDurationInMsec() const { return m_naturalDurationInMsec; }
};
typedef std::vector<W3DAnimationInfo> W3DAnimationVector;
//-------------------------------------------------------------------------------------------------
struct ParticleSysBoneInfo
{
AsciiString boneName;
const ParticleSystemTemplate* particleSystemTemplate;
};
typedef std::vector<ParticleSysBoneInfo> ParticleSysBoneInfoVector;
//-------------------------------------------------------------------------------------------------
struct PristineBoneInfo
{
Matrix3D mtx;
Int boneIndex;
};
typedef std::hash_map< NameKeyType, PristineBoneInfo, rts::hash<NameKeyType>, rts::equal_to<NameKeyType> > PristineBoneInfoMap;
//-------------------------------------------------------------------------------------------------
struct ModelConditionInfo
{
struct HideShowSubObjInfo
{
AsciiString subObjName;
Bool hide;
};
struct TurretInfo
{
// read from INI
NameKeyType m_turretAngleNameKey;
NameKeyType m_turretPitchNameKey;
Real m_turretArtAngle;
Real m_turretArtPitch;
// calculated at runtime
Int m_turretAngleBone;
Int m_turretPitchBone;
void clear()
{
m_turretAngleNameKey = NAMEKEY_INVALID;
m_turretPitchNameKey = NAMEKEY_INVALID;
m_turretArtAngle = 0;
m_turretArtPitch = 0;
m_turretAngleBone = 0;
m_turretPitchBone = 0;
}
};
struct WeaponBarrelInfo
{
Int m_recoilBone; ///< the W3D bone for this barrel (zero == no bone)
Int m_fxBone; ///< the FX bone for this barrel (zero == no bone)
Int m_muzzleFlashBone; ///< the muzzle-flash subobj bone for this barrel (zero == none)
Matrix3D m_projectileOffsetMtx; ///< where the projectile fires from
#if defined(_DEBUG) || defined(_INTERNAL)
AsciiString m_muzzleFlashBoneName;
#endif
WeaponBarrelInfo()
{
clear();
}
void clear()
{
m_recoilBone = 0;
m_fxBone = 0;
m_muzzleFlashBone = 0;
m_projectileOffsetMtx.Make_Identity();
#if defined(_DEBUG) || defined(_INTERNAL)
m_muzzleFlashBoneName.clear();
#endif
}
void setMuzzleFlashHidden(RenderObjClass *fullObject, Bool hide) const;
};
typedef std::vector<WeaponBarrelInfo> WeaponBarrelInfoVec;
#if defined(_DEBUG) || defined(_INTERNAL)
AsciiString m_description;
#endif
std::vector<ModelConditionFlags> m_conditionsYesVec;
AsciiString m_modelName;
std::vector<HideShowSubObjInfo> m_hideShowVec;
mutable std::vector<AsciiString> m_publicBones;
AsciiString m_weaponFireFXBoneName[WEAPONSLOT_COUNT];
AsciiString m_weaponRecoilBoneName[WEAPONSLOT_COUNT];
AsciiString m_weaponMuzzleFlashName[WEAPONSLOT_COUNT];
AsciiString m_weaponProjectileLaunchBoneName[WEAPONSLOT_COUNT];
AsciiString m_weaponProjectileHideShowName[WEAPONSLOT_COUNT];
W3DAnimationVector m_animations;
NameKeyType m_transitionKey;
NameKeyType m_allowToFinishKey;
Int m_flags;
Int m_iniReadFlags; // not read from ini, but used for helping with default states
RenderObjClass::AnimMode m_mode;
ParticleSysBoneInfoVector m_particleSysBones; ///< Bone names and attached particle systems.
TransitionSig m_transitionSig;
Real m_animMinSpeedFactor; //Min speed factor (randomized each time it's played)
Real m_animMaxSpeedFactor; //Max speed factor (randomized each time it's played)
mutable PristineBoneInfoMap m_pristineBones;
mutable TurretInfo m_turrets[MAX_TURRETS];
mutable WeaponBarrelInfoVec m_weaponBarrelInfoVec[WEAPONSLOT_COUNT];
mutable Bool m_hasRecoilBonesOrMuzzleFlashes[WEAPONSLOT_COUNT];
mutable Byte m_validStuff;
enum
{
PRISTINE_BONES_VALID = 0x0001,
TURRETS_VALID = 0x0002,
HAS_PROJECTILE_BONES = 0x0004,
BARRELS_VALID = 0x0008,
PUBLIC_BONES_VALID = 0x0010
};
inline ModelConditionInfo()
{
clear();
}
void clear();
void loadAnimations() const;
void preloadAssets( TimeOfDay timeOfDay, Real scale ); ///< preload any assets for time of day
inline Int getConditionsYesCount() const { DEBUG_ASSERTCRASH(m_conditionsYesVec.size() > 0, ("empty m_conditionsYesVec.size(), see srj")); return m_conditionsYesVec.size(); }
inline const ModelConditionFlags& getNthConditionsYes(Int i) const { return m_conditionsYesVec[i]; }
#if defined(_DEBUG) || defined(_INTERNAL)
inline AsciiString getDescription() const { return m_description; }
#endif
const Matrix3D* findPristineBone(NameKeyType boneName, Int* boneIndex) const;
Bool findPristineBonePos(NameKeyType boneName, Coord3D& pos) const;
void addPublicBone(const AsciiString& boneName) const;
Bool matchesMode(Bool night, Bool snowy) const;
void validateStuff(RenderObjClass* robj, Real scale, const std::vector<AsciiString>& extraPublicBones) const;
private:
void validateWeaponBarrelInfo() const;
void validateTurretInfo() const;
void validateCachedBones(RenderObjClass* robj, Real scale) const;
};
typedef std::vector<ModelConditionInfo> ModelConditionVector;
//-------------------------------------------------------------------------------------------------
typedef std::hash_map< TransitionSig, ModelConditionInfo, std::hash<TransitionSig>, std::equal_to<TransitionSig> > TransitionMap;
//-------------------------------------------------------------------------------------------------
// this is more efficient and also helps solve a projectile-launch-offset problem for double-upgraded
// technicals. it is not within risk, however, and WILL NOT WORK if the attach-to-module is animated
// in any meaningful way, so be careful. (srj)
#define CACHE_ATTACH_BONE
//-------------------------------------------------------------------------------------------------
class W3DModelDrawModuleData : public ModuleData
{
public:
mutable ModelConditionVector m_conditionStates;
mutable SparseMatchFinder< ModelConditionInfo, ModelConditionFlags >
m_conditionStateMap;
mutable TransitionMap m_transitionMap;
std::vector<AsciiString> m_extraPublicBones;
AsciiString m_trackFile; ///< if present, leaves tracks using this texture
AsciiString m_attachToDrawableBone;
#ifdef CACHE_ATTACH_BONE
mutable Vector3 m_attachToDrawableBoneOffset;
#endif
Int m_defaultState;
Int m_projectileBoneFeedbackEnabledSlots; ///< Hide and show the launch bone geometries according to clip status adjustments.
Real m_initialRecoil;
Real m_maxRecoil;
Real m_recoilDamping;
Real m_recoilSettle;
StaticGameLODLevel m_minLODRequired; ///< minumum game LOD level necessary to use this module.
ModelConditionFlags m_ignoreConditionStates;
Bool m_okToChangeModelColor;
Bool m_animationsRequirePower;///< Should UnderPowered disable type pause animations in this draw module?
#ifdef CACHE_ATTACH_BONE
mutable Bool m_attachToDrawableBoneOffsetValid;
#endif
mutable Byte m_validated;
W3DModelDrawModuleData();
~W3DModelDrawModuleData();
void validateStuffForTimeAndWeather(const Drawable* draw, Bool night, Bool snowy) const;
static void buildFieldParse(MultiIniFieldParse& p);
AsciiString getBestModelNameForWB(const ModelConditionFlags& c) const;
const ModelConditionInfo* findBestInfo(const ModelConditionFlags& c) const;
void preloadAssets( TimeOfDay timeOfDay, Real scale ) const;
#ifdef CACHE_ATTACH_BONE
const Vector3* getAttachToDrawableBoneOffset(const Drawable* draw) const;
#endif
// ugh, hack
virtual const W3DModelDrawModuleData* getAsW3DModelDrawModuleData() const { return this; }
virtual StaticGameLODLevel getMinimumRequiredGameLOD() const { return m_minLODRequired;}
private:
static void parseConditionState( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ );
public:
virtual void crc( Xfer *xfer );
virtual void xfer( Xfer *xfer );
virtual void loadPostProcess( void );
};
//-------------------------------------------------------------------------------------------------
class W3DModelDraw : public DrawModule, public ObjectDrawInterface
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DModelDraw, "W3DModelDraw" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DModelDraw, W3DModelDrawModuleData )
public:
W3DModelDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
/// preloading assets
virtual void preloadAssets( TimeOfDay timeOfDay );
/// the draw method
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void setShadowsEnabled(Bool enable);
virtual void releaseShadows(void); ///< frees all shadow resources used by this module - used by Options screen.
virtual void allocateShadows(void); ///< create shadow resources if not already present. Used by Options screen.
#if defined(_DEBUG) || defined(_INTERNAL)
virtual void getRenderCost(RenderCost & rc) const; ///< estimates the render cost of this draw module
void getRenderCostRecursive(RenderCost & rc,RenderObjClass * robj) const;
#endif
virtual void setFullyObscuredByShroud(Bool fullyObscured);
virtual void setTerrainDecal(TerrainDecalType type);
virtual Bool isVisible() const;
virtual void reactToTransformChange(const Matrix3D* oldMtx, const Coord3D* oldPos, Real oldAngle);
virtual void reactToGeometryChange() { }
// this method must ONLY be called from the client, NEVER From the logic, not even indirectly.
virtual Bool clientOnly_getRenderObjInfo(Coord3D* pos, Real* boundingSphereRadius, Matrix3D* transform) const;
virtual Int getPristineBonePositionsForConditionState(const ModelConditionFlags& condition, const char* boneNamePrefix, Int startIndex, Coord3D* positions, Matrix3D* transforms, Int maxBones) const;
virtual Int getCurrentBonePositions(const char* boneNamePrefix, Int startIndex, Coord3D* positions, Matrix3D* transforms, Int maxBones) const;
virtual Bool getCurrentWorldspaceClientBonePositions(const char* boneName, Matrix3D& transform) const;
virtual Bool getProjectileLaunchOffset(const ModelConditionFlags& condition, WeaponSlotType wslot, Int specificBarrelToUse, Matrix3D* launchPos, WhichTurretType tur, Coord3D* turretRotPos, Coord3D* turretPitchPos = NULL) const;
virtual void updateProjectileClipStatus( UnsignedInt shotsRemaining, UnsignedInt maxShots, WeaponSlotType slot ); ///< This will do the show/hide work if ProjectileBoneFeedbackEnabled is set.
virtual void updateDrawModuleSupplyStatus( Int maxSupply, Int currentSupply ); ///< This will do visual feedback on Supplies carried
virtual void notifyDrawModuleDependencyCleared( ){}///< if you were waiting for something before you drew, it's ready now
virtual void setHidden(Bool h);
virtual void replaceModelConditionState(const ModelConditionFlags& c);
virtual void replaceIndicatorColor(Color color);
virtual Bool handleWeaponFireFX(WeaponSlotType wslot, Int specificBarrelToUse, const FXList* fxl, Real weaponSpeed, const Coord3D* victimPos, Real damageRadius);
virtual Int getBarrelCount(WeaponSlotType wslot) const;
virtual void setSelectable(Bool selectable); // Change the selectability of the model.
/**
This call says, "I want the current animation (if any) to take n frames to complete a single cycle".
If it's a looping anim, each loop will take n frames. someday, we may want to add the option to insert
"pad" frames at the start and/or end, but for now, we always just "stretch" the animation to fit.
Note that you must call this AFTER setting the condition codes.
*/
virtual void setAnimationLoopDuration(UnsignedInt numFrames);
/**
similar to the above, but assumes that the current state is a "ONCE",
and is smart about transition states... if there is a transition state
"inbetween", it is included in the completion time.
*/
virtual void setAnimationCompletionTime(UnsignedInt numFrames);
/**
This call is used to pause or resume an animation.
*/
virtual void setPauseAnimation(Bool pauseAnim);
virtual void updateSubObjects();
virtual void showSubObject( const AsciiString& name, Bool show );
#ifdef ALLOW_ANIM_INQUIRIES
// srj sez: not sure if this is a good idea, for net sync reasons...
virtual Real getAnimationScrubScalar( void ) const;
#endif
virtual ObjectDrawInterface* getObjectDrawInterface() { return this; }
virtual const ObjectDrawInterface* getObjectDrawInterface() const { return this; }
///@todo: I had to make this public because W3DDevice needs access for casting shadows -MW
inline RenderObjClass *getRenderObject() { return m_renderObject; }
virtual Bool updateBonesForClientParticleSystems( void );///< this will reposition particle systems on the fly ML
virtual void onDrawableBoundToObject();
virtual void setTerrainDecalSize(Real x, Real y);
virtual void setTerrainDecalOpacity(Real o);
protected:
virtual void onRenderObjRecreated(void){};
inline const ModelConditionInfo* getCurState() const { return m_curState; }
void setModelState(const ModelConditionInfo* newState);
const ModelConditionInfo* findBestInfo(const ModelConditionFlags& c) const;
void handleClientTurretPositioning();
void handleClientRecoil();
void recalcBonesForClientParticleSystems();
void stopClientParticleSystems();
void doHideShowSubObjs(const std::vector<ModelConditionInfo::HideShowSubObjInfo>* vec);
virtual void adjustTransformMtx(Matrix3D& mtx) const;
Real getCurAnimDistanceCovered() const;
Bool setCurAnimDurationInMsec(Real duration);
inline Bool getFullyObscuredByShroud() const { return m_fullyObscuredByShroud; }
private:
struct WeaponRecoilInfo
{
enum RecoilState
{
IDLE, RECOIL_START, RECOIL, SETTLE
};
RecoilState m_state; ///< what state this gun is in
Real m_shift; ///< how far the gun barrel has recoiled
Real m_recoilRate; ///< how fast the gun barrel is recoiling
WeaponRecoilInfo()
{
clear();
}
void clear()
{
m_state = IDLE;
m_shift = 0.0f;
m_recoilRate = 0.0f;
}
};
struct ParticleSysTrackerType
{
ParticleSystemID id;
Int boneIndex;
};
typedef std::vector<WeaponRecoilInfo> WeaponRecoilInfoVec;
typedef std::vector<ParticleSysTrackerType> ParticleSystemIDVec;
//typedef std::vector<ParticleSystemID> ParticleSystemIDVec;
const ModelConditionInfo* m_curState;
const ModelConditionInfo* m_nextState;
UnsignedInt m_nextStateAnimLoopDuration;
Int m_hexColor;
Int m_whichAnimInCurState; ///< the index of the currently playing anim in cur state (if any)
WeaponRecoilInfoVec m_weaponRecoilInfoVec[WEAPONSLOT_COUNT];
Bool m_needRecalcBoneParticleSystems;
Bool m_fullyObscuredByShroud;
Bool m_shadowEnabled; ///< cached state of shadow. Used to determine if shadows should be enabled via options screen.
RenderObjClass* m_renderObject; ///< W3D Render object for this drawable
Shadow* m_shadow; ///< Updates/Renders shadows of this object
Shadow* m_terrainDecal;
TerrainTracksRenderObjClass* m_trackRenderObject; ///< This is rendered under object
ParticleSystemIDVec m_particleSystemIDs; ///< The ID numbers of the particle systems currently running.
std::vector<ModelConditionInfo::HideShowSubObjInfo> m_subObjectVec;
Bool m_hideHeadlights;
Bool m_pauseAnimation;
Int m_animationMode;
void adjustAnimation(const ModelConditionInfo* prevState, Real prevAnimFraction);
Real getCurrentAnimFraction() const;
void applyCorrectModelStateAnimation();
const ModelConditionInfo* findTransitionForSig(TransitionSig sig) const;
void rebuildWeaponRecoilInfo(const ModelConditionInfo* state);
void doHideShowProjectileObjects( UnsignedInt showCount, UnsignedInt maxCount, WeaponSlotType slot );///< Means effectively, show m of n.
void nukeCurrentRender(Matrix3D* xform);
void doStartOrStopParticleSys();
void adjustAnimSpeedToMovementSpeed();
static void hideAllMuzzleFlashes(const ModelConditionInfo* state, RenderObjClass* renderObject);
void hideAllHeadlights(Bool hide);
#if defined(_DEBUG) || defined(_INTERNAL) //art wants to see buildings without flags as a test.
void hideGarrisonFlags(Bool hide);
#endif
};
#endif // __W3DModelDraw_H_

View file

@ -0,0 +1,75 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
// FIEL: W3DOverlordTankDraw.h ////////////////////////////////////////////////////////////////////////////
// Author: Graham Smallwood, October 2002
// Desc: The Overlord has a super specific special need. He needs his rider to draw explicitly after him,
// and he needs direct access to get that rider when everyone else can't see it because of the OverlordContain.
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _W3D_OVERLORD_TANK_DRAW_H_
#define _W3D_OVERLORD_TANK_DRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "W3DDevice/GameClient/Module/W3DTankDraw.h"
//-------------------------------------------------------------------------------------------------
class W3DOverlordTankDrawModuleData : public W3DTankDrawModuleData
{
public:
AsciiString m_treadDebrisNameLeft;
AsciiString m_treadDebrisNameRight;
Real m_treadAnimationRate; ///<amount of tread texture to scroll per sec. 1.0 == full width.
Real m_treadPivotSpeedFraction; ///<fraction of locomotor speed below which we allow pivoting.
Real m_treadDriveSpeedFraction; ///<fraction of locomotor speed below which treads stop animating.
W3DOverlordTankDrawModuleData();
~W3DOverlordTankDrawModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
};
//-------------------------------------------------------------------------------------------------
class W3DOverlordTankDraw : public W3DTankDraw
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DOverlordTankDraw, "W3DOverlordTankDraw" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DOverlordTankDraw, W3DOverlordTankDrawModuleData )
public:
W3DOverlordTankDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void setHidden(Bool h);
virtual void doDrawModule(const Matrix3D* transformMtx);
protected:
};
#endif

View file

@ -0,0 +1,68 @@
/*
** Command & Conquer Generals(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: W3DPoliceCarDraw.h ///////////////////////////////////////////////////////////////////////
// Author:
// Desc:
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DPOLICECARDRAW_H_
#define __W3DPOLICECARDRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/DrawModule.h"
#include "W3DDevice/GameClient/Module/W3DTruckDraw.h"
#include "W3DDevice/GameClient/W3DDynamicLight.h"
#include "WW3D2/Line3D.h"
//-------------------------------------------------------------------------------------------------
/** W3D police car draw */
//-------------------------------------------------------------------------------------------------
class W3DPoliceCarDraw : public W3DTruckDraw
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DPoliceCarDraw, "W3DPoliceCarDraw" )
MAKE_STANDARD_MODULE_MACRO( W3DPoliceCarDraw )
public:
W3DPoliceCarDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void doDrawModule(const Matrix3D* transformMtx);
protected:
/// create the dynamic light for the search light
W3DDynamicLight *createDynamicLight( void );
W3DDynamicLight *m_light; ///< light for the POLICECAR
Real m_curFrame;
};
#endif // __W3DPOLICECARDRAW_H_

View file

@ -0,0 +1,88 @@
/*
** Command & Conquer Generals(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: W3DProjectileStreamDraw.h ////////////////////////////////////////////////////////////
// Tile a texture strung between Projectiles
// Graham Smallwood, May 2002
/////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _W3D_PROJECTILE_STREAM_DRAW_H_
#define _W3D_PROJECTILE_STREAM_DRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/DrawModule.h"
#include "GameLogic/Module/ProjectileStreamUpdate.h" // I am the draw module for this update. Very tight.
class SegmentedLineClass;
class TextureClass;
class Vector3;
//-------------------------------------------------------------------------------------------------
class W3DProjectileStreamDrawModuleData : public ModuleData
{
public:
AsciiString m_textureName;
Real m_width;
Real m_tileFactor;
Real m_scrollRate;
Int m_maxSegments;
W3DProjectileStreamDrawModuleData();
~W3DProjectileStreamDrawModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
};
//-------------------------------------------------------------------------------------------------
class W3DProjectileStreamDraw : public DrawModule
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DProjectileStreamDraw, "W3DProjectileStreamDraw" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DProjectileStreamDraw, W3DProjectileStreamDrawModuleData )
public:
W3DProjectileStreamDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void releaseShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void allocateShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void setShadowsEnabled(Bool ) { }
virtual void setFullyObscuredByShroud(Bool);
virtual void reactToTransformChange(const Matrix3D* oldMtx, const Coord3D* oldPos, Real oldAngle) { }
virtual void reactToGeometryChange() { }
protected:
void makeOrUpdateLine( Vector3 *points, UnsignedInt pointCount, Int lineIndex );
TextureClass *m_texture;
SegmentedLineClass *m_allLines[MAX_PROJECTILE_STREAM]; ///< Persist, so I can ensure they live a full cycle, and minimize re-creates by holding on
Int m_linesValid;
};
#endif

View file

@ -0,0 +1,98 @@
/*
** Command & Conquer Generals(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: W3DRopeDraw.h //////////////////////////////////////////////////////////////////////////
// Author:
// Desc:
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DRopeDraw_H_
#define __W3DRopeDraw_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/DrawModule.h"
#include "WW3D2/Line3D.h"
//-------------------------------------------------------------------------------------------------
/** W3D rope draw */
//-------------------------------------------------------------------------------------------------
class W3DRopeDraw : public DrawModule, public RopeDrawInterface
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DRopeDraw, "W3DRopeDraw" )
MAKE_STANDARD_MODULE_MACRO( W3DRopeDraw )
public:
W3DRopeDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void setShadowsEnabled(Bool enable) { }
virtual void releaseShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void allocateShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void setFullyObscuredByShroud(Bool fullyObscured) { }
virtual void reactToTransformChange(const Matrix3D* oldMtx, const Coord3D* oldPos, Real oldAngle) { }
virtual void reactToGeometryChange() { }
virtual void initRopeParms(Real length, Real width, const RGBColor& color, Real wobbleLen, Real wobbleAmp, Real wobbleRate);
virtual void setRopeCurLen(Real length);
virtual void setRopeSpeed(Real curSpeed, Real maxSpeed, Real accel);
virtual RopeDrawInterface* getRopeDrawInterface() { return this; }
virtual const RopeDrawInterface* getRopeDrawInterface() const { return this; }
private:
struct SegInfo
{
Line3DClass* line;
Line3DClass* softLine;
Real wobbleAxisX;
Real wobbleAxisY;
};
std::vector<SegInfo> m_segments; ///< the rope render object in the W3D scene
Real m_curLen; ///< length of rope
Real m_maxLen; ///< length of rope
Real m_width; ///< width of rope
RGBColor m_color; ///< color of rope
Real m_curSpeed;
Real m_maxSpeed;
Real m_accel;
Real m_wobbleLen;
Real m_wobbleAmp;
Real m_wobbleRate;
Real m_curWobblePhase;
Real m_curZOffset;
void tossSegments();
void buildSegments();
};
#endif // __W3DRopeDraw_H_

View file

@ -0,0 +1,68 @@
/*
** Command & Conquer Generals(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: W3DScienceModelDraw.h ////////////////////////////////////////////////////////////////////////////
// Author: Graham Smallwood, NOVEMBER 2002
// Desc: Draw module just like Model, except it only draws if the local player has the specified science
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _W3D_SCIENCE_MODEL_DRAW_H_
#define _W3D_SCIENCE_MODEL_DRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "W3DDevice/GameClient/Module/W3DModelDraw.h"
enum ScienceType;
//-------------------------------------------------------------------------------------------------
class W3DScienceModelDrawModuleData : public W3DModelDrawModuleData
{
public:
ScienceType m_requiredScience; ///< Local player must have this science for me to ever draw
W3DScienceModelDrawModuleData();
~W3DScienceModelDrawModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
};
//-------------------------------------------------------------------------------------------------
class W3DScienceModelDraw : public W3DModelDraw
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DScienceModelDraw, "W3DScienceModelDraw" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DScienceModelDraw, W3DScienceModelDrawModuleData )
public:
W3DScienceModelDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void doDrawModule(const Matrix3D* transformMtx);///< checks a property on the local player before passing this up
protected:
};
#endif

View file

@ -0,0 +1,70 @@
/*
** Command & Conquer Generals(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: W3DSupplyDraw.h ////////////////////////////////////////////////////////////////////////////
// Author: Graham Smallwood, September 2002
// Desc: Draw module reacts to SupplyStatus setting by hiding an equal number of the specified bone array.
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _W3D_SUPPLY_DRAW_H_
#define _W3D_SUPPLY_DRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "W3DDevice/GameClient/Module/W3DModelDraw.h"
//-------------------------------------------------------------------------------------------------
class W3DSupplyDrawModuleData : public W3DModelDrawModuleData
{
public:
AsciiString m_supplyBonePrefix;
W3DSupplyDrawModuleData();
~W3DSupplyDrawModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
};
//-------------------------------------------------------------------------------------------------
class W3DSupplyDraw : public W3DModelDraw
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DSupplyDraw, "W3DSupplyDraw" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DSupplyDraw, W3DSupplyDrawModuleData )
public:
W3DSupplyDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void updateDrawModuleSupplyStatus( Int maxSupply, Int currentSupply ); ///< This will do visual feedback on Supplies carried
virtual void reactToGeometryChange() { }
protected:
Int m_totalBones;
Int m_lastNumberShown;
};
#endif // _W3D_TRUCK_DRAW_H_

View file

@ -0,0 +1,110 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
// FIEL: W3DTankDraw.h ////////////////////////////////////////////////////////////////////////////
// Draw a tank
// Author: Michael S. Booth, October 2001
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _W3D_TANK_DRAW_H_
#define _W3D_TANK_DRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/DrawModule.h"
#include "GameClient/ParticleSys.h"
#include "W3DDevice/GameClient/Module/W3DModelDraw.h"
#include "WW3D2/HAnim.h"
#include "WW3D2/RendObj.h"
#include "WW3D2/Part_Emt.h"
//-------------------------------------------------------------------------------------------------
class W3DTankDrawModuleData : public W3DModelDrawModuleData
{
public:
AsciiString m_treadDebrisNameLeft;
AsciiString m_treadDebrisNameRight;
Real m_treadAnimationRate; ///<amount of tread texture to scroll per sec. 1.0 == full width.
Real m_treadPivotSpeedFraction; ///<fraction of locomotor speed below which we allow pivoting.
Real m_treadDriveSpeedFraction; ///<fraction of locomotor speed below which treads stop animating.
W3DTankDrawModuleData();
~W3DTankDrawModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
};
//-------------------------------------------------------------------------------------------------
class W3DTankDraw : public W3DModelDraw
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DTankDraw, "W3DTankDraw" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DTankDraw, W3DTankDrawModuleData )
public:
W3DTankDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void setHidden(Bool h);
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void setFullyObscuredByShroud(Bool fullyObscured);
protected:
virtual void onRenderObjRecreated(void);
protected:
/// debris emitters for when tank is moving
ParticleSystem* m_treadDebrisLeft;
ParticleSystem* m_treadDebrisRight;
RenderObjClass *m_prevRenderObj;
enum TreadType { TREAD_LEFT, TREAD_RIGHT, TREAD_MIDDLE }; //types of treads for different vehicles
enum {MAX_TREADS_PER_TANK=4};
struct TreadObjectInfo
{
RenderObjClass *m_robj; ///<sub-object for tread
TreadType m_type; ///<kind of tread
RenderObjClass::Material_Override m_materialSettings; ///<used to set current uv scroll amount.
};
TreadObjectInfo m_treads[MAX_TREADS_PER_TANK];
Int m_treadCount;
Coord3D m_lastDirection; ///< orientation of tank last time it was drawn.
void createEmitters( void ); ///< Create particle effects.
void tossEmitters( void ); ///< Create particle effects.
void startMoveDebris( void ); ///< start creating debris from the tank treads
void stopMoveDebris( void ); ///< stop creating debris from the tank treads
void updateTreadObjects(void); ///< update pointers to sub-objects like treads.
void updateTreadPositions(Real uvDelta); ///< update uv coordinates on each tread
};
#endif // _W3D_TANK_DRAW_H_

View file

@ -0,0 +1,157 @@
/*
** Command & Conquer Generals(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: W3DTankTruckDraw.h ////////////////////////////////////////////////////////////////////////////
// Draw a vehicle with treads and wheels.
// Author: Mark Wilczynski, August 2002
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _W3D_TANKTRUCK_DRAW_H_
#define _W3D_TANKTRUCK_DRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/DrawModule.h"
#include "Common/AudioEventRTS.h"
#include "GameClient/ParticleSys.h"
#include "W3DDevice/GameClient/Module/W3DModelDraw.h"
#include "WW3D2/HAnim.h"
#include "WW3D2/RendObj.h"
#include "WW3D2/Part_Emt.h"
//-------------------------------------------------------------------------------------------------
class W3DTankTruckDrawModuleData : public W3DModelDrawModuleData
{
public:
AsciiString m_dustEffectName;
AsciiString m_dirtEffectName;
AsciiString m_powerslideEffectName;
AsciiString m_frontLeftTireBoneName;
AsciiString m_frontRightTireBoneName;
AsciiString m_rearLeftTireBoneName;
AsciiString m_rearRightTireBoneName;
//4 extra tires to support up to 8 tires.
AsciiString m_midFrontLeftTireBoneName;
AsciiString m_midFrontRightTireBoneName;
AsciiString m_midRearLeftTireBoneName;
AsciiString m_midRearRightTireBoneName;
Real m_rotationSpeedMultiplier;
Real m_powerslideRotationAddition;
//Tank data
AsciiString m_treadDebrisNameLeft;
AsciiString m_treadDebrisNameRight;
Real m_treadAnimationRate; ///<amount of tread texture to scroll per sec. 1.0 == full width.
Real m_treadPivotSpeedFraction; ///<fraction of locomotor speed below which we allow pivoting.
Real m_treadDriveSpeedFraction; ///<fraction of locomotor speed below which treads stop animating.
W3DTankTruckDrawModuleData();
~W3DTankTruckDrawModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
};
//-------------------------------------------------------------------------------------------------
class W3DTankTruckDraw : public W3DModelDraw
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DTankTruckDraw, "W3DTankTruckDraw" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DTankTruckDraw, W3DTankTruckDrawModuleData )
public:
W3DTankTruckDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void setHidden(Bool h);
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void setFullyObscuredByShroud(Bool fullyObscured);
virtual void reactToGeometryChange() { }
protected:
virtual void onRenderObjRecreated(void);
protected:
Bool m_effectsInitialized;
Bool m_wasAirborne;
Bool m_isPowersliding;
/// debris emitters for when tank is moving
ParticleSystem* m_dustEffect;
ParticleSystem* m_dirtEffect;
ParticleSystem* m_powerslideEffect;
Real m_frontWheelRotation;
Real m_rearWheelRotation;
Real m_midFrontWheelRotation;
Real m_midRearWheelRotation;
Int m_frontLeftTireBone;
Int m_frontRightTireBone;
Int m_rearLeftTireBone;
Int m_rearRightTireBone;
//4 extra tires to support up to 8 tires
Int m_midFrontLeftTireBone;
Int m_midFrontRightTireBone;
Int m_midRearLeftTireBone;
Int m_midRearRightTireBone;
AudioEventRTS m_powerslideSound;
AudioEventRTS m_landingSound;
//Tank Data
/// debris emitters for when tank is moving
ParticleSystem* m_treadDebrisLeft;
ParticleSystem* m_treadDebrisRight;
enum TreadType { TREAD_LEFT, TREAD_RIGHT, TREAD_MIDDLE }; //types of treads for different vehicles
enum {MAX_TREADS_PER_TANK=4};
struct TreadObjectInfo
{
RenderObjClass *m_robj; ///<sub-object for tread
TreadType m_type; ///<kind of tread
RenderObjClass::Material_Override m_materialSettings; ///<used to set current uv scroll amount.
};
TreadObjectInfo m_treads[MAX_TREADS_PER_TANK];
Int m_treadCount;
RenderObjClass *m_prevRenderObj;
void createEmitters( void ); ///< Create particle effects.
void tossEmitters( void ); ///< Create particle effects.
void enableEmitters( Bool enable ); ///< stop creating debris from the tank treads
void updateBones( void );
void startMoveDebris( void ); ///< start creating debris from the tank treads
void stopMoveDebris( void ); ///< stop creating debris from the tank treads
void updateTreadObjects(void); ///< update pointers to sub-objects like treads.
void updateTreadPositions(Real uvDelta); ///< update uv coordinates on each tread
};
#endif // _W3D_TANKTRUCK_DRAW_H_

View file

@ -0,0 +1,78 @@
/*
** Command & Conquer Generals(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: W3DTracerDraw.h //////////////////////////////////////////////////////////////////////////
// Author:
// Desc:
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DTRACERDRAW_H_
#define __W3DTRACERDRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/DrawModule.h"
#include "WW3D2/Line3D.h"
//-------------------------------------------------------------------------------------------------
/** W3D tracer draw */
//-------------------------------------------------------------------------------------------------
class W3DTracerDraw : public DrawModule, public TracerDrawInterface
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DTracerDraw, "W3DTracerDraw" )
MAKE_STANDARD_MODULE_MACRO( W3DTracerDraw )
public:
W3DTracerDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void setShadowsEnabled(Bool enable) { }
virtual void releaseShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void allocateShadows(void) {}; ///< we don't care about preserving temporary shadows.
virtual void setFullyObscuredByShroud(Bool fullyObscured) { }
virtual void reactToTransformChange(const Matrix3D* oldMtx, const Coord3D* oldPos, Real oldAngle);
virtual void reactToGeometryChange() { }
virtual void setTracerParms(Real speed, Real length, Real width, const RGBColor& color, Real initialOpacity);
virtual TracerDrawInterface* getTracerDrawInterface() { return this; }
virtual const TracerDrawInterface* getTracerDrawInterface() const { return this; }
protected:
Line3DClass *m_theTracer; ///< the tracer render object in the W3D scene
Real m_length; ///< length of tracer
Real m_width; ///< width of tracer
RGBColor m_color; ///< color of tracer
Real m_speedInDistPerFrame; ///< speed of tracer (in dist/frame)
Real m_opacity; ///< opacity of the tracer
};
#endif // __W3DTRACERDRAW_H_

View file

@ -0,0 +1,146 @@
/*
** Command & Conquer Generals(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: W3DTruckDraw.h ////////////////////////////////////////////////////////////////////////////
// Draw a tank
// Author: John Ahlquist, March 2002
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _W3D_TRUCK_DRAW_H_
#define _W3D_TRUCK_DRAW_H_
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/DrawModule.h"
#include "Common/AudioEventRTS.h"
#include "GameClient/ParticleSys.h"
#include "W3DDevice/GameClient/Module/W3DModelDraw.h"
#include "WW3D2/HAnim.h"
#include "WW3D2/RendObj.h"
#include "WW3D2/Part_Emt.h"
//-------------------------------------------------------------------------------------------------
class W3DTruckDrawModuleData : public W3DModelDrawModuleData
{
public:
AsciiString m_dustEffectName;
AsciiString m_dirtEffectName;
AsciiString m_powerslideEffectName;
AsciiString m_frontLeftTireBoneName;
AsciiString m_frontRightTireBoneName;
AsciiString m_rearLeftTireBoneName;
AsciiString m_rearRightTireBoneName;
//4 extra tires to support up to 8 tires.
AsciiString m_midFrontLeftTireBoneName;
AsciiString m_midFrontRightTireBoneName;
AsciiString m_midRearLeftTireBoneName;
AsciiString m_midRearRightTireBoneName;
//And some more
AsciiString m_midMidLeftTireBoneName;
AsciiString m_midMidRightTireBoneName;
// Cab bone for a segmented truck.
AsciiString m_cabBoneName;
AsciiString m_trailerBoneName;
Real m_cabRotationFactor;
Real m_trailerRotationFactor;
Real m_rotationDampingFactor;
Real m_rotationSpeedMultiplier;
Real m_powerslideRotationAddition;
W3DTruckDrawModuleData();
~W3DTruckDrawModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
};
//-------------------------------------------------------------------------------------------------
class W3DTruckDraw : public W3DModelDraw
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DTruckDraw, "W3DTruckDraw" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( W3DTruckDraw, W3DTruckDrawModuleData )
public:
W3DTruckDraw( Thing *thing, const ModuleData* moduleData );
// virtual destructor prototype provided by memory pool declaration
virtual void setHidden(Bool h);
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void setFullyObscuredByShroud(Bool fullyObscured);
virtual void reactToGeometryChange() { }
protected:
virtual void onRenderObjRecreated(void);
protected:
Bool m_effectsInitialized;
Bool m_wasAirborne;
Bool m_isPowersliding;
/// debris emitters for when tank is moving
ParticleSystem* m_dustEffect;
ParticleSystem* m_dirtEffect;
ParticleSystem* m_powerslideEffect;
Real m_frontWheelRotation;
Real m_rearWheelRotation;
Real m_midFrontWheelRotation;
Real m_midRearWheelRotation;
Int m_frontLeftTireBone;
Int m_frontRightTireBone;
Int m_rearLeftTireBone;
Int m_rearRightTireBone;
//4 extra tires to support up to 8 tires
Int m_midFrontLeftTireBone;
Int m_midFrontRightTireBone;
Int m_midRearLeftTireBone;
Int m_midRearRightTireBone;
//And some more
Int m_midMidLeftTireBone;
Int m_midMidRightTireBone;
Int m_cabBone;
Real m_curCabRotation;
Int m_trailerBone;
Real m_curTrailerRotation;
Int m_prevNumBones;
AudioEventRTS m_powerslideSound;
AudioEventRTS m_landingSound;
RenderObjClass *m_prevRenderObj;
void createEmitters( void ); ///< Create particle effects.
void tossEmitters( void ); ///< Create particle effects.
void enableEmitters( Bool enable ); ///< stop creating debris from the tank treads
void updateBones( void );
};
#endif // _W3D_TRUCK_DRAW_H_

View file

@ -0,0 +1,147 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
// TerrainTex.h
// Class to generate texture for terrain.
// Author: John Ahlquist, April 2001
#pragma once
#ifndef TERRAINTEX_H
#define TERRAINTEX_H
//#define DO_8STAGE_TERRAIN_PASS //optimized terrain rendering for Nvidia based cards
#include "WW3D2/Texture.h"
#include "WWMATH/Matrix3d.h"
#include "common/AsciiString.h"
class WorldHeightMap;
#define TILE_OFFSET 8
/** ***********************************************************************
** TerrainTextureClass
***************************************************************************/
class TerrainTextureClass : public TextureClass
{
W3DMPO_GLUE(TerrainTextureClass)
protected:
virtual void Apply(unsigned int stage);
int update256(WorldHeightMap *htMap);///< Sets the pixels, and returns the actual height of the texture.
public:
/// Create texture for a height map.
TerrainTextureClass(int height, MipCountType mipLevelCount = MIP_LEVELS_3 );
// just use default destructor. ~TerrainTextureClass(void);
public:
int update(WorldHeightMap *htMap); ///< Sets the pixels, and returns the actual height of the texture.
};
class AlphaTerrainTextureClass : public TextureClass
{
W3DMPO_GLUE(AlphaTerrainTextureClass)
protected:
virtual void Apply(unsigned int stage);
public:
// Create texture for a height map.
AlphaTerrainTextureClass(TextureClass *pBaseTex );
// just use default destructor. ~TerrainTextureClass(void);
};
/** ***********************************************************************
** AlphaEdgeTextureClass
***************************************************************************/
class AlphaEdgeTextureClass : public TextureClass
{
W3DMPO_GLUE(AlphaEdgeTextureClass)
protected:
virtual void Apply(unsigned int stage);
int update256(WorldHeightMap *htMap);///< Sets the pixels, and returns the actual height of the texture.
public:
/// Create texture for a height map.
AlphaEdgeTextureClass(int height, MipCountType mipLevelCount = MIP_LEVELS_3 );
// just use default destructor. ~TerrainTextureClass(void);
public:
int update(WorldHeightMap *htMap); ///< Sets the pixels, and returns the actual height of the texture.
};
class LightMapTerrainTextureClass : public TextureClass
{
W3DMPO_GLUE(LightMapTerrainTextureClass)
protected:
virtual void Apply(unsigned int stage);
public:
// Create texture from a height map.
LightMapTerrainTextureClass( AsciiString name, MipCountType mipLevelCount = MIP_LEVELS_ALL );
// just use default destructor.
};
class ScorchTextureClass : public TextureClass
{
W3DMPO_GLUE(ScorchTextureClass)
protected:
virtual void Apply(unsigned int stage);
public:
// Create texture.
ScorchTextureClass( MipCountType mipLevelCount = MIP_LEVELS_3 );
// just use default destructor. ~ScorchTextureClass(void);
};
class CloudMapTerrainTextureClass : public TextureClass
{
W3DMPO_GLUE(CloudMapTerrainTextureClass)
protected:
virtual void Apply(unsigned int stage);
protected:
float m_xSlidePerSecond ; ///< How far the clouds move per second.
float m_ySlidePerSecond ; ///< How far the clouds move per second.
int m_curTick;
float m_xOffset;
float m_yOffset;
public:
// Create texture from a height map.
CloudMapTerrainTextureClass( MipCountType mipLevelCount = MIP_LEVELS_ALL );
// just use default destructor. ~TerrainTextureClass(void);
void restore(void);
};
#endif //TEXTURE_H

View file

@ -0,0 +1,108 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
// TileData.h
// Class to hold 1 tile's data.
// Author: John Ahlquist, April 2001
#pragma once
#ifndef TileData_H
#define TileData_H
#include <stdio.h>
#include "Lib/BaseType.h"
#include "WWLib/RefCount.h"
#include "Common/AsciiString.h"
typedef struct {
Int blendNdx;
UnsignedByte horiz;
UnsignedByte vert;
UnsignedByte rightDiagonal;
UnsignedByte leftDiagonal;
UnsignedByte inverted;
UnsignedByte longDiagonal;
Int customBlendEdgeClass; // Class of texture for a blend edge. -1 means use alpha.
} TBlendTileInfo;
#define INVERTED_MASK 0x1 //AND this with TBlendTileInfo.inverted to get actual inverted state
#define FLIPPED_MASK 0x2 //AND this with TBlendTileInfo.inverted to get forced flip state (for horizontal/vertical flips).
#define TILE_PIXEL_EXTENT 64
#define TILE_BYTES_PER_PIXEL 4
#define DATA_LEN_BYTES TILE_PIXEL_EXTENT*TILE_PIXEL_EXTENT*TILE_BYTES_PER_PIXEL
#define DATA_LEN_PIXELS TILE_PIXEL_EXTENT*TILE_PIXEL_EXTENT
#define TILE_PIXEL_EXTENT_MIP1 32
#define TILE_PIXEL_EXTENT_MIP2 16
#define TILE_PIXEL_EXTENT_MIP3 8
#define TILE_PIXEL_EXTENT_MIP4 4
#define TILE_PIXEL_EXTENT_MIP5 2
#define TILE_PIXEL_EXTENT_MIP6 1
#define TEXTURE_WIDTH 2048 // was 1024 jba
/** This class holds the bitmap data from the .tga texture files. It is used to
create the D3D texture in the game and 3d windows, and to create DIB data for the
2d window. */
class TileData : public RefCountClass
{
protected:
// data is bgrabgrabgra to be compatible with windows blt. jba.
// Also, first byte is lower left pixel, not upper left pixel.
// so 0,0 is lower left, not upper left.
UnsignedByte m_tileData[DATA_LEN_BYTES];
/// Mipped down copies of the tile data.
UnsignedByte m_tileDataMip32[TILE_PIXEL_EXTENT_MIP1*TILE_PIXEL_EXTENT_MIP1*TILE_BYTES_PER_PIXEL];
UnsignedByte m_tileDataMip16[TILE_PIXEL_EXTENT_MIP2*TILE_PIXEL_EXTENT_MIP2*TILE_BYTES_PER_PIXEL];
UnsignedByte m_tileDataMip8[TILE_PIXEL_EXTENT_MIP3*TILE_PIXEL_EXTENT_MIP3*TILE_BYTES_PER_PIXEL];
UnsignedByte m_tileDataMip4[TILE_PIXEL_EXTENT_MIP4*TILE_PIXEL_EXTENT_MIP4*TILE_BYTES_PER_PIXEL];
UnsignedByte m_tileDataMip2[TILE_PIXEL_EXTENT_MIP5*TILE_PIXEL_EXTENT_MIP5*TILE_BYTES_PER_PIXEL];
UnsignedByte m_tileDataMip1[TILE_PIXEL_EXTENT_MIP6*TILE_PIXEL_EXTENT_MIP6*TILE_BYTES_PER_PIXEL];
public:
ICoord2D m_tileLocationInTexture;
protected:
/** doMip - generates the next mip level mipping pHiRes down to pLoRes.
pLoRes is 1/2 the width of pHiRes, and both are square. */
static void doMip(UnsignedByte *pHiRes, Int hiRow, UnsignedByte *pLoRes);
public:
TileData(void);
public:
UnsignedByte *getDataPtr(void) {return(m_tileData);};
static Int dataLen(void) {return(DATA_LEN_BYTES);};
void updateMips(void);
Bool hasRGBDataForWidth(Int width);
UnsignedByte *getRGBDataForWidth(Int width);
};
#endif

View file

@ -0,0 +1,123 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : W3DAssetManager *
* *
* $Archive:: $*
* *
* Original Author:: Hector Yee *
* *
* $Author:: $*
* *
* $Modtime:: $*
* *
* $Revision:: $*
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#if defined(_MSC_VER)
#pragma once
#endif
#ifndef W3DASSETMANAGER_H
#define W3DASSETMANAGER_H
#include "assetmgr.h"
#include "Lib/BaseType.h"
class Vector3;
class VertexMaterialClass;
class GrannyAnimManagerClass;
class W3DAssetManager: public WW3DAssetManager
{
public:
W3DAssetManager(void);
virtual ~W3DAssetManager(void);
virtual RenderObjClass * Create_Render_Obj(const char * name);
// unique to W3DAssetManager
virtual HAnimClass * Get_HAnim(const char * name);
virtual bool Load_3D_Assets( const char * filename ); // This CANNOT be Bool, as it will not inherit properly if you make Bool == Int
virtual TextureClass * Get_Texture(
const char * filename,
TextureClass::MipCountType mip_level_count=TextureClass::MIP_LEVELS_ALL,
WW3DFormat texture_format=WW3D_FORMAT_UNKNOWN,
bool allow_compression=true);
//'Generals' customizations
void Report_Used_Assets(void);
void Report_Used_Prototypes (void);
void Report_Used_Textures(void);
void Report_Used_Font3DDatas( void );
void Report_Used_FontChars (void);
virtual RenderObjClass * Create_Render_Obj(const char * name,float scale, const int color, const char *oldTexure=NULL, const char *newTexture=NULL);
///Swaps the specified textures in the render object prototype.
int replacePrototypeTexture(RenderObjClass *robj, const char * oldname, const char * newname);
private:
void Make_Mesh_Unique(RenderObjClass *robj,Bool geometry, Bool colors);
void Make_HLOD_Unique(RenderObjClass *robj,Bool geometry, Bool colors);
void Make_Unique(RenderObjClass *robj,Bool geometry, Bool colors);
//'Generals' customizations
int Recolor_Asset(RenderObjClass *robj, const int color);
int Recolor_Mesh(RenderObjClass *robj, const int color);
int Recolor_HLOD(RenderObjClass *robj, const int color);
void Recolor_Vertex_Material(VertexMaterialClass *vmat, const int color);
void Make_Mesh_Unique(RenderObjClass *robj, Bool colors);
void Make_HLOD_Unique(RenderObjClass *robj, Bool colors);
TextureClass * Find_Texture(const char * name, const int color);
TextureClass * Recolor_Texture(TextureClass *texture, const int color);
TextureClass * Recolor_Texture_One_Time(TextureClass *texture, const int color);
void Remap_Palette(SurfaceClass *surface, const int color, Bool doPaletteOnly, Bool useAlpha);
int replaceAssetTexture(RenderObjClass *robj, TextureClass *oldTex, TextureClass *newTex);
int replaceHLODTexture(RenderObjClass *robj, TextureClass *oldTex, TextureClass *newTex);
int replaceMeshTexture(RenderObjClass *robj, TextureClass *oldTex, TextureClass *newTex);
GrannyAnimManagerClass *m_GrannyAnimManager;
//'E&B' customizations
/* virtual RenderObjClass * Create_Render_Obj(const char * name, float scale, const Vector3 &hsv_shift);
TextureClass * Get_Texture_With_HSV_Shift(const char * filename, const Vector3 &hsv_shift, TextureClass::MipCountType mip_level_count = TextureClass::MIP_LEVELS_ALL);
void Recolor_Vertex_Material(VertexMaterialClass *vmat, const Vector3 &hsv_shift);
void Recolor_Vertices(unsigned int *color, int count, const Vector3 &hsv_shift);
void Recolor_Mesh(RenderObjClass *robj, const Vector3 &hsv_shift);
TextureClass * Recolor_Texture(TextureClass *texture, const Vector3 &hsv_shift);
TextureClass * Recolor_Texture_One_Time(TextureClass *texture, const Vector3 &hsv_shift);
TextureClass * Find_Texture(const char * name, const Vector3 &hsv_shift);
void Recolor_HLOD(RenderObjClass *robj, const Vector3 &hsv_shift);
void Recolor_ParticleEmitter(RenderObjClass *robj, const Vector3 &hsv_shift);
void Recolor_Asset(RenderObjClass *robj, const Vector3 &hsv_shift);*/
};
#endif

View file

@ -0,0 +1,56 @@
/*
** Command & Conquer Generals(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: W3DAssetManagerExposed.h
/*---------------------------------------------------------------------------*/
/* EA Pacific */
/* Confidential Information */
/* Copyright (C) 2001 - All Rights Reserved */
/* DO NOT DISTRIBUTE */
/*---------------------------------------------------------------------------*/
/* Project: RTS3 */
/* File name: W3DAssetManagerExposed.h */
/* Created: John K. McDonald, Jr., 4/27/2002 */
/* Desc: A hack to get around our build structure. */
/* Revision History: */
/* 4/27/2002 : Initial creation */
/*---------------------------------------------------------------------------*/
#pragma once
#ifndef _H_W3DASSETMANAGEREXPOSED_
#define _H_W3DASSETMANAGEREXPOSED_
// INCLUDES ///////////////////////////////////////////////////////////////////
// DEFINES ////////////////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// FORWARD DECLARATIONS ///////////////////////////////////////////////////////
// This function is here because the particle editor needs to be able to force
// the asset manager to release all his textures and then reload them on demand.
// Unfortunately, the asset manager can't be called directly from the gamelogic,
// so this function is here. It should only be called by the particle editor,
// @todo Remove this function when we are no longer editing particles.
void ReloadAllTextures(void);
#endif /* _H_W3DASSETMANAGEREXPOSED_ */

View file

@ -0,0 +1,135 @@
/*
** Command & Conquer Generals(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: W3DBibBuffer.h //////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: W3DBibBuffer.h
//
// Created: John Ahlquist, May 2001
//
// Desc: Draw buffer to handle all the bibs in a scene.
//
//-----------------------------------------------------------------------------
#pragma once
#ifndef __W3DBIB_BUFFER_H_
#define __W3DBIB_BUFFER_H_
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#include "common/GameType.h"
#include "Common/AsciiString.h"
//-----------------------------------------------------------------------------
// Forward References
//-----------------------------------------------------------------------------
class MeshClass;
//-----------------------------------------------------------------------------
// Type Defines
//-----------------------------------------------------------------------------
/// The individual data for a Bib.
typedef struct {
Vector3 m_corners[4]; ///< Drawing location
Bool m_highlight; ///< Use the highlight texture.
Int m_color; ///< Tint perhaps.
ObjectID m_objectID; ///< The object id this bib corresponds to.
DrawableID m_drawableID; ///< The object id this bib corresponds to.
Bool m_unused; ///< True if this bib is currently unused.
} TBib;
//
// W3DBibBuffer: Draw buffer for the bibs.
//
//
class W3DBibBuffer
{
friend class HeightMapRenderObjClass;
public:
W3DBibBuffer(void);
~W3DBibBuffer(void);
/// Add a bib at location. Name is the w3d model name.
void addBib(Vector3 corners[4], ObjectID id, Bool highlight);
void addBibDrawable(Vector3 corners[4], DrawableID id, Bool highlight);
/// Add a bib at location. Name is the w3d model name.
void removeBib(ObjectID id);
void removeBibDrawable(DrawableID id);
/// Empties the bib buffer.
void clearAllBibs(void);
/// Removes highlighting.
void removeHighlighting(void);
/// Draws the bibs.
void renderBibs();
/// Called when the view changes, and sort key needs to be recalculated.
/// Normally sortKey gets calculated when a bib becomes visible.
protected:
enum { INITIAL_BIB_VERTEX=256,
INITIAL_BIB_INDEX=384,
MAX_BIBS=1000};
DX8VertexBufferClass *m_vertexBib; ///<Bib vertex buffer.
Int m_vertexBibSize; ///< Num vertices in bib buffer.
DX8IndexBufferClass *m_indexBib; ///<indices defining a triangles for the bib drawing.
Int m_indexBibSize; ///<indices available in m_indexBib.
TextureClass *m_bibTexture; ///<Bibs texture
TextureClass *m_highlightBibTexture; ///<Bibs texture
Int m_curNumBibVertices; ///<Number of vertices used in m_vertexBib.
Int m_curNumBibIndices; ///<Number of indices used in b_indexBib;
Int m_curNumNormalBibIndices; ///< Number of non-highlighted bib index.
Int m_curNumNormalBibVertex; ///< Number of non-highlighted bib vertex.
TBib m_bibs[MAX_BIBS]; ///< The bib buffer. All bibs are stored here.
Int m_numBibs; ///< Number of bibs in m_bibs.
Bool m_anythingChanged; ///< Set to true if visibility or sorting changed.
Bool m_updateAllKeys; ///< Set to true when the view changes.
Bool m_initialized; ///< True if the subsystem initialized.
Bool m_isTerrainPass; ///< True if the terrain was drawn in this W3D scene render pass.
void loadBibsInVertexAndIndexBuffers(void); ///< Fills the index and vertex buffers for drawing.
void allocateBibBuffers(void); ///< Allocates the buffers.
void freeBibBuffers(void); ///< Frees the index and vertex buffers.
};
#endif // end __W3DBIB_BUFFER_H_

View file

@ -0,0 +1,190 @@
/*
** Command & Conquer Generals(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: W3DBridgeBuffer.h //////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: W3DBridgeBuffer.h
//
// Created: John Ahlquist, May 2001
//
// Desc: Draw buffer to handle all the bridges in a scene.
//
//-----------------------------------------------------------------------------
#pragma once
#ifndef __W3DBRIDGE_BUFFER_H_
#define __W3DBRIDGE_BUFFER_H_
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#include "common/GameType.h"
#include "Common/Dict.h"
#include "Common/AsciiString.h"
//-----------------------------------------------------------------------------
// Forward References
//-----------------------------------------------------------------------------
class MeshClass;
class W3DTerrainLogic;
class W3DAssetManager;
class SimpleSceneClass;
//-----------------------------------------------------------------------------
// Type Defines
//-----------------------------------------------------------------------------
typedef enum {
FIXED_BRIDGE = 0,
SECTIONAL_BRIDGE = 1
} TBridgeType;
class BridgeInfo;
/// The individual data for a bridge.
class W3DBridge
{
protected:
Vector3 m_start; ///< Drawing location
Vector3 m_end; ///< Drawing location
Real m_scale; ///< Width scale.
Real m_length;
TBridgeType m_bridgeType; ///< Type of bridge. Currently only 2 supported.
SphereClass m_bounds; ///< Bounding sphere for culling to set the visible flag.
TextureClass *m_bridgeTexture;
MeshClass *m_leftMesh; ///< W3D mesh models for the bridges.
Matrix3D m_leftMtx; ///< Transform for the left mesh.
Real m_minY; ///< min y vertex.
Real m_maxY; ///< max y vertex.
Real m_leftMinX; ///< m_leftMesh min x vertex.
Real m_leftMaxX; ///< m_leftMesh max x vertex.
MeshClass *m_sectionMesh; ///< W3D mesh models for the bridges.
Matrix3D m_sectionMtx; ///< Transform for the section mesh.
Real m_sectionMinX; ///< m_sectionMesh min x vertex.
Real m_sectionMaxX; ///< m_sectionMesh max x vertex.
MeshClass *m_rightMesh; ///< W3D mesh models for the bridges.
Matrix3D m_rightMtx; ///< Transform for the right mesh.
Real m_rightMinX; ///< m_rightMesh min x vertex.
Real m_rightMaxX; ///< m_rightMesh max x vertex.
Int m_firstIndex; ///< Starting index buffer.
Int m_numVertex; ///< Number of vertex used.
Int m_firstVertex; ///< First vertex.
Int m_numPolygons; ///< Number of polygons to draw.
Bool m_visible;
AsciiString m_templateName; ///< Name of the bridge type.
enum BodyDamageType m_curDamageState;
Bool m_enabled;
protected:
Int getModelVerticesFixed(VertexFormatXYZNDUV1 *destination_vb, Int curVertex, const Matrix3D &mtx, MeshClass *pMesh, RefRenderObjListIterator *pLightsIterator);
Int getModelIndices(UnsignedShort *destination_ib, Int curIndex, Int vertexOffset, MeshClass *pMesh);
Int getModelVertices(VertexFormatXYZNDUV1 *destination_vb, Int curVertex, Real xOffset,
Vector3 &vec, Vector3 &vecNormal, Vector3 &vecZ, Vector3 &offset,
const Matrix3D &mtx,
MeshClass *pMesh, RefRenderObjListIterator *pLightsIterator);
public:
W3DBridge(void);
~W3DBridge(void);
void init(Vector3 fromLoc, Vector3 toLoc, AsciiString name);
AsciiString getTemplateName(void) {return m_templateName;}
const Vector3* getStart(void) const {return &m_start;}
const Vector3* getEnd(void) const { return &m_end;}
Bool load(enum BodyDamageType curDamageState);
enum BodyDamageType getDamageState(void) {return m_curDamageState;};
void setDamageState(enum BodyDamageType state) { m_curDamageState = state;};
void getIndicesNVertices(UnsignedShort *destination_ib, VertexFormatXYZNDUV1 *destination_vb, Int *curIndexP, Int *curVertexP, RefRenderObjListIterator *pLightsIterator);
Bool cullBridge(CameraClass * camera); ///< Culls the bridges. Returns true if visibility changed.
void clearBridge(void); ///< Frees all objects associated with a bridge.
Bool isVisible(void) {return m_visible;};
Bool isEnabled(void) {return m_enabled;};
void setEnabled(Bool enable) {m_enabled = enable;};
void renderBridge(Bool wireframe);
void getBridgeInfo(BridgeInfo *pInfo);
};
//
// W3DBridgeBuffer: Draw buffer for the bridges.
//
//
class W3DBridgeBuffer
{
friend class HeightMapRenderObjClass;
public:
W3DBridgeBuffer(void);
~W3DBridgeBuffer(void);
/// Empties the bridge buffer.
void clearAllBridges(void);
/// Draws the bridges. Uses camera for culling.
void drawBridges(CameraClass * camera, Bool wireframe, TextureClass *cloudTexture);
/// Called when the view changes, and sort key needs to be recalculated.
/// Normally sortKey gets calculated when a bridge becomes visible.
void doFullUpdate(void) {m_updateVis = true;};
void loadBridges(W3DTerrainLogic *pTerrainLogic, Bool saveGame); ///< Loads the bridges from the map objects list.
void worldBuilderUpdateBridgeTowers( W3DAssetManager *assetManager, SimpleSceneClass *scene ); ///< for the editor and showing visual bridge towers
void updateCenter(CameraClass *camera, RefRenderObjListIterator *pLightsIterator);
enum { MAX_BRIDGE_VERTEX=8000,
MAX_BRIDGE_INDEX=2*8000,
MAX_BRIDGES=200};
protected:
DX8VertexBufferClass *m_vertexBridge; ///<Bridge vertex buffer.
DX8IndexBufferClass *m_indexBridge; ///<indices defining a triangles for the bridge drawing.
VertexMaterialClass *m_vertexMaterial;
TextureClass *m_bridgeTexture; ///<Bridges texture
Int m_curNumBridgeVertices; ///<Number of vertices used in m_vertexBridge.
Int m_curNumBridgeIndices; ///<Number of indices used in b_indexBridge;
W3DBridge m_bridges[MAX_BRIDGES]; ///< The bridge buffer. All bridges are stored here.
Int m_numBridges; ///< Number of bridges in m_bridges.
Bool m_initialized; ///< True if the subsystem initialized.
Bool m_updateVis; ///< True if the camera moved, and we need to recalculate visibility.
Bool m_anythingChanged; ///< Set to true if visibility changed.
/// Add a bridge at location. Name is the gdf item name.
void addBridge(Vector3 fromLoc, Vector3 toLoc, AsciiString name, W3DTerrainLogic *pTerrainLogic, Dict *props);
void loadBridgesInVertexAndIndexBuffers(RefRenderObjListIterator *pLightsIterator); ///< Fills the index and vertex buffers for drawing.
void allocateBridgeBuffers(void); ///< Allocates the buffers.
void cull(CameraClass * camera); ///< Culls the bridges.
void freeBridgeBuffers(void); ///< Frees the index and vertex buffers.
};
#endif // end __W3DBRIDGE_BUFFER_H_

View file

@ -0,0 +1,180 @@
/*
** Command & Conquer Generals(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: W3DBufferManager.h ///////////////////////////////////////////////////////////////////////////
// Author: Mark Wilczynski
// Desc: A system for managing partial vertex buffer allocations.
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _W3D_VERTEX_BUFFER_MANAGER
#define _W3D_VERTEX_BUFFER_MANAGER
#include "Lib/BaseType.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#define MAX_VB_SIZES 128 //number of different sized VB slots allowed.
#define MIN_SLOT_SIZE 32 //minimum number of vertices allocated per slot (power of 2). See also MIN_SLOT_SIZE_SHIFT.
#define MIN_SLOT_SIZE_SHIFT 5 //used for division by MIN_SLOT_SIZE
#define MAX_VERTEX_BUFFERS_CREATED 32 //maximum number of D3D vertex buffers allowed to create per vertex type.
#define DEFAULT_VERTEX_BUFFER_SIZE 8192 //this size ends up generating VB's of about 256Kbytes
#define MAX_NUMBER_SLOTS 4096 //maximum number of slots that can be allocated.
#define MAX_IB_SIZES 128 //number of different sized IB slots allowed (goes all the way up to 65536)
#define MAX_INDEX_BUFFERS_CREATED 32
#define DEFAULT_INDEX_BUFFER_SIZE 32768
class W3DBufferManager
{
public:
//List of all possible vertex formats available to the game.
enum VBM_FVF_TYPES
{
VBM_FVF_XYZ, //position
VBM_FVF_XYZD, //position, diffuse
VBM_FVF_XYZUV, //position, uv
VBM_FVF_XYZDUV, //position, diffuse, uv
VBM_FVF_XYZUV2, //position, uv1, uv2
VBM_FVF_XYZDUV2, //position, diffuse, uv1, uv2
VBM_FVF_XYZN, //position, normal
VBM_FVF_XYZND, //position, normal, diffuse
VBM_FVF_XYZNUV, //position, normal, uv
VBM_FVF_XYZNDUV, //position, normal, diffuse, uv
VBM_FVF_XYZNUV2, //position, normal, uv1, uv2
VBM_FVF_XYZNDUV2, //position, normal, diffuse, uv1, uv2
VBM_FVF_XYZRHW, //transformed position
VBM_FVF_XYZRHWD, //transformed position, diffuse
VBM_FVF_XYZRHWUV, //transformed position, uv
VBM_FVF_XYZRHWDUV, //transformed position, diffuse, uv
VBM_FVF_XYZRHWUV2, //transformed position, uv1, uv2
VBM_FVF_XYZRHWDUV2, //transformed position, diffuse, uv1, uv2
MAX_FVF
};
struct W3DRenderTask
{
W3DRenderTask *m_nextTask; ///<next rendering task
};
struct W3DVertexBuffer; //forward reference
struct W3DIndexBuffer; //forward reference
struct W3DVertexBufferSlot
{
Int m_size; ///<number of vertices in slot
Int m_start; ///<index of first vertex within VB
W3DVertexBuffer *m_VB; ///<vertex buffer holding this slot.
W3DVertexBufferSlot *m_prevSameSize; //previous slot of equal size.
W3DVertexBufferSlot *m_nextSameSize; //next slot of equal size.
W3DVertexBufferSlot *m_prevSameVB; //previous slot in same VB.
W3DVertexBufferSlot *m_nextSameVB; //next slot in same VB.
};
struct W3DVertexBuffer
{
VBM_FVF_TYPES m_format; ///<format of vertices in this VB.
W3DVertexBufferSlot *m_usedSlots; ///<slots inside this vertex buffer being used.
Int m_startFreeIndex; ///<index of vertex at start of unallocated memory.
Int m_size; ///<number of vertices allowed in VB.
W3DVertexBuffer *m_nextVB; ///<next vertex buffer of same type.
DX8VertexBufferClass *m_DX8VertexBuffer; ///<actual DX8 vertex buffer interface
W3DRenderTask *m_renderTaskList; ///<used to help app sort its D3D access by VB.
};
struct W3DIndexBufferSlot
{
Int m_size; ///<number of vertices in slot
Int m_start; ///<index of first index within VB
W3DIndexBuffer *m_IB; ///<index buffer holding this slot.
W3DIndexBufferSlot *m_prevSameSize; //previous slot of equal size.
W3DIndexBufferSlot *m_nextSameSize; //next slot of equal size.
W3DIndexBufferSlot *m_prevSameIB; //previous slot in same VB.
W3DIndexBufferSlot *m_nextSameIB; //next slot in same VB.
};
struct W3DIndexBuffer
{
W3DIndexBufferSlot *m_usedSlots; ///<slots inside this index buffer being used.
Int m_startFreeIndex; ///<index of index at start of unallocated memory.
Int m_size; ///<number of vertices allowed in VB.
W3DIndexBuffer *m_nextIB; ///<next index buffer of same type.
DX8IndexBufferClass *m_DX8IndexBuffer; ///<actual DX8 index buffer interface
};
W3DBufferManager(void);
~W3DBufferManager(void);
///return free vertex buffer memory slot.
W3DVertexBufferSlot *getSlot(VBM_FVF_TYPES fvfType, Int size);
///return free index buffer memory slot.
W3DIndexBufferSlot *getSlot(Int size);
void releaseSlot(W3DVertexBufferSlot *vbSlot); ///<return slot to pool
void releaseSlot(W3DIndexBufferSlot *vbSlot); ///<return slot to pool
void freeAllSlots(void); ///<release all slots to pool.
void freeAllBuffers(void); ///<release all vertex buffers to pool.
void W3DBufferManager::ReleaseResources(void); ///<release D3D/W3D resources.
Bool W3DBufferManager::ReAcquireResources(void); ///<reaquire D3D/W3D resources.
///allows iterating over vertex buffers used by manager. Input of NULL to get first.
W3DVertexBuffer *getNextVertexBuffer(W3DVertexBuffer *pVb, VBM_FVF_TYPES type)
{ if (pVb == NULL)
return m_W3DVertexBuffers[type];
return pVb->m_nextVB;
};
static Int getDX8Format(VBM_FVF_TYPES format); ///<translates our vertex format into D3D equivalent
protected:
///holds previously allocated slots that are free to fill again.
W3DVertexBufferSlot *m_W3DVertexBufferSlots[MAX_FVF][MAX_VB_SIZES];
///holds allocated vertex buffers of each type.
W3DVertexBuffer *m_W3DVertexBuffers[MAX_FVF];
///holds unallocated slot wrappers which were never initialized
W3DVertexBufferSlot m_W3DVertexBufferEmptySlots[MAX_NUMBER_SLOTS];
Int m_numEmptySlotsAllocated;
///holds unallocated vertex buffer wrappers which were never initialized
W3DVertexBuffer m_W3DEmptyVertexBuffers[MAX_VERTEX_BUFFERS_CREATED];
Int m_numEmptyVertexBuffersAllocated;
///holds previously allocated slots that are free to fill again.
W3DIndexBufferSlot *m_W3DIndexBufferSlots[MAX_IB_SIZES];
///holds allocated index buffers of each type.
W3DIndexBuffer *m_W3DIndexBuffers;
///holds unallocated slot wrappers which were never initialized
W3DIndexBufferSlot m_W3DIndexBufferEmptySlots[MAX_NUMBER_SLOTS];
Int m_numEmptyIndexSlotsAllocated;
///holds unallocated index buffer wrappers which were never initialized
W3DIndexBuffer m_W3DEmptyIndexBuffers[MAX_INDEX_BUFFERS_CREATED];
Int m_numEmptyIndexBuffersAllocated;
///allocate new memory inside a vertex buffer.
W3DVertexBufferSlot *allocateSlotStorage(VBM_FVF_TYPES fvfType, Int size);
W3DIndexBufferSlot *allocateSlotStorage(Int size);
};
extern W3DBufferManager *TheW3DBufferManager; //singleton
#endif //_W3D_VERTEX_BUFFER_MANAGER

View file

@ -0,0 +1,111 @@
/*
** Command & Conquer Generals(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: W3DCustomEdging.h //////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: W3DCustomEdging.h
//
// Created: John Ahlquist, May 2001
//
// Desc: Draw buffer to handle all the trees in a scene.
//
//-----------------------------------------------------------------------------
#pragma once
#ifndef __W3DCUSTOM_EDGING_H_
#define __W3DCUSTOM_EDGING_H_
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#include "common/GameType.h"
#include "Common/AsciiString.h"
//-----------------------------------------------------------------------------
// Forward References
//-----------------------------------------------------------------------------
class WorldHeightMap;
//-----------------------------------------------------------------------------
// Type Defines
//-----------------------------------------------------------------------------
//
// W3DCustomEdging: Draw buffer for the trees.
//
//
class W3DCustomEdging
{
friend class HeightMapRenderObjClass;
public:
W3DCustomEdging(void);
~W3DCustomEdging(void);
void addEdging(Coord3D location, Real scale, Real angle, AsciiString name, Bool visibleInMirror);
/// Empties the tree buffer.
void clearAllEdging(void);
/// Draws the trees. Uses camera for culling.
void drawEdging( WorldHeightMap *pMap, Int minX, Int maxX, Int minY, Int maxY,
TextureClass * terrainTexture, TextureClass * cloudTexture, TextureClass * noiseTexture );
/// Called when the view changes, and sort key needs to be recalculated.
/// Normally sortKey gets calculated when a tree becomes visible.
void doFullUpdate(void) {clearAllEdging();};
protected:
#define MAX_BLENDS 2000
enum { MAX_EDGE_VERTEX=4*MAX_BLENDS,
MAX_EDGE_INDEX=6*MAX_BLENDS};
DX8VertexBufferClass *m_vertexEdging; ///<Edging vertex buffer.
DX8IndexBufferClass *m_indexEdging; ///<indices defining a triangles for the tree drawing.
Int m_curNumEdgingVertices; ///<Number of vertices used in m_vertexEdging.
Int m_curNumEdgingIndices; ///<Number of indices used in b_indexEdging;
Int m_curEdgingIndexOffset; ///<First index to draw at. We draw the trees backwards by filling up the index buffer backwards,
// so any trees that don't fit are far away from the camera.
Bool m_anythingChanged; ///< Set to true if visibility or sorting changed.
Bool m_initialized; ///< True if the subsystem initialized.
void allocateEdgingBuffers(void); ///< Allocates the buffers.
void freeEdgingBuffers(void); ///< Frees the index and vertex buffers.
void loadEdgingsInVertexAndIndexBuffers(WorldHeightMap *pMap, Int minX, Int maxX, Int minY, Int maxY);
};
#endif // end __W3DCUSTOM_EDGING_H_

View file

@ -0,0 +1,36 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DCUSTOMSCENE_H_
#define __W3DCUSTOMSCENE_H_
enum CustomScenePassModes
{
SCENE_PASS_DEFAULT,
SCENE_PASS_ALPHA_MASK
};
#endif //W3DCUSTOMSCENE

View file

@ -0,0 +1,104 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//----------------------------------------------------------------------------
//
// Project: Generals
//
// Module: Debug
//
// File name: W3DDevice/GameClient/W3DDebugDisplay.h
//
// Created: 11/13/01 TR
//
//----------------------------------------------------------------------------
#pragma once
#ifndef __W3DDEVICE_GAMECLIENT_W3DDEBUGDISPLAY_H
#define __W3DDEVICE_GAMECLIENT_W3DDEBUGDISPLAY_H
//----------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------
#include "GameClient/DebugDisplay.h"
//----------------------------------------------------------------------------
// Forward References
//----------------------------------------------------------------------------
class GameFont;
class DisplayString;
//----------------------------------------------------------------------------
// Type Defines
//----------------------------------------------------------------------------
//===============================
// W3DDebugDisplay
//===============================
class W3DDebugDisplay : public DebugDisplay
{
public:
W3DDebugDisplay();
virtual ~W3DDebugDisplay();
void init( void ); ///< Initialized the display
void setFont( GameFont *font ); ///< Set the font to render with
void setFontWidth( Int width ) { m_fontWidth = width; }; ///< Set the font width
void setFontHeight( Int height ) { m_fontHeight = height; }; ///< Set the font height
protected:
GameFont *m_font; ///< Font to render text with
Int m_fontWidth;
Int m_fontHeight;
DisplayString *m_displayString;
virtual void drawText( Int x, Int y, Char *text ); ///< Render null ternimated string at current cursor position
};
//----------------------------------------------------------------------------
// Inlining
//----------------------------------------------------------------------------
#endif // __W3DDEVICE_GAMECLIENT_W3DDEBUGDISPLAY_H

View file

@ -0,0 +1,81 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3D_DEBUG_ICONS_H_
#define __W3D_DEBUG_ICONS_H_
#include "always.h"
#include "rendobj.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#if defined _DEBUG || defined _INTERNAL
struct DebugIcon;
//
/// W3DDebugIcons: Draws huge numbers of debug icons for pathfinding quickly.
//
//
class W3DDebugIcons : public RenderObjClass
{
public:
W3DDebugIcons(void);
W3DDebugIcons(const W3DDebugIcons & src);
W3DDebugIcons & operator = (const W3DDebugIcons &);
~W3DDebugIcons(void);
/////////////////////////////////////////////////////////////////////////////
// Render Object Interface
/////////////////////////////////////////////////////////////////////////////
virtual RenderObjClass * Clone(void) const;
virtual int Class_ID(void) const;
virtual void Render(RenderInfoClass & rinfo);
virtual bool Cast_Ray(RayCollisionTestClass & raytest);
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const;
protected:
VertexMaterialClass *m_vertexMaterialClass;
protected:
static DebugIcon *m_debugIcons;
static Int m_numDebugIcons;
protected:
enum {MAX_ICONS = 100000};
void allocateIconsArray(void);
void compressIconsArray(void);
public:
static void addIcon(const Coord3D *pos, Real width, Int numFramesDuration, RGBColor color);
};
#endif // _DEBUG or _INTERNAL
#endif // end __W3D_DEBUG_ICONS_H_

View file

@ -0,0 +1,202 @@
/*
** Command & Conquer Generals(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: W3DDisplay.h /////////////////////////////////////////////////////////
//
// W3D Implementation for the W3D Display which is responsible for creating
// and maintaning the entire visual display
//
// Author: Colin Day, April 2001
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DDISPLAY_H_
#define __W3DDISPLAY_H_
#include "GameClient/Display.h"
#include "WW3D2/lightenvironment.h"
class VideoBuffer;
class W3DDebugDisplay;
class DisplayString;
class W3DAssetManager;
class LightClass;
class Render2DClass;
class RTS3DScene;
class RTS2DScene;
class RTS3DInterfaceScene;
//=============================================================================
/** W3D implementation of the game display which is responsible for creating
* all interaction with the screen and updating the display
*/
class W3DDisplay : public Display
{
public:
W3DDisplay();
~W3DDisplay();
virtual void init( void ); ///< initialize or re-initialize the sytsem
virtual void reset( void ) ; ///< Reset system
virtual void setWidth( UnsignedInt width );
virtual void setHeight( UnsignedInt height );
virtual Bool setDisplayMode( UnsignedInt xres, UnsignedInt yres, UnsignedInt bitdepth, Bool windowed );
virtual Int getDisplayModeCount(void); ///<return number of display modes/resolutions supported by video card.
virtual void getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres, Int *bitDepth); ///<return description of mode
virtual void setGamma(Real gamma, Real bright, Real contrast, Bool calibrate);
virtual void doSmartAssetPurgeAndPreload(const char* usageFileName);
#if defined(_DEBUG) || defined(_INTERNAL)
virtual void dumpAssetUsage(const char* mapname);
#endif
//---------------------------------------------------------------------------
// Drawing management
virtual void setClipRegion( IRegion2D *region ); ///< Set clip rectangle for 2D draw operations.
virtual Bool isClippingEnabled( void ) { return m_isClippedEnabled; }
virtual void enableClipping( Bool onoff ) { m_isClippedEnabled = onoff; }
virtual void draw( void ); ///< redraw the entire display
/// @todo Replace these light management routines with a LightManager singleton
virtual void createLightPulse( const Coord3D *pos, const RGBColor *color, Real innerRadius,Real outerRadius,
UnsignedInt increaseFrameTime, UnsignedInt decayFrameTime//, Bool donut = FALSE
);
virtual void setTimeOfDay ( TimeOfDay tod );
/// draw a line on the display in screen coordinates
virtual void drawLine( Int startX, Int startY, Int endX, Int endY,
Real lineWidth, UnsignedInt lineColor );
/// draw a line on the display in screen coordinates
virtual void drawLine( Int startX, Int startY, Int endX, Int endY,
Real lineWidth, UnsignedInt lineColor1, UnsignedInt lineColor2 );
/// draw a rect border on the display in pixel coordinates with the specified color
virtual void drawOpenRect( Int startX, Int startY, Int width, Int height,
Real lineWidth, UnsignedInt lineColor );
/// draw a filled rect on the display in pixel coords with the specified color
virtual void drawFillRect( Int startX, Int startY, Int width, Int height,
UnsignedInt color );
/// Draw a percentage of a rectangle, much like a clock (0 to x%)
virtual void drawRectClock(Int startX, Int startY, Int width, Int height, Int percent, UnsignedInt color);
/// Draw's the remaining percentage of a rectangle (x% to 100)
virtual void drawRemainingRectClock(Int startX, Int startY, Int width, Int height, Int percent, UnsignedInt color);
/// draw an image fit within the screen coordinates
virtual void drawImage( const Image *image, Int startX, Int startY,
Int endX, Int endY, Color color = 0xFFFFFFFF, DrawImageMode mode=DRAW_IMAGE_ALPHA);
/// draw a video buffer fit within the screen coordinates
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY,
Int endX, Int endY );
virtual VideoBuffer* createVideoBuffer( void ) ; ///< Create a video buffer that can be used for this display
virtual void takeScreenShot(void); //save screenshot to file
virtual void toggleMovieCapture(void); //enable AVI or frame capture mode.
virtual void toggleLetterBox(void); ///<enabled letter-boxed display
virtual void enableLetterBox(Bool enable); ///<forces letter-boxed display on/off
virtual Bool isLetterBoxFading(void); ///<returns true while letterbox fades in/out
virtual void clearShroud();
virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting);
virtual void setBorderShroudLevel(UnsignedByte level); ///<color that will appear in unused border terrain.
#if defined(_DEBUG) || defined(_INTERNAL)
virtual void dumpModelAssets(const char *path); ///< dump all used models/textures to a file.
#endif
virtual void preloadModelAssets( AsciiString model ); ///< preload model asset
virtual void preloadTextureAssets( AsciiString texture ); ///< preload texture asset
/// @todo Need a scene abstraction
static RTS3DScene *m_3DScene; ///< our 3d scene representation
static RTS2DScene *m_2DScene; ///< our 2d scene representation
static RTS3DInterfaceScene *m_3DInterfaceScene; ///< our 3d interface scene that draws last (for 3d mouse cursor, etc)
static W3DAssetManager *m_assetManager; ///< W3D asset manager
void drawFPSStats( void ); ///< draw the fps on the screen
virtual Real getAverageFPS( void ); ///< return the average FPS.
virtual Int getLastFrameDrawCalls( void ); ///< returns the number of draw calls issued in the previous frame
protected:
void initAssets( void ); ///< init assets for WW3D
void init3DScene( void ); ///< init 3D scene for WW3D
void init2DScene( void ); ///< init 2D scene for WW3D
void gatherDebugStats( void ); ///< compute debug stats
void drawDebugStats( void ); ///< display debug stats
void drawCurrentDebugDisplay( void ); ///< draws current debug display
void calculateTerrainLOD(void); ///< Calculate terrain LOD.
void renderLetterBox(UnsignedInt time); ///< draw letter box border
void updateAverageFPS(void); ///< figure out the average fps over the last 30 frames.
Byte m_initialized; ///< TRUE when system is initialized
LightClass *m_myLight[LightEnvironmentClass::MAX_LIGHTS]; ///< light hack for now
Render2DClass *m_2DRender; ///< interface for common 2D functions
IRegion2D m_clipRegion; ///< the clipping region for images
Bool m_isClippedEnabled; ///<used by 2D drawing operations to define clip re
Real m_averageFPS; ///<average fps over the last 30 frames.
#if defined(_DEBUG) || defined(_INTERNAL)
Int64 m_timerAtCumuFPSStart;
#endif
enum
{
FPS, ///< debug display frames per second
Frame, ///< debug display current frame
Polygons, ///< debug display polygons
Vertices, ///< debug display vertices
VideoRam, ///< debug display for video ram used
DebugInfo, ///< miscellaneous debug info string
KEY_MOUSE_STATES, ///< keyboard modifier and mouse button states.
MousePosition, ///< debug display mouse position
Particles, ///< debug display particles
Objects, ///< debug display total number of objects
NetIncoming, ///< debug display network incoming stats
NetOutgoing, ///< debug display network outgoing stats
NetStats, ///< debug display network performance stats.
NetFPSAverages, ///< debug display all players' average fps.
SelectedInfo, ///< debug display for the selected object in the UI
TerrainStats, ///< debug display for the terrain renderer
DisplayStringCount
};
DisplayString *m_displayStrings[DisplayStringCount];
DisplayString *m_benchmarkDisplayString;
W3DDebugDisplay *m_nativeDebugDisplay; ///< W3D specific debug display interface
}; // end W3DDisplay
#endif // end __W3DDISPLAY_H_

View file

@ -0,0 +1,124 @@
/*
** Command & Conquer Generals(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: W3DDisplayString.h ///////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: W3DDisplayString.h
//
// Created: Colin Day, July 2001
//
// Desc: Display string W3D implementation, display strings hold
// double byte characters and all the data we need to render
// those strings to the screen.
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DDISPLAYSTRING_H_
#define __W3DDISPLAYSTRING_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Common/GameMemory.h"
#include "GameClient/DisplayString.h"
#include "WW3D2/Render2DSentence.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////
class W3DDisplayStringManager;
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// W3DDisplayString -----------------------------------------------------------
/** */
//-----------------------------------------------------------------------------
class W3DDisplayString : public DisplayString
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DDisplayString, "W3DDisplayString" )
public:
friend W3DDisplayStringManager;
W3DDisplayString( void );
// ~W3DDisplayString( void ); // destructor defined by memory pool
void notifyTextChanged( void ); ///< called when text contents change
void draw( Int x, Int y, Color color, Color dropColor ); ///< render text
void draw( Int x, Int y, Color color, Color dropColor, Int xDrop, Int yDrop ); ///< render text with the drop shadow being at the offsets passed in
void getSize( Int *width, Int *height ); ///< get render size
Int getWidth( Int charPos = -1);
void setWordWrap( Int wordWrap ); ///< set the word wrap width
void setWordWrapCentered( Bool isCentered ); ///< If this is set to true, the text on a new line is centered
void setFont( GameFont *font ); ///< set a font for display
void setUseHotkey( Bool useHotkey, Color hotKeyColor = 0xffffffff );
void setClipRegion( IRegion2D *region ); ///< clip text in this region
protected:
void checkForChangedTextData( void ); /**< called when we need to update our
render sentence and update extents */
void usingResources( UnsignedInt frame ); /**< call this whenever display
resources are in use */
void computeExtents( void ); ///< compupte text width and height
Render2DSentenceClass m_textRenderer; ///< for drawing text
Render2DSentenceClass m_textRendererHotKey; ///< for drawing text
Bool m_textChanged; ///< when contents of string change this is TRUE
Bool m_fontChanged; ///< when font has chagned this is TRUE
UnicodeString m_hotkey; ///< holds the current hotkey marker.
Bool m_useHotKey;
ICoord2D m_hotKeyPos;
Color m_hotKeyColor;
ICoord2D m_textPos; ///< current text pos set in text renderer
Color m_currTextColor, ///< current color used in text renderer
m_currDropColor; ///< current color used for shadow in text
ICoord2D m_size; ///< (width,height) size of rendered text
IRegion2D m_clipRegion; ///< the clipping region for text
UnsignedInt m_lastResourceFrame; ///< last frame resources were used on
};
///////////////////////////////////////////////////////////////////////////////
// INLINING ///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
inline void W3DDisplayString::usingResources( UnsignedInt frame ) { m_lastResourceFrame = frame; }
// EXTERNALS //////////////////////////////////////////////////////////////////
#endif // __W3DDISPLAYSTRING_H_

View file

@ -0,0 +1,73 @@
/*
** Command & Conquer Generals(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: W3DDisplayStringManager.h ////////////////////////////////////////////////////////////////
// Created: Colin Day, July 2001
// Desc: Access for creating game managed display strings
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _W3DDISPLAYSTRINGMANAGER_H_
#define _W3DDISPLAYSTRINGMANAGER_H_
#include "GameClient/DisplayStringManager.h"
#include "W3DDevice/GameClient/W3DDisplayString.h"
//-------------------------------------------------------------------------------------------------
/** Access for creating game managed display strings */
//-------------------------------------------------------------------------------------------------
class W3DDisplayStringManager : public DisplayStringManager
{
public:
W3DDisplayStringManager( void );
virtual ~W3DDisplayStringManager( void );
// Initialize our numeral strings in postProcessLoad
virtual void postProcessLoad( void );
/// update method for all our display strings
virtual void update( void );
/// allocate a new display string
virtual DisplayString *newDisplayString( void );
/// free a display string
virtual void freeDisplayString( DisplayString *string );
// This is used to save us a few FPS and storage space. There's no reason to
// duplicate the DisplayString on every drawable when 1 copy will suffice.
virtual DisplayString *getGroupNumeralString( Int numeral );
virtual DisplayString *getFormationLetterString( void ) { return m_formationLetterDisplayString; };
protected:
DisplayString *m_groupNumeralStrings[10];
DisplayString *m_formationLetterDisplayString;
};
#endif // _W3DDISPLAYSTRINGMANAGER_H_

View file

@ -0,0 +1,87 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
// W3DDynamicLight.h
// Class to generate texture for terrain.
// Author: John Ahlquist, April 2001
#pragma once
#ifndef W3D_DYNAMIC_LIGHT_H
#define W3D_DYNAMIC_LIGHT_H
#include "WW3D2/Light.h"
#include "lib/baseType.h"
class HeightMapRenderObjClass;
/*************************************************************************
** W3DDynamicLight
***************************************************************************/
class W3DDynamicLight : public LightClass
{
friend class HeightMapRenderObjClass;
protected:
/// Values used by HeightMapRenderObjClass to update the height map.
Bool m_priorEnable;
Bool m_processMe;
Int m_prevMinX, m_prevMinY, m_prevMaxX, m_prevMaxY;
Int m_minX, m_minY, m_maxX, m_maxY;
Bool m_enabled;
Bool m_decayRange;
Bool m_decayColor;
UnsignedInt m_curDecayFrameCount;
UnsignedInt m_curIncreaseFrameCount;
UnsignedInt m_decayFrameCount;
UnsignedInt m_increaseFrameCount;
Real m_targetRange;
Vector3 m_targetAmbient;
Vector3 m_targetDiffuse;
public:
W3DDynamicLight();
~W3DDynamicLight(void);
public:
virtual void On_Frame_Update(void);
void setEnabled(Bool enabled) { m_enabled = enabled; m_decayRange = false; m_decayFrameCount = 0; m_decayColor = false; m_increaseFrameCount = 0;};
Bool isEnabled(void) {return m_enabled;};
/// 0 frameIncreaseTime means it starts out full size/intensity, 0 decay time means it lasts forever.
void setFrameFade(UnsignedInt frameIncreaseTime, UnsignedInt decayFrameTime);
void setDecayRange(void) {m_decayRange = true;};
void setDecayColor(void) {m_decayColor = true;};
// Cull returns true if the terrain vertex at x,y is outside of the light's influence.
Bool cull(Int x, Int y ) {return (x<m_minX||y<m_minY||x>m_maxX||y>m_maxY);}
};
#endif //TEXTURE_H

View file

@ -0,0 +1,94 @@
/*
** Command & Conquer Generals(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: W3DFileSystem.h ////////////////////////////////////////////////////////
//
// W3D implementation of a file factory. Uses GDI assets, so that
// W3D files and targa files are loaded using the GDI file interface.
//
// Author: John Ahlquist, Sept 2001
//
///////////////////////////////////////////////////////////////////////////////
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef __W3DFILESYSTEM_H_
#define __W3DFILESYSTEM_H_
#include "WWLIB/ffactory.h"
#include "Common/File.h"
//-------------------------------------------------------------------------------------------------
/** Game file access. At present this allows us to access test assets, assets from
* legacy GDI assets, and the current flat directory access for textures, models etc */
//-------------------------------------------------------------------------------------------------
class GameFileClass : public FileClass
{
public:
GameFileClass(char const *filename);
GameFileClass(void);
virtual ~GameFileClass(void);
virtual char const * File_Name(void) const;
virtual char const * Set_Name(char const *filename);
virtual bool Is_Available(int forced=false);
virtual bool Is_Open(void) const;
virtual int Open(char const *filename, int rights=READ);
virtual int Open(int rights=READ);
virtual int Read(void *buffer, int len);
virtual int Seek(int pos, int dir=SEEK_CUR);
virtual int Size(void);
virtual int Write(void const *buffer, int len);
virtual void Close(void);
protected:
File *m_theFile; /// < The file
Bool m_fileExists; ///< TRUE if the file exists
char m_filePath[_MAX_PATH]; ///< the file name *and* path (relative)
char m_filename[_MAX_PATH]; ///< The file name only
};
/*
** W3DFileSystem is a derived FileFactoryClass which
** uses GDI assets.
*/
class W3DFileSystem : public FileFactoryClass {
public:
W3DFileSystem(void);
~W3DFileSystem(void);
virtual FileClass * Get_File( char const *filename );
virtual void Return_File( FileClass *file );
};
extern W3DFileSystem *TheW3DFileSystem;
#endif

View file

@ -0,0 +1,72 @@
/*
** Command & Conquer Generals(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: W3DGUICallbacks.h ////////////////////////////////////////////////////////////////////////
// Created: Colin Day, August 2001
// Desc: Callbacks for GUI elements that are specifically tied to
// a W3D implementation
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DGUICALLBACKS_H_
#define __W3DGUICALLBACKS_H_
class GameWindow;
class WindowLayout;
class WinInstanceData;
// EXTERNALS //////////////////////////////////////////////////////////////////////////////////////
// Message of the day message window --------------------------------------------------------------
extern void W3DLeftHUDDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DCameoMovieDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DRightHUDDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DPowerDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DMainMenuDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DMainMenuFourDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DMetalBarMenuDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DCreditsMenuDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DClockDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DMainMenuMapBorder( GameWindow *window, WinInstanceData *instData );
extern void W3DMainMenuButtonDropShadowDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DMainMenuRandomTextDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DThinBorderDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DShellMenuSchemeDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DCommandBarGridDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DCommandBarGenExpDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DCommandBarHelpPopupDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DCommandBarBackgroundDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DCommandBarForegroundDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DCommandBarTopDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DNoDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DDrawMapPreview( GameWindow *window, WinInstanceData *instData );
void W3DMainMenuInit( WindowLayout *layout, void *userData );
#endif // __W3DGUICALLBACKS_H_

View file

@ -0,0 +1,94 @@
/*
** Command & Conquer Generals(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: W3DGadget.h //////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: W3DGadget.h
//
// Created: Colin Day, June 2001
//
// Desc: Implemtation details for various gadgets as they pertain to
// W3D will go here
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DGADGET_H_
#define __W3DGADGET_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GameClient/Gadget.h"
#include "W3DDevice/GameClient/W3DGameWindow.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
/// when drawing line art for gadgets, the borders are this size
#define WIN_DRAW_LINE_WIDTH (1.0f)
// INLINING ///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
extern void W3DGadgetPushButtonDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetPushButtonImageDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetCheckBoxDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetCheckBoxImageDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetRadioButtonDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetRadioButtonImageDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetTabControlDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetTabControlImageDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetListBoxDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetListBoxImageDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetComboBoxDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetComboBoxImageDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetHorizontalSliderDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetHorizontalSliderImageDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetVerticalSliderDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetVerticalSliderImageDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetProgressBarDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetProgressBarImageDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetStaticTextDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetStaticTextImageDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetTextEntryDraw( GameWindow *window, WinInstanceData *instData );
extern void W3DGadgetTextEntryImageDraw( GameWindow *window, WinInstanceData *instData );
#endif // __W3DGADGET_H_

View file

@ -0,0 +1,130 @@
/*
** Command & Conquer Generals(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: W3DGameClient.h ///////////////////////////////////////////////////
//
// W3D implementation of the game interface. The GameClient is
// responsible for maintaining our drawbles, handling our GUI, and creating
// the display ... basically the Client if this were a Client/Server game.
//
// Author: Colin Day, April 2001
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DGAMEINTERFACE_H_
#define __W3DGAMEINTERFACE_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GameClient/GameClient.h"
#include "W3DDevice/GameClient/W3DParticleSys.h"
#include "W3DDevice/GameClient/W3DDisplay.h"
#include "W3DDevice/GameClient/W3DInGameUI.h"
#include "W3DDevice/GameClient/W3DTerrainVisual.h"
#include "W3DDevice/GameClient/W3DGameWindowManager.h"
#include "W3DDevice/GameClient/W3DGameFont.h"
#include "W3DDevice/GameClient/W3DDisplayStringManager.h"
#include "VideoDevice/Bink/BinkVideoPlayer.h"
#include "Win32Device/GameClient/Win32DIKeyboard.h"
#include "Win32Device/GameClient/Win32DIMouse.h"
#include "Win32Device/GameClient/Win32Mouse.h"
#include "W3DDevice/GameClient/W3DMouse.h"
class ThingTemplate;
extern Win32Mouse *TheWin32Mouse;
///////////////////////////////////////////////////////////////////////////////
// PROTOTYPES /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// W3DGameClient -----------------------------------------------------------
/** The W3DGameClient singleton */
//-----------------------------------------------------------------------------
class W3DGameClient : public GameClient
{
public:
W3DGameClient();
virtual ~W3DGameClient();
/// given a type, create a drawable
virtual Drawable *friend_createDrawable( const ThingTemplate *thing, DrawableStatus statusBits = DRAWABLE_STATUS_NONE );
virtual void init( void ); ///< initialize resources
virtual void update( void ); ///< per frame update
virtual void reset( void ); ///< reset system
virtual void addScorch(const Coord3D *pos, Real radius, Scorches type);
virtual void createRayEffectByTemplate( const Coord3D *start, const Coord3D *end, const ThingTemplate* tmpl ); ///< create effect needing start and end location
//virtual Bool getBonePos(Drawable *draw, AsciiString boneName, Coord3D* pos, Matrix3D* transform) const;
virtual void setTimeOfDay( TimeOfDay tod ); ///< Tell all the drawables what time of day it is now
//---------------------------------------------------------------------------
virtual void setTeamColor( Int red, Int green, Int blue ); ///< @todo superhack for demo, remove!!!
virtual void adjustLOD( Int adj ); ///< @todo hack for evaluation, remove.
protected:
virtual Keyboard *createKeyboard( void ); ///< factory for the keyboard
virtual Mouse *createMouse( void ); ///< factory for the mouse
/// factory for creating TheDisplay
virtual Display *createGameDisplay( void ) { return NEW W3DDisplay; }
/// factory for creating TheInGameUI
virtual InGameUI *createInGameUI( void ) { return NEW W3DInGameUI; }
/// factory for creating the window manager
virtual GameWindowManager *createWindowManager( void ) { return NEW W3DGameWindowManager; }
/// factory for creating the font library
virtual FontLibrary *createFontLibrary( void ) { return NEW W3DFontLibrary; }
/// Manager for display strings
virtual DisplayStringManager *createDisplayStringManager( void ) { return NEW W3DDisplayStringManager; }
virtual VideoPlayerInterface *createVideoPlayer( void ) { return NEW BinkVideoPlayer; }
/// factory for creating the TerrainVisual
virtual TerrainVisual *createTerrainVisual( void ) { return NEW W3DTerrainVisual; }
virtual void setFrameRate(Real msecsPerFrame) { TheW3DFrameLengthInMsec = msecsPerFrame; }
}; // end class W3DGameClient
inline Keyboard *W3DGameClient::createKeyboard( void ) { return NEW DirectInputKeyboard; }
inline Mouse *W3DGameClient::createMouse( void )
{
//return new DirectInputMouse;
Win32Mouse * mouse = NEW W3DMouse;
TheWin32Mouse = mouse; ///< global cheat for the WndProc()
return mouse;
}
#endif // end __W3DGAMEINTERFACE_H_

View file

@ -0,0 +1,85 @@
/*
** Command & Conquer Generals(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: W3DGameFont.h ////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: W3DGameFont.h
//
// Created: Colin Day, June 2001
//
// Desc: W3D implementation for managing font definitions
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DGAMEFONT_H_
#define __W3DGAMEFONT_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GameClient/GameFont.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// W3DFontLibrary -------------------------------------------------------------
/** Our font library that uses W3D font implementations */
//-----------------------------------------------------------------------------
class W3DFontLibrary : public FontLibrary
{
public:
W3DFontLibrary( void ) { }
~W3DFontLibrary( void ) { }
protected:
/// load the font data pointer based on everything else we already have set
Bool loadFontData( GameFont *font );
/// release the font data pointer
void releaseFontData( GameFont *font );
}; // end W3DFontLibrary
// INLINING ///////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
#endif // __W3DGAMEFONT_H_

View file

@ -0,0 +1,105 @@
/*
** Command & Conquer Generals(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: W3DGameWindow.h //////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: W3DGameWindow.h
//
// Created: Colin Day, June 2001
//
// Desc: W3D implemenations for the game windowing system
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DGAMEWINDOW_H_
#define __W3DGAMEWINDOW_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GameClient/GameWindow.h"
#include "WW3D2/Render2DSentence.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// W3DGameWindow --------------------------------------------------------------
/** W3D implemenation for a game window */
// ----------------------------------------------------------------------------
class W3DGameWindow : public GameWindow
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(W3DGameWindow, "W3DGameWindow")
public:
W3DGameWindow( void );
// already defined by MPO.
//~W3DGameWindow( void );
/// draw borders for this window only, NO child windows or anything else
void winDrawBorder( void );
Int winSetPosition( Int x, Int y ); ///< set window position
Int winSetText( UnicodeString newText ); ///< set text string
void winSetFont( GameFont *font ); ///< set font for window
void getTextSize( Int *width, Int *height ); ///< get size of text
void setTextLoc( Int x, Int y ); ///< set text screen coord loc
void drawText( Color color ); ///< draw text in the text renderer
protected:
/// helper function to draw borders
void blitBorderRect( Int x, Int y, Int width, Int height );
Render2DSentenceClass m_textRenderer; ///< for drawing text
ICoord2D m_textPos; ///< current text pos set in text renderer
Color m_currTextColor; ///< current color used in text renderer
Bool m_needPolyDraw; ///< TRUE need to redo the text polys
Bool m_newTextPos; ///< TRUE when our window has moved and we need a new text pos
}; // end class W3DGameWindow
// INLINING ///////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
extern void W3DGameWinDefaultDraw( GameWindow *window,
WinInstanceData *instData );
#endif // __W3DGAMEWINDOW_H_

View file

@ -0,0 +1,112 @@
/*
** Command & Conquer Generals(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: W3DGameWindowManager.h ///////////////////////////////////////////////////////////////////
// Created: Colin Day, June 2001
// Desc: W3D implementation specific parts for the game window manager,
// which controls all access to the game windows for the in and
// of game GUI controls and windows
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DGAMEWINDOWMANAGER_H_
#define __W3DGAMEWINDOWMANAGER_H_
#include "GameClient/GameWindowManager.h"
#include "W3DDevice/GameClient/W3DGameWindow.h"
#include "W3DDevice/GameClient/W3DGadget.h"
//-------------------------------------------------------------------------------------------------
/** W3D implementation of the game window manager which controls all windows
* and user interface controls */
//-------------------------------------------------------------------------------------------------
class W3DGameWindowManager : public GameWindowManager
{
public:
W3DGameWindowManager( void );
virtual ~W3DGameWindowManager( void );
virtual void init( void ); ///< initialize the singlegon
virtual GameWindow *allocateNewWindow( void ); ///< allocate a new game window
virtual GameWinDrawFunc getDefaultDraw( void ); ///< return default draw func to use
virtual GameWinDrawFunc getPushButtonImageDrawFunc( void );
virtual GameWinDrawFunc getPushButtonDrawFunc( void );
virtual GameWinDrawFunc getCheckBoxImageDrawFunc( void );
virtual GameWinDrawFunc getCheckBoxDrawFunc( void );
virtual GameWinDrawFunc getRadioButtonImageDrawFunc( void );
virtual GameWinDrawFunc getRadioButtonDrawFunc( void );
virtual GameWinDrawFunc getTabControlImageDrawFunc( void );
virtual GameWinDrawFunc getTabControlDrawFunc( void );
virtual GameWinDrawFunc getListBoxImageDrawFunc( void );
virtual GameWinDrawFunc getListBoxDrawFunc( void );
virtual GameWinDrawFunc getComboBoxImageDrawFunc( void );
virtual GameWinDrawFunc getComboBoxDrawFunc( void );
virtual GameWinDrawFunc getHorizontalSliderImageDrawFunc( void );
virtual GameWinDrawFunc getHorizontalSliderDrawFunc( void );
virtual GameWinDrawFunc getVerticalSliderImageDrawFunc( void );
virtual GameWinDrawFunc getVerticalSliderDrawFunc( void );
virtual GameWinDrawFunc getProgressBarImageDrawFunc( void );
virtual GameWinDrawFunc getProgressBarDrawFunc( void );
virtual GameWinDrawFunc getStaticTextImageDrawFunc( void );
virtual GameWinDrawFunc getStaticTextDrawFunc( void );
virtual GameWinDrawFunc getTextEntryImageDrawFunc( void );
virtual GameWinDrawFunc getTextEntryDrawFunc( void );
protected:
}; // end class W3DGameWindowManager
// INLINE //////////////////////////////////////////////////////////////////////////////////////////
inline GameWindow *W3DGameWindowManager::allocateNewWindow( void ) { return newInstance(W3DGameWindow); }
inline GameWinDrawFunc W3DGameWindowManager::getDefaultDraw( void ) { return W3DGameWinDefaultDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getPushButtonImageDrawFunc( void ) { return W3DGadgetPushButtonImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getPushButtonDrawFunc( void ) { return W3DGadgetPushButtonDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getCheckBoxImageDrawFunc( void ) { return W3DGadgetCheckBoxImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getCheckBoxDrawFunc( void ) { return W3DGadgetCheckBoxDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getRadioButtonImageDrawFunc( void ) { return W3DGadgetRadioButtonImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getRadioButtonDrawFunc( void ) { return W3DGadgetRadioButtonDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getTabControlImageDrawFunc( void ) { return W3DGadgetTabControlImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getTabControlDrawFunc( void ) { return W3DGadgetTabControlDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getListBoxImageDrawFunc( void ) { return W3DGadgetListBoxImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getListBoxDrawFunc( void ) { return W3DGadgetListBoxDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getComboBoxImageDrawFunc( void ) { return W3DGadgetComboBoxImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getComboBoxDrawFunc( void ) { return W3DGadgetComboBoxDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getHorizontalSliderImageDrawFunc( void ) { return W3DGadgetHorizontalSliderImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getHorizontalSliderDrawFunc( void ) { return W3DGadgetHorizontalSliderDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getVerticalSliderImageDrawFunc( void ) { return W3DGadgetVerticalSliderImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getVerticalSliderDrawFunc( void ) { return W3DGadgetVerticalSliderDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getProgressBarImageDrawFunc( void ) { return W3DGadgetProgressBarImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getProgressBarDrawFunc( void ) { return W3DGadgetProgressBarDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getStaticTextImageDrawFunc( void ) { return W3DGadgetStaticTextImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getStaticTextDrawFunc( void ) { return W3DGadgetStaticTextDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getTextEntryImageDrawFunc( void ) { return W3DGadgetTextEntryImageDraw; }
inline GameWinDrawFunc W3DGameWindowManager::getTextEntryDrawFunc( void ) { return W3DGadgetTextEntryDraw; }
#endif // __W3DGAMEWINDOWMANAGER_H_

View file

@ -0,0 +1,304 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#include "always.h"
#include "hanim.h"
#include "proto.h"
#include "rendobj.h"
#include "LightEnvironment.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#pragma once
#ifndef __W3DGRANNY_H_
#define __W3DGRANNY_H_
#ifdef INCLUDE_GRANNY_IN_BUILD
#include "granny.h"
class GrannyRenderObjSystem; ///<forward reference
class GrannyPrototypeClass; ///<forward reference
class GrannyLoaderClass
{
public:
GrannyLoaderClass(void);
~GrannyLoaderClass(void);
PrototypeClass * Load_W3D(const char *filename);
granny_material_library *Get_Material_Library(void) {return MaterialLibrary;}
private:
granny_texture_library *TextureLibrary;
granny_material_library *MaterialLibrary;
};
extern GrannyLoaderClass _GrannyLoader;
/// Custom animation type specific to Granny.
class GrannyAnimClass : public HAnimClass
{
friend class GrannyRenderObjClass;
public:
enum
{
OK,
LOAD_ERROR
};
GrannyAnimClass(void);
~GrannyAnimClass(void);
const char * Get_Name(void) const { return Name;}
const char * Get_HName(void) const { return Name;}
int Get_Num_Frames(void) { return NumFrames;}
float Get_Frame_Rate() { return FrameRate;}
float Get_Total_Time() { return (float)NumFrames / FrameRate;}
void Get_Translation(Vector3& translation, int pividx,float frame) const {translation=Vector3(0,0,0);}
void Get_Orientation(Quaternion& orientation, int pividx,float frame) const {orientation=Quaternion(1);}
void Get_Transform(Matrix3D& mtx, int pividx, float frame) const {mtx=Matrix3D(1);}
Bool Get_Visibility(int pividx,float frame) { return 1;} //assume always visible
int Get_Num_Pivots(void) const { return 1;}
Bool Is_Node_Motion_Present(int pividx) {return true;}
int Load_W3D(const char *name);
private:
granny_animation *Animation;
granny_file *File;
int NumFrames;
float FrameRate;
char Name[2*W3D_NAME_LEN];
};
class GrannyAnimManagerClass
{
public:
GrannyAnimManagerClass(void);
~GrannyAnimManagerClass(void);
int Load_Anim(const char *name);
GrannyAnimClass * Get_Anim(const char * name);
GrannyAnimClass * Peek_Anim(const char * name);
Bool Add_Anim(GrannyAnimClass *new_anim);
void Free_All_Anims(void);
void Register_Missing( const char * name );
Bool Is_Missing( const char * name );
void Reset_Missing( void );
private:
int Load_Raw_Anim(const char *name);
HashTableClass * AnimPtrTable;
HashTableClass * MissingAnimTable;
friend class GrannyAnimManagerIterator;
};
/*
** An Iterator to get to all loaded HAnims in a HAnimManager
*/
class GrannyAnimManagerIterator : public HashTableIteratorClass {
public:
GrannyAnimManagerIterator( GrannyAnimManagerClass & manager ) : HashTableIteratorClass( *manager.AnimPtrTable ) {}
GrannyAnimClass * Get_Current_Anim( void );
};
/// Custom render object that draws tracks on the terrain.
/**
This render object handles drawing tracks left by objects moving on the terrain. It will only work
with rectangular planar surfaces and was tuned with an emphasis on water.
Since skies are only visible in reflections, this code will also
render clouds and sky bodies.
*/
class GrannyRenderObjClass : public RenderObjClass
{
friend class GrannyRenderObjSystem;
friend class W3DShadow;
public:
GrannyRenderObjClass(const GrannyPrototypeClass &proto);
~GrannyRenderObjClass(void);
/////////////////////////////////////////////////////////////////////////////
// Render Object Interface (W3D methods)
/////////////////////////////////////////////////////////////////////////////
virtual RenderObjClass * Clone(void) const;
virtual int Class_ID(void) const;
virtual void Render(RenderInfoClass & rinfo);
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const;
virtual void Set_Animation( HAnimClass * motion, float frame, int anim_mode = ANIM_MODE_MANUAL);
void Set_ObjectScale(float scale); ///<adjust internal scale factor applied to rendered asset.
Bool Cast_Ray(RayCollisionTestClass & raytest); ///<returns intersection of ray and picking box.
Int freeResources(void); ///<free W3D assets used for this track
const GrannyPrototypeClass & getPrototype(void) const { return m_prototype;}
protected:
granny_model_instance *m_modelInstance; ///<granny instance used to control model
granny_control *m_animationControl; ///<current animation
const GrannyPrototypeClass &m_prototype; ///<prototype that was used to create this model.
Int AnimMode; ///<type of animation playing
Real LastSyncTime; ///<time of last animation update
SphereClass m_boundingSphere; ///<bounding sphere of TerrainTracks
AABoxClass m_boundingBox; ///<bounding box of TerrainTracks
Int m_vertexCount; ///<number of vertices in model
GrannyRenderObjClass *m_nextSystem; ///<next track system
GrannyRenderObjClass *m_prevSystem; ///<previous track system
};
#define GRANNY_MAX_MESHES_PER_MODEL 4
/** Prototype or definition of a Granny model. Contains all info need to instance a model of this type.*/
class GrannyPrototypeClass : public PrototypeClass
{
friend class GrannyRenderObjClass;
friend class GrannyRenderObjSystem;
public:
GrannyPrototypeClass(granny_file *file)
{ m_file = file; assert(m_file); m_vertexCount=0;
m_name[0]='\0';
m_meshCount=0;
m_vertexMaterial=NEW_REF(VertexMaterialClass,());
m_vertexMaterial->Set_Shininess(0.0);
m_vertexMaterial->Set_Specular(0,0,0);
m_vertexMaterial->Set_Lighting(true);
}
struct grannyMeshDesc
{
const UnsignedInt *index; ///< pointer to pool of face indices
Int indexCount; ///< number of face indices in this mesh
const granny_pnt332_vertex *vertex; ///< pointer to pool of mesh vertices
Int vertexCount; ///< number of vertices in this mesh.
};
virtual ~GrannyPrototypeClass(void) { if (m_vertexMaterial) REF_PTR_RELEASE (m_vertexMaterial); if (m_file) GrannyFreeFile(m_file); }
virtual const char * Get_Name(void) const { return m_name; }
virtual int Get_Class_ID(void) const { return RenderObjClass::CLASSID_UNKNOWN; }
virtual RenderObjClass * Create(void) { return NEW_REF( GrannyRenderObjClass, (*this) ); }
void Set_Name(char *name) {strcpy(m_name,name);}
void setBoundingBox(AABoxClass & box) {m_boundingBox=box;}
void setBoundingSphere(SphereClass & sphere) {m_boundingSphere=sphere;}
void setVertexCount(Int vertexCount) {m_vertexCount=vertexCount;}
void setIndexCount(Int indexCount) {m_indexCount=indexCount;}
void setMeshCount(Int meshCount) {m_meshCount=meshCount;}
void setMeshData(grannyMeshDesc &meshdesc, Int index) {m_meshData[index]=meshdesc;}
const UnsignedInt *getMeshIndexList(int index) const { if (index < m_meshCount) return m_meshData[0].index; else return NULL;}
const granny_pnt332_vertex *getMeshVertexList(int index) const { if (index < m_meshCount) return m_meshData[0].vertex; else return NULL;}
const Int getIndexCount(void) const {return m_indexCount;} //return total number of indices in model
private:
granny_file *m_file; ///<pointer to Granny allocated model data.
char m_name[32]; ///<prototype name
AABoxClass m_boundingBox; ///<bounding volume used for picking and frustum culling.
SphereClass m_boundingSphere; ///<bounding volume used for picking and frustum culling.
VertexMaterialClass *m_vertexMaterial; ///<vertex lighting material used for this model.
Int m_vertexCount; ///< total/maximum number of vertices that will be needed to draw complete model.
Int m_indexCount; ///< total/maximum number of indices that will be needed to draw the complete model.
Int m_meshCount; ///< total number of meshes in model - meshes can have different materials
grannyMeshDesc m_meshData[GRANNY_MAX_MESHES_PER_MODEL]; ///<descriptions of all meshes in this model
};
#define MAX_GRANNY_RENDERSTATES 32 //maximum number of render states available to granny models per frame.
#define MAX_VISIBLE_GRANNY_MODELS 200 //maximum number of granny models to render per frame
class GrannyRenderObjSystem
{
public:
void AddRenderObject(RenderInfoClass & rinfo, GrannyRenderObjClass *robj); ///<buffers model for rendering at frame flush.
void Flush(void); ///<renders all objects queued up for this frame.
void queueUpdate(void) {m_doUpdate=TRUE;} ///<tell Granny to update all animations - do this only once per frame.
protected:
struct RenderStateModelList{
GrannyRenderObjClass *list; ///<start of Granny models using this renderstate
};
RenderStateModelList m_renderStateModelList[MAX_GRANNY_RENDERSTATES]; ///<list of render states used during this frame.
LightEnvironmentClass m_renderLocalLightEnv[MAX_VISIBLE_GRANNY_MODELS]; ///<pool of lighting settings available to granny
Int m_renderStateCount; ///<number of different render states requested in current frame.
Int m_renderObjectCount; ///<number of granny models to render this frame.
Bool m_doUpdate; ///<flag to indicate if animation time needs to be updated this frame.
};
extern GrannyRenderObjSystem *TheGrannyRenderObjSystem; ///< singleton for drawing all Granny models.
#if 0 ///@todo: Will have to implement an optimized granny rendering system
/// System for loading, drawing, and updating Granny models
/**
This system keeps track of all the active granny objects and renders any models
that were submitted in current frame.
*/
class GrannyRenderObjClassSystem
{
friend class GrannyRenderObjClass;
public:
GrannyRenderObjClassSystem( void );
~GrannyRenderObjClassSystem( void );
void ReleaseResources(void); ///< Release all dx8 resources so the device can be reset.
void ReAcquireResources(void); ///< Reacquire all resources after device reset.
void flush (void); ///<draw all models that were requested for rendering.
void update(void); ///<update the state of all models.
void init(); ///< pre-allocate resources and initialize granny.
void shutdown( void ); ///< release all pre-allocated resources and kill Granny.
RenderObjClass *createRenderObj(const char * name); ///< create an instance of the model
protected:
DX8VertexBufferClass *m_vertexBuffer; ///<vertex buffer used to draw all tracks
DX8IndexBufferClass *m_indexBuffer; ///<indices defining triangles in maximum length track
VertexMaterialClass *m_vertexMaterialClass; ///< vertex lighting material
ShaderClass m_shaderClass; ///<shader or rendering state for heightmap
GrannyRenderObjClass *m_usedModules; ///<active objects being rendered in the scene
GrannyRenderObjClass *m_freeModules; //<unused modules that are free to use again
}; // end class GrannyRenderObjClassSystem
extern GrannyRenderObjClassSystem *TheGrannyRenderObjClassSystem; ///< singleton for track drawing system.
#endif //end of GrannyRenderObjClassSystem
#endif //INCLUDE_GRANNY_IN_BUILD
#endif // end __W3DGRANNY_H_

View file

@ -0,0 +1,89 @@
/*
** Command & Conquer Generals(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: W3DInGameUI.h ////////////////////////////////////////////////////////
//
// W3D implementation of the in game user interface, the in game ui is
// responsible for
//
// Author: Colin Day, April 2001
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DINGAMEUI_H_
#define __W3DINGAMEUI_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GameClient/InGameUI.h"
#include "GameClient/View.h"
#include "W3DDevice/GameClient/W3DView.h"
#include "WW3D2/Render2D.h"
#include "WW3D2/RendObj.h"
#include "WW3D2/Line3D.h"
class HAnimClass;
// W3DInGameUI ----------------------------------------------------------------
/** Implementation for the W3D game user interface. This singleton is
* responsible for all user interaction and feedback with as part of the
* user interface */
//-----------------------------------------------------------------------------
class W3DInGameUI : public InGameUI
{
public:
W3DInGameUI();
virtual ~W3DInGameUI();
// Inherited from subsystem interface -----------------------------------------------------------
virtual void init( void ); ///< Initialize the in-game user interface
virtual void update( void ); //< Update the UI by calling preDraw(), draw(), and postDraw()
virtual void reset( void ); ///< Reset
//-----------------------------------------------------------------------------------------------
virtual void draw( void ); ///< Render the in-game user interface
protected:
/// factory for views
virtual View *createView( void ) { return NEW W3DView; }
virtual void drawSelectionRegion( void ); ///< draw the selection region on screen
virtual void drawMoveHints( View *view ); ///< draw move hint visual feedback
virtual void drawAttackHints( View *view ); ///< draw attack hint visual feedback
virtual void drawPlaceAngle( View *view ); ///< draw place building angle if needed
RenderObjClass *m_moveHintRenderObj[ MAX_MOVE_HINTS ];
HAnimClass *m_moveHintAnim[ MAX_MOVE_HINTS ];
RenderObjClass *m_buildingPlacementAnchor;
RenderObjClass *m_buildingPlacementArrow;
}; // end class W3DInGameUI
#endif // end __W3DINGAMEUI_H_

View file

@ -0,0 +1,119 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DMirror_H_
#define __W3DMirror_H_
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#include "Common/GameType.h"
/// Custom render object that draws mirrors, water, and skies.
/**
This render object handles drawing reflected W3D scenes. It will only work
with rectangular planar surfaces and was tuned with an emphasis on water.
Since skies are only visible in reflections, this code will also
render clouds and sky bodies.
*/
class MirrorRenderObjClass : public RenderObjClass
{
public:
MirrorRenderObjClass(void);
~MirrorRenderObjClass(void);
/////////////////////////////////////////////////////////////////////////////
// Render Object Interface (W3D methods)
/////////////////////////////////////////////////////////////////////////////
virtual RenderObjClass * Clone(void) const;
virtual int Class_ID(void) const;
virtual void Render(RenderInfoClass & rinfo);
/// @todo: Add methods for collision detection with mirror surface
// virtual Bool Cast_Ray(RayCollisionTestClass & raytest);
// virtual Bool Cast_AABox(AABoxCollisionTestClass & boxtest);
// virtual Bool Cast_OBBox(OBBoxCollisionTestClass & boxtest);
// virtual Bool Intersect_AABox(AABoxIntersectionTestClass & boxtest);
// virtual Bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest);
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const;
///allocate W3D resources needed to render mirror
Int init(Real waterLevel, Real dx, Real dy, SceneClass *parentScene);
static void setTimeOfDay(TimeOfDay tod) {m_tod=tod;} ///<change sky/water for time of day
void toggleCloudLayer(Bool state) { m_useCloudLayer=state;} ///<enables/disables the cloud layer
protected:
DX8IndexBufferClass *m_indexBuffer; ///<indices defining quad
SceneClass *m_parentScene; ///<scene to be reflected
ShaderClass m_shaderClass; ///<shader or rendering state for heightmap
VertexMaterialClass *m_vertexMaterialClass; ///<vertex lighting material
TextureClass *m_alphaClippingTexture; ///<used for faked clipping using alpha
Real m_dx; ///<x extent of mirror surface (offset from local center)
Real m_dy; ///<y extent of mirror surface (offset from local center)
Vector3 m_planeNormal; ///<mirror plane normal
Real m_planeDistance; ///<mirror plane distance
Real m_level; ///<level of mirror (hack for water)
Real m_uOffset; ///<current texture offset on u axis
Real m_vOffset; ///<current texture offset on v axis
Real m_uScrollPerMs; ///<texels per/ms scroll rate in u direction
Real m_vScrollPerMs; ///<texels per/ms scroll rate in v direction
Int m_LastUpdateTime; ///<time of last cloud update
Bool m_useCloudLayer; ///<flag if clouds are on/off
static TimeOfDay m_tod; ///<time of day setting for reflected cloud layer
struct skySetting
{
TextureClass *skyTexture;
TextureClass *waterTexture;
Int waterRepeatCount;
Int skyRepeatCount;
DWORD vertex00Diffuse;
DWORD vertex10Diffuse;
DWORD vertex11Diffuse;
DWORD vertex01Diffuse;
DWORD waterDiffuse;
Real uScrollPerMs;
Real vScrollPerMs;
};
skySetting m_skySettings[TIME_OF_DAY_COUNT]; ///< settings for each time of day
void renderSky(void); ///<draw the sky layer (clouds, stars, etc.)
void renderSkyBody(Matrix3D *mat); ///<draw the sky body (sun, moon, etc.)
void renderWater(void);
void renderWaterMesh(void);
};
#endif // end __W3DMirror_H_

View file

@ -0,0 +1,114 @@
/*
** Command & Conquer Generals(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: W3DMouse.h /////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: Win32Mouse.h
//
// Created: Mark Wilczynski, Jan 2002
//
// Desc: Interface for the mouse using W3D methods to display cursor.
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DMOUSE_H_
#define __W3DMOUSE_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Win32Device/GameClient/Win32Mouse.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////
class CameraClass;
class SurfaceClass;
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// W3DMouse -----------------------------------------------------------------
/** Mouse interface for when using only the Win32 messages and W3D for cursor */
//-----------------------------------------------------------------------------
class W3DMouse : public Win32Mouse
{
public:
W3DMouse( void );
virtual ~W3DMouse( void );
virtual void init( void ); ///< init mouse, extend this functionality, do not replace
virtual void reset( void ); ///< reset the system
virtual void setCursor( MouseCursor cursor ); ///< set mouse cursor
virtual void draw( void ); ///< draw the cursor or refresh the image
virtual void setRedrawMode(RedrawMode mode); ///<set cursor drawing method.
private:
MouseCursor m_currentD3DCursor; ///< keep track of last cursor image sent to D3D.
SurfaceClass *m_currentD3DSurface[MAX_2D_CURSOR_ANIM_FRAMES];
ICoord2D m_currentHotSpot;
Int m_currentFrames; ///< total number of frames in current 2D cursor animation.
Real m_currentAnimFrame;///< current frame of 2D cursor animation.
Int m_currentD3DFrame; ///< current frame actually sent to the hardware.
Int m_lastAnimTime; ///< ms at last animation update.
Real m_currentFMS; ///< frames per ms.
Bool m_drawing; ///< flag to indicate mouse cursor is currently in the act of drawing.
///@todo: remove the textures if we only need surfaces
void initD3DAssets(void); ///< load textures for mouse cursors, etc.
void freeD3DAssets(void); ///< unload textures used by mouse cursors.
Bool loadD3DCursorTextures(MouseCursor cursor); ///<load the textures/animation for given cursor.
Bool releaseD3DCursorTextures(MouseCursor cursor); ///<release loaded textures for cursor.
// W3D animated model cursor
CameraClass *m_camera; ///< our camera
MouseCursor m_currentW3DCursor;
void initW3DAssets(void); ///< load models for mouse cursors, etc.
void freeW3DAssets(void); ///< unload models used by mouse cursors.
MouseCursor m_currentPolygonCursor;
void initPolygonAssets(void); ///< load images for cursor polygon.
void freePolygonAssets(void); ///< free images for cursor polygon.
void setCursorDirection(MouseCursor cursor); ///figure out direction for oriented 2D cursors.
}; // end Win32Mouse
// INLINING ///////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
#endif // __W3DMOUSE_H_

View file

@ -0,0 +1,67 @@
/*
** Command & Conquer Generals(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: W3DParticleSys.h /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DParticleSys_H_
#define __W3DParticleSys_H_
#include "GameClient/ParticleSys.h"
#include "WW3D2/PointGr.h"
#include "WW3D2/streak.h"
#include "WW3D2/RInfo.h"
#include "WWLib/BitType.h"
//=============================================================================
/** W3D implementation of the game display which is responsible for creating
* all interaction with the screen and updating the display
*/
class W3DParticleSystemManager : public ParticleSystemManager
{
public:
W3DParticleSystemManager();
~W3DParticleSystemManager();
virtual void doParticles(RenderInfoClass &rinfo);
virtual void queueParticleRender();
///< returns the number of particles shown on screen per frame
virtual Int getOnScreenParticleCount() { return m_onScreenParticleCount; }
private:
enum { MAX_POINTS_PER_GROUP = 512 };
PointGroupClass *m_pointGroup; ///< the point group that contains all of the particles
StreakLineClass *m_streakLine; ///< the streak class that contains all of the streaks
ShareBufferClass<Vector3> *m_posBuffer; ///< array of particle positions
ShareBufferClass<Vector4> *m_RGBABuffer; ///< array of particle color and alpha
ShareBufferClass<float> *m_sizeBuffer; ///< array of particle sizes
ShareBufferClass<uint8> *m_angleBuffer; ///< array of particle orientations
Bool m_readyToRender; ///< if true, it is OK to render
};
#endif // end __W3DParticleSys_H_

View file

@ -0,0 +1,70 @@
/*
** Command & Conquer Generals(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: W3DPoly.h /////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: W3DPoly.h
//
// Created: Mark Wilczynski, Jan 2002
//
// Desc: Generic Polgon operations.
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DPOLY_H_
#define __W3DPOLY_H_
#include "vector3.h"
#include "plane.h"
#include "simplevec.h"
//-------------------------------------------------------------------------------------------------
/**VisPolyClass - This class is used to clip a polygon to a plane. Useful for manually
* clipping polys to the frustum or other geometry. Based on internal WW3D2 code. */
//-------------------------------------------------------------------------------------------------
class ClipPolyClass
{
public:
void Reset(void);
void Add_Vertex(const Vector3 & point);
void Clip(const PlaneClass & plane,ClipPolyClass & dest) const;
SimpleDynVecClass<Vector3> Verts;
};
#endif //__W3DPOLY_H_

View file

@ -0,0 +1,92 @@
/*
** Command & Conquer Generals(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: W3DProjectedShadow.h ///////////////////////////////////////////////////////////
//
// Real time shadow projection through textures.
//
// Author: Mark Wilczynski, February 2002
//
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3D_PROJECTED_SHADOW_H_
#define __W3D_PROJECTED_SHADOW_H_
#include "GameClient/Shadow.h"
class W3DShadowTexture; //forward reference
class W3DShadowTextureManager; //forward reference
class W3DProjectedShadow; //forward reference
class Drawable; //forward reference
class W3DProjectedShadowManager : public ProjectedShadowManager
{
/* enum ShadowTextureType {
STT_STATIC = 0x0001,
STT_DYNAMIC = 0x0002,
STT_SHARED
};
*/
public:
W3DProjectedShadowManager( void );
~W3DProjectedShadowManager( void );
Bool init(void); ///<allocate one-time shadow assets for length of entire game.
void reset(void); ///<free all existing shadows - ready for next map.
void shutdown(void); ///<free all assets prior to shutdown of entire game.
Int renderShadows(RenderInfoClass & rinfo); ///<iterate over each object and render its shadow onto affected objects.
void ReleaseResources(void); ///<release device dependent D3D resources.
Bool ReAcquireResources(void); ///<allocate device dependent D3D resources.
void invalidateCachedLightPositions(void); ///<forces shadows to update regardless of last lightposition
virtual Shadow *addDecal(RenderObjClass *robj, Shadow::ShadowTypeInfo *shadowInfo); ///<add a non-shadow decal
virtual Shadow *addDecal(Shadow::ShadowTypeInfo *shadowInfo); ///<add a non-shadow decal which does not follow an object.
W3DProjectedShadow *addShadow( RenderObjClass *robj, Shadow::ShadowTypeInfo *shadowInfo, Drawable *draw); ///<add a new shadow with texture of given name or that of robj.
void removeShadow (W3DProjectedShadow *shadow);
void removeAllShadows(void); ///< Remove all shadows.
TextureClass *getRenderTarget(void) { return m_dynamicRenderTarget;}
SpecialRenderInfoClass *getRenderContext(void) { return m_shadowContext;}
void updateRenderTargetTextures(void); ///<render into any textures that need updating.
void queueDecal(W3DProjectedShadow *shadow); ///<add shadow decal to render list - decal conforms to terrain.
void queueSimpleDecal(W3DProjectedShadow *shadow); ///< add shadow decal to render list - decal floats on terrain.
void flushDecals(W3DShadowTexture *texture, ShadowType type); ///<empty queue by rendering all decals with given texture
private:
W3DProjectedShadow *m_shadowList;
W3DProjectedShadow *m_decalList;
TextureClass *m_dynamicRenderTarget; ///<offscreen video memory texture used to render all shadow textures.
Bool m_renderTargetHasAlpha; ///<does render target have destination alpha support?
CameraClass *m_shadowCamera; ///<camera used to render all shadow textures - configured by projector
LightEnvironmentClass m_shadowLightEnv;
SpecialRenderInfoClass *m_shadowContext;
W3DShadowTextureManager *m_W3DShadowTextureManager;
Int m_numDecalShadows; ///< number of decal shadows in the system.
Int m_numProjectionShadows; ///< number of projected shadows in the system.
Int renderProjectedTerrainShadow(W3DProjectedShadow *shadow, AABoxClass &box); ///<render shadow on map terrain.
};
extern W3DProjectedShadowManager *TheW3DProjectedShadowManager;
#endif //__W3D_PROJECTED_SHADOW_H_

View file

@ -0,0 +1,281 @@
/*
** Command & Conquer Generals(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: W3DRoadBuffer.h //////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: W3DRoadBuffer.h
//
// Created: John Ahlquist, May 2001
//
// Desc: Draw buffer to handle all the roads in a scene.
//
//-----------------------------------------------------------------------------
#pragma once
#ifndef __W3DROAD_BUFFER_H_
#define __W3DROAD_BUFFER_H_
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
//#include "common/GameFileSystem.h"
#include "Common/FileSystem.h" // for LOAD_TEST_ASSETS
#include "Lib/BaseType.h"
#include "common/GameType.h"
#include "Common/AsciiString.h"
//-----------------------------------------------------------------------------
// Forward References
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Type Defines
//-----------------------------------------------------------------------------
enum {bottomLeft=0, bottomRight=1, topLeft=2, topRight=3, NUM_CORNERS=4};
#define MAX_LINKS 6
#define DEFAULT_ROAD_SCALE (8.0f)
#define MIN_ROAD_SEGMENT (0.25f)
struct TRoadPt
{
Vector2 loc;
Vector2 top;
Vector2 bottom;
Int count;
Bool last;
Bool multi;
Bool isAngled;
Bool isJoin;
};
struct TRoadSegInfo
{
Vector2 loc;
Vector2 roadNormal;
Vector2 roadVector;
Vector2 corners[NUM_CORNERS];
Real uOffset;
Real vOffset;
Real scale;
};
// The individual data for a road segment.
enum {MAX_SEG_VERTEX=500, MAX_SEG_INDEX=2000};
enum TCorner
{
SEGMENT,
CURVE,
TEE,
FOUR_WAY,
THREE_WAY_Y,
THREE_WAY_H,
THREE_WAY_H_FLIP,
ALPHA_JOIN,
NUM_JOINS
};
class RoadSegment
{
public:
TRoadPt m_pt1; ///< Drawing location pt1 to pt2.
TRoadPt m_pt2; ///< Drawing location to.
Real m_curveRadius; ///< Radius if it is a curve.
TCorner m_type; ///< Segment, or curve, or intersection.
Real m_scale; ///< Scale.
Real m_widthInTexture; ///< Width of the road in the texture.
Int m_uniqueID; ///< Road type.
protected:
Int m_numVertex;
VertexFormatXYZDUV1* m_vb;
Int m_numIndex;
UnsignedShort* m_ib;
TRoadSegInfo m_info;
SphereClass m_bounds;
public:
RoadSegment(void);
~RoadSegment(void);
public:
void SetVertexBuffer(VertexFormatXYZDUV1 *vb, Int numVertex);
void SetIndexBuffer(UnsignedShort *ib, Int numIndex);
void SetRoadSegInfo(TRoadSegInfo *pInfo) {m_info = *pInfo;};
void GetRoadSegInfo(TRoadSegInfo *pInfo) {*pInfo = m_info;};
const SphereClass &getBounds(void) {return m_bounds;};
Int GetNumVertex(void) {return m_numVertex;};
Int GetNumIndex(void) {return m_numIndex;};
Int GetVertices(VertexFormatXYZDUV1 *destination_vb, Int numToCopy);
Int GetIndices(UnsignedShort *destination_ib, Int numToCopy, Int offset);
void updateSegLighting(void);
} ;
class RoadType {
public:
RoadType(void);
~RoadType(void);
protected:
TextureClass *m_roadTexture; ///<Roads texture
DX8VertexBufferClass *m_vertexRoad; ///<Road vertex buffer.
DX8IndexBufferClass *m_indexRoad; ///<indices defining a triangles for the road drawing.
Int m_numRoadVertices; ///<Number of vertices used in m_vertexRoad.
Int m_numRoadIndices; ///<Number of indices used in b_indexRoad;
Int m_uniqueID; ///< ID of the road type in INI.
Bool m_isAutoLoaded;
Int m_stackingOrder; ///< Order in the drawing. 0 drawn first, then 1 and so on.
#ifdef LOAD_TEST_ASSETS
AsciiString m_texturePath;
#endif
public:
void loadTexture(AsciiString path, Int id);
void applyTexture(void);
Int getStacking(void) {return m_stackingOrder;}
void setStacking(Int order) {m_stackingOrder = order;}
Int getUniqueID(void) {return m_uniqueID;};
DX8VertexBufferClass *getVB(void) {return m_vertexRoad;};
DX8IndexBufferClass *getIB(void) {return m_indexRoad;}
Int getNumVertices(void) {return m_numRoadVertices;}
void setNumIndices(Int num) {m_numRoadIndices=num;}
void setNumVertices(Int num) {m_numRoadVertices=num;}
Int getNumIndices(void) {return m_numRoadIndices;}
#ifdef LOAD_TEST_ASSETS
void setAutoLoaded(void) {m_isAutoLoaded = true;};
Bool isAutoLoaded(void) {return m_isAutoLoaded;};
AsciiString getPath(void) {return(m_texturePath);};
void loadTestTexture(void);
#endif
} ;
class WorldHeightMap;
//
// W3DRoadBuffer: Draw buffer for the roads.
//
//
class W3DRoadBuffer
{
friend class HeightMapRenderObjClass;
public:
W3DRoadBuffer(void);
~W3DRoadBuffer(void);
/// Loads the roads from the map objects list.
void loadRoads();
/// Empties the road buffer.
void clearAllRoads(void);
/// Draws the roads. Uses terrain bounds for culling.
void drawRoads(CameraClass * camera, TextureClass *cloudTexture, TextureClass *noiseTexture, Bool wireframe,
Int minX, Int maxX, Int minY, Int maxY, RefRenderObjListIterator *pDynamicLightsIterator);
/// Sets the map pointer.
void setMap(WorldHeightMap *pMap);
/// Updates the diffuse lighting in the buffers.
void updateLighting(void);
protected:
RoadType *m_roadTypes; ///<Roads texture
RoadSegment *m_roads; ///< The road buffer. All roads are stored here.
Int m_numRoads; ///< Number of roads used in m_roads.
Bool m_initialized; ///< True if the subsystem initialized.
WorldHeightMap *m_map; ///< Pointer to the height map data.
RefRenderObjListIterator *m_lightsIterator; ///< Lighting iterator.
Int m_minX, m_maxX, m_minY, m_maxY; ///< Bounds on the terrain to be rendered.
Int m_curUniqueID; ///< Road type we are rendering at this pass.
Int m_curRoadType;
#ifdef LOAD_TEST_ASSETS
Int m_maxUID; ///< Maximum UID.
Int m_curOpenRoad; ///< First road type not used.
#endif
Int m_maxRoadSegments; ///< Size of m_roads.
Int m_maxRoadVertex; ///< Size of m_vertexRoad.
Int m_maxRoadIndex; ///< Size of m_indexRoad.
Int m_maxRoadTypes; ///< Size of m_roadTypes.
Int m_curNumRoadVertices; ///<Number of vertices used in current road type.
Int m_curNumRoadIndices; ///<Number of indices used in current road type;
void addMapObjects(void);
void addMapObject(RoadSegment *pRoad, Bool updateTheCounts);
void adjustStacking(Int topUniqueID, Int bottomUniqueID);
Int findCrossTypeJoinVector(Vector2 loc, Vector2 *joinVector, Int uniqueID);
void flipTheRoad(RoadSegment *pRoad) {TRoadPt tmp=pRoad->m_pt1; pRoad->m_pt1 = pRoad->m_pt2; pRoad->m_pt2 = tmp;}; ///< Flips the loc1 and loc2 info.
void insertCurveSegmentAt(Int ndx1, Int ndx2);
void insertCrossTypeJoins(void);
void insertJoinAt(Int ndx);
void miter(Int ndx1, Int ndx2);
void moveRoadSegTo(Int fromNdx, Int toNdx);
void checkLinkAfter(Int ndx);
void checkLinkBefore(Int ndx);
void updateCounts(RoadSegment *pRoad);
void updateCountsAndFlags(void);
void insertCurveSegments(void);
void insertTeeIntersections(void);
void insertTee(Vector2 loc, Int index1, Real scale);
Bool insertY(Vector2 loc, Int index1, Real scale);
void insert4Way(Vector2 loc, Int index1, Real scale);
void offset4Way(TRoadPt *pc1, TRoadPt *pc2, TRoadPt *pc3, TRoadPt *pr3, TRoadPt *pc4, Vector2 loc, Vector2 alignVector, Real widthInTexture);
void offset3Way(TRoadPt *pc1, TRoadPt *pc2, TRoadPt *pc3, Vector2 loc, Vector2 upVector, Vector2 teeVector, Real widthInTexture);
void offsetY(TRoadPt *pc1, TRoadPt *pc2, TRoadPt *pc3, Vector2 loc, Vector2 upVector, Real widthInTexture);
void offsetH(TRoadPt *pc1, TRoadPt *pc2, TRoadPt *pc3, Vector2 loc, Vector2 upVector, Vector2 teeVector, Bool flip, Bool mirror, Real widthInTexture);
void preloadRoadsInVertexAndIndexBuffers(void); ///< Fills the index and vertex buffers for drawing.
void preloadRoadSegment(RoadSegment *pRoad); ///< Fills the index and vertex buffers for drawing 1 segment.
void loadCurve(RoadSegment *pRoad, Vector2 loc1, Vector2 loc2, Real scale); ///< Fills the index and vertex buffers for drawing 1 fade.
void loadTee(RoadSegment *pRoad, Vector2 loc1, Vector2 loc2, Bool is4way, Real scale); ///< Fills the index and vertex buffers for drawing 1 tee intersection.
void loadY(RoadSegment *pRoad, Vector2 loc1, Vector2 loc2, Real scale); ///< Fills the index and vertex buffers for drawing 1 Y intersection.
void loadAlphaJoin(RoadSegment *pRoad, Vector2 loc1, Vector2 loc2, Real scale); ///< Fills the index and vertex buffers for drawing 1 alpha blend cap.
void loadH(RoadSegment *pRoad, Vector2 loc1, Vector2 loc2, Bool flip, Real scale); ///< Fills the index and vertex buffers for drawing 1 h tee intersection.
void loadFloatSection(RoadSegment *pRoad, Vector2 loc,
Vector2 roadVector, Real height, Real left, Real right, Real uOffset, Real vOffset, Real scale);
void loadFloat4PtSection(RoadSegment *pRoad, Vector2 loc,
Vector2 roadNormal, Vector2 roadVector,
Vector2 *cornersP,
Real uOffset, Real vOffset, Real uScale, Real vScale);
void loadLit4PtSection(RoadSegment *pRoad, UnsignedShort *ib, VertexFormatXYZDUV1 *vb, RefRenderObjListIterator *pDynamicLightsIterator);
void loadRoadsInVertexAndIndexBuffers(void); ///< Fills the index and vertex buffers for drawing.
void loadLitRoadsInVertexAndIndexBuffers(RefRenderObjListIterator *pDynamicLightsIterator); ///< Fills the index and vertex buffers for drawing.
void loadRoadSegment(UnsignedShort *ib, VertexFormatXYZDUV1 *vb, RoadSegment *pRoad); ///< Fills the index and vertex buffers for drawing 1 segment.
void allocateRoadBuffers(void); ///< Allocates the buffers.
void freeRoadBuffers(void); ///< Frees the index and vertex buffers.
void rotateAbout(Vector2 *ptP, Vector2 center, Real angle);
};
#endif // end __W3DROAD_BUFFER_H_

View file

@ -0,0 +1,191 @@
/*
** Command & Conquer Generals(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: W3DScene.h ///////////////////////////////////////////////////////////
//
// Scene manger for display using W3DDispaly. A scene manager can customize
// the rendering process, culling, material passes ...
//
// Author: Colin Day, April 2001
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DSCENE_H_
#define __W3DSCENE_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "WW3D2/Scene.h"
#include "WW3D2/RInfo.h"
#include "WW3D2/Coltest.h"
#include "WW3D2/lightenvironment.h"
///////////////////////////////////////////////////////////////////////////////
// PROTOTYPES /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class W3DDynamicLight;
class LightClass;
class Drawable;
enum CustomScenePassModes;
class MaterialPassClass;
class W3DShroudMaterialPassClass;
class W3DMaskMaterialPassClass;
//-----------------------------------------------------------------------------
// RTS3DScene
//-----------------------------------------------------------------------------
/** Scene management for 3D RTS game */
//-----------------------------------------------------------------------------
class RTS3DScene : public SimpleSceneClass, public SubsystemInterface
{
public:
RTS3DScene(); ///< RTSScene constructor
~RTS3DScene(); ///< RTSScene desctructor
/// ray picking against objects in scene
Bool castRay(RayCollisionTestClass & raytest, Bool testAll, Int collisionType);
/// customizable renderer for the RTS3DScene
virtual void Customized_Render( RenderInfoClass &rinfo );
virtual void Visibility_Check(CameraClass * camera);
virtual void Render(RenderInfoClass & rinfo);
void setCustomPassMode (CustomScenePassModes mode) {m_customPassMode = mode;}
CustomScenePassModes getCustomPassMode (void) {return m_customPassMode;}
void Flush(RenderInfoClass & rinfo); //draw queued up models.
/// Drawing control method
void drawTerrainOnly(Bool draw) {m_drawTerrainOnly = draw;};
/// Drawing control method
void renderSpecificDrawables(RenderInfoClass &rinfo, Int numDrawables, Drawable **theDrawables) ;
/// Lighting methods
void addDynamicLight(W3DDynamicLight * obj);
void removeDynamicLight(W3DDynamicLight * obj);
RefRenderObjListIterator * createLightsIterator(void);
void destroyLightsIterator(RefRenderObjListIterator * it);
RefRenderObjListClass *getDynamicLights(void) {return &m_dynamicLightList;};
W3DDynamicLight *getADynamicLight(void);
void setGlobalLight(LightClass *pLight,Int lightIndex=0);
LightEnvironmentClass &getDefaultLightEnv(void) {return m_defaultLightEnv;}
void init() {}
void update() {}
void draw();
void reset(){}
void doRender(CameraClass * cam);
protected:
void renderOneObject(RenderInfoClass &rinfo, RenderObjClass *robj, Int localPlayerIndex);
void updateFixedLightEnvironments(RenderInfoClass & rinfo);
void flushTranslucentObjects(RenderInfoClass & rinfo);
void flushOccludedObjects(RenderInfoClass & rinfo);
void flagOccludedObjects(CameraClass * camera);
void flushOccludedObjectsIntoStencil(RenderInfoClass & rinfo);
void updatePlayerColorPasses(void);
protected:
RefRenderObjListClass m_dynamicLightList;
Bool m_drawTerrainOnly;
LightClass *m_globalLight[LightEnvironmentClass::MAX_LIGHTS]; ///< The global directional light (sun, moon) Applies to objects.
LightClass *m_scratchLight; ///< a workspace for copying global lights and modifying // MLorenzen
Vector3 m_infantryAmbient; ///<scene ambient modified to make infantry easier to see
LightClass *m_infantryLight[LightEnvironmentClass::MAX_LIGHTS]; ///< The global direction light modified to make infantry easier to see.
Int m_numGlobalLights; ///<number of global lights
LightEnvironmentClass m_defaultLightEnv; ///<default light environment applied to objects without custom/dynamic lighting.
LightEnvironmentClass m_foggedLightEnv; ///<default light environment applied to objects without custom/dynamic lighting.
W3DShroudMaterialPassClass *m_shroudMaterialPass; ///< Custom render pass which applies shrouds to objects
W3DMaskMaterialPassClass *m_maskMaterialPass; ///< Custom render pass applied to entire scene used to mask out pixels.
MaterialPassClass *m_heatVisionMaterialPass; ///< Custom render passed applied on top of objects with heatvision effect.
MaterialPassClass *m_heatVisionOnlyPass; ///< Custom render pass applied in place of regular pass on objects with heat vision effect.
///Custom rendering passes for each possible player color on the map
MaterialPassClass *m_occludedMaterialPass[MAX_PLAYER_COUNT];
CustomScenePassModes m_customPassMode; ///< flag used to force a non-standard rendering of scene.
Int m_translucentObjectsCount; ///< number of translucent objects to render this frame.
RenderObjClass **m_translucentObjectsBuffer; ///< queue of current frame's translucent objects.
Int m_occludedObjectsCount; ///<number of objects in current frame that need special rendering because occluded.
RenderObjClass **m_potentialOccluders; ///<objects which may block other objects from being visible
RenderObjClass **m_potentialOccludees; ///<objects which may be blocked from visibility by other objects.
RenderObjClass **m_nonOccludersOrOccludees; ///<objects which are neither bockers or blockees (small rocks, shrubs, etc.).
Int m_numPotentialOccluders;
Int m_numPotentialOccludees;
Int m_numNonOccluderOrOccludee;
CameraClass *m_camera;
}; // end class RTS3DScene
//-----------------------------------------------------------------------------
// RTS2DScene
//-----------------------------------------------------------------------------
/** Scene management for 2D overlay on top of 3D scene */
//-----------------------------------------------------------------------------
class RTS2DScene : public SimpleSceneClass, public SubsystemInterface
{
public:
RTS2DScene();
~RTS2DScene();
/// customizable renderer for the RTS2DScene
virtual void Customized_Render( RenderInfoClass &rinfo );
void init() {}
void update() {}
void draw();
void reset(){}
void doRender(CameraClass * cam);
protected:
RenderObjClass *m_status;
CameraClass *m_camera;
}; // end class RTS2DScene
//-----------------------------------------------------------------------------
// RTS3DInterfaceScene
//-----------------------------------------------------------------------------
/** Scene management for 3D interface overlay on top of 3D scene */
//-----------------------------------------------------------------------------
class RTS3DInterfaceScene : public SimpleSceneClass
{
public:
RTS3DInterfaceScene();
~RTS3DInterfaceScene();
/// customizable renderer for the RTS3DInterfaceScene
virtual void Customized_Render( RenderInfoClass &rinfo );
protected:
}; // end class RTS3DInterfaceScene
#endif // end __W3DSCENE_H_

View file

@ -0,0 +1,243 @@
/*
** Command & Conquer Generals(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: W3DShaderManager.h /////////////////////////////////////////////////////////
//
// Custom shader system that allows more options and easier device validation than
// possible with W3D2.
//
// Author: Mark Wilczynski, August 2001
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DSHADERMANAGER_H_
#define __W3DSHADERMANAGER_H_
#include "WW3D2/Texture.h"
enum FilterTypes;
enum CustomScenePassModes;
enum StaticGameLODLevel;
enum ChipsetType;
enum CpuType;
class TextureClass; ///forward reference
/** System for managing complex rendering settings which are either not handled by
WW3D2 or need custom paths depending on the video card. This system will determine
the proper shader given video card limitations and also allow the app to query the
hardware for specific features.
*/
class W3DShaderManager
{
public:
//put any custom shaders (not going through W3D) in here.
enum ShaderTypes
{ ST_INVALID, //invalid shader type.
ST_TERRAIN_BASE, //shader to apply base terrain texture only
ST_TERRAIN_BASE_NOISE1, //shader to apply base texture and cloud/noise 1.
ST_TERRAIN_BASE_NOISE2, //shader to apply base texture and cloud/noise 2.
ST_TERRAIN_BASE_NOISE12,//shader to apply base texture and both cloud/noise
ST_SHROUD_TEXTURE, //shader to apply shroud texture projection.
ST_MASK_TEXTURE, //shader to apply alpha mask texture projection.
ST_ROAD_BASE, //shader to apply base terrain texture only
ST_ROAD_BASE_NOISE1, //shader to apply base texture and cloud/noise 1.
ST_ROAD_BASE_NOISE2, //shader to apply base texture and cloud/noise 2.
ST_ROAD_BASE_NOISE12,//shader to apply base texture and both cloud/noise
ST_CLOUD_TEXTURE, //shader to project clouds.
ST_MAX
};
W3DShaderManager(void); ///<constructor
static void init( void ); ///<determine optimal shaders for current device.
static void shutdown(void); ///<release resources used by shaders
static ChipsetType getChipset(void); ///<return current device chipset.
static Int getShaderPasses(ShaderTypes shader); ///<rendering passes required for shader
static Int setShader(ShaderTypes shader, Int pass); ///<enable specific shader pass.
static void resetShader(ShaderTypes shader); ///<make sure W3D2 gets restored to normal
///Specify all textures (up to 8) which can be accessed by the shaders.
static void setTexture(Int stage,TextureClass* texture) {m_Textures[stage]=texture;}
///Return current texture available to shaders.
static inline TextureClass *getShaderTexture(Int stage) { return m_Textures[stage];} ///<returns currently selected texture for given stage
///Return last activated shader.
static inline ShaderTypes getCurrentShader(void) {return m_currentShader;}
/// Loads a .vso file and creates a vertex shader for it
static HRESULT LoadAndCreateD3DShader(char* strFilePath, const DWORD* pDeclaration, DWORD Usage, Bool ShaderType, DWORD* pHandle);
static Bool testMinimumRequirements(ChipsetType *videoChipType, CpuType *cpuType, Int *cpuFreq, Int *numRAM, Real *intBenchIndex, Real *floatBenchIndex, Real *memBenchIndex);
static StaticGameLODLevel getGPUPerformanceIndex(void);
static Real GetCPUBenchTime(void);
// Filter methods
static Bool filterPreRender(FilterTypes filter, Bool &skipRender, CustomScenePassModes &scenePassMode); ///< Set up at start of render. Only applies to screen filter shaders.
static Bool filterPostRender(FilterTypes filter, enum FilterModes mode, Coord2D &scrollDelta, Bool &doExtraRender); ///< Called after render. Only applies to screen filter shaders.
static Bool filterSetup(FilterTypes filter, enum FilterModes mode);
// Support routines for filter methods.
static Bool canRenderToTexture(void) { return (m_oldRenderSurface && m_newRenderSurface);}
static void startRenderToTexture(void); ///< Sets render target to texture.
static IDirect3DTexture8 * endRenderToTexture(void); ///< Ends render to texture, & returns texture.
static IDirect3DTexture8 * getRenderTexture(void); ///< returns last used render target texture
static void drawViewport(Int color); ///<draws 2 triangles covering the current tactical viewport
protected:
static TextureClass *m_Textures[8]; ///textures assigned to each of the possible stages
static ChipsetType m_currentChipset; ///<last video card chipset that was detected.
static ShaderTypes m_currentShader; ///<last shader that was set.
static Int m_currentShaderPass; ///<pass of last shader that was set.
static FilterTypes m_currentFilter; ///< Last filter that was set.
// Info for a render to texture surface for special effects.
static Bool m_renderingToTexture;
static IDirect3DSurface8 *m_oldRenderSurface; ///<previous render target
static IDirect3DTexture8 *m_renderTexture; ///<texture into which rendering will be redirected.
static IDirect3DSurface8 *m_newRenderSurface; ///<new render target inside m_renderTexture
static IDirect3DSurface8 *m_oldDepthSurface; ///<previous depth buffer surface
};
class W3DFilterInterface
{
public:
virtual Int init(void) = 0; ///<perform any one time initialization and validation
virtual Int shutdown(void) { return TRUE;}; ///<release resources used by shader
virtual Bool preRender(Bool &skipRender, CustomScenePassModes &scenePassMode) {skipRender=false; return false;} ///< Set up at start of render. Only applies to screen filter shaders.
virtual Bool postRender(enum FilterModes mode, Coord2D &scrollDelta, Bool &doExtraRender){return false;} ///< Called after render. Only applies to screen filter shaders.
virtual Bool setup(enum FilterModes mode){return false;} ///< Called when the filter is started, one time before the first prerender.
protected:
virtual Int set(enum FilterModes mode) = 0; ///<setup shader for the specified rendering pass.
///do any custom resetting necessary to bring W3D in sync.
virtual void reset(void) = 0;
};
/*========= ScreenMotionBlurFilter =============================================================*/
///applies motion blur to viewport.
class ScreenMotionBlurFilter : public W3DFilterInterface
{
public:
virtual Int set(enum FilterModes mode); ///<setup shader for the specified rendering pass.
virtual Int init(void); ///<perform any one time initialization and validation
virtual void reset(void); ///<do any custom resetting necessary to bring W3D in sync.
virtual Int shutdown(void); ///<release resources used by shader
virtual Bool preRender(Bool &skipRender, CustomScenePassModes &scenePassMode); ///< Set up at start of render. Only applies to screen filter shaders.
virtual Bool postRender(enum FilterModes mode, Coord2D &scrollDelta, Bool &doExtraRender); ///< Called after render. Only applies to screen filter shaders.
virtual Bool setup(enum FilterModes mode); ///< Called when the filter is started, one time before the first prerender.
ScreenMotionBlurFilter();
static void setZoomToPos(const Coord3D *pos) {m_zoomToPos = *pos; m_zoomToValid = true;}
protected:
enum {MAX_COUNT = 60,
MAX_LIMIT = 30,
COUNT_STEP = 5,
DEFAULT_PAN_FACTOR = 30};
Int m_maxCount;
Int m_lastFrame;
Bool m_decrement;
Bool m_skipRender;
Bool m_additive;
Bool m_doZoomTo;
Coord2D m_priorDelta;
Int m_panFactor;
static Coord3D m_zoomToPos;
static Bool m_zoomToValid;
} ;
/*========= ScreenBWFilter =============================================================*/
///converts viewport to black & white.
class ScreenBWFilter : public W3DFilterInterface
{
DWORD m_dwBWPixelShader; ///<D3D handle to pixel shader which tints texture to black & white.
public:
virtual Int init(void); ///<perform any one time initialization and validation
virtual Int shutdown(void); ///<release resources used by shader
virtual Bool preRender(Bool &skipRender, CustomScenePassModes &scenePassMode); ///< Set up at start of render. Only applies to screen filter shaders.
virtual Bool postRender(enum FilterModes mode, Coord2D &scrollDelta,Bool &doExtraRender); ///< Called after render. Only applies to screen filter shaders.
virtual Bool setup(enum FilterModes mode){return true;} ///< Called when the filter is started, one time before the first prerender.
static void setFadeParameters(Int fadeFrames, Int direction)
{
m_curFadeFrame = 0;
m_fadeFrames = fadeFrames;
m_fadeDirection = direction;
}
protected:
virtual Int set(enum FilterModes mode); ///<setup shader for the specified rendering pass.
virtual void reset(void); ///<do any custom resetting necessary to bring W3D in sync.
static Int m_fadeFrames;
static Int m_fadeDirection;
static Int m_curFadeFrame;
static Real m_curFadeValue;
};
class ScreenBWFilterDOT3 : public ScreenBWFilter
{
public:
virtual Int init(void); ///<perform any one time initialization and validation
virtual Int shutdown(void); ///<release resources used by shader
virtual Bool preRender(Bool &skipRender, CustomScenePassModes &scenePassMode); ///< Set up at start of render. Only applies to screen filter shaders.
virtual Bool postRender(enum FilterModes mode, Coord2D &scrollDelta,Bool &doExtraRender); ///< Called after render. Only applies to screen filter shaders.
virtual Bool setup(enum FilterModes mode){return true;} ///< Called when the filter is started, one time before the first prerender.
protected:
virtual Int set(enum FilterModes mode); ///<setup shader for the specified rendering pass.
virtual void reset(void); ///<do any custom resetting necessary to bring W3D in sync.
};
/*========= ScreenCrossFadeFilter =============================================================*/
///Fades between 2 different rendered frames.
class ScreenCrossFadeFilter : public W3DFilterInterface
{
public:
virtual Int init(void); ///<perform any one time initialization and validation
virtual Int shutdown(void); ///<release resources used by shader
virtual Bool preRender(Bool &skipRender, CustomScenePassModes &scenePassMode); ///< Set up at start of render. Only applies to screen filter shaders.
virtual Bool postRender(enum FilterModes mode, Coord2D &scrollDelta,Bool &doExtraRender); ///< Called after render. Only applies to screen filter shaders.
virtual Bool setup(enum FilterModes mode){return true;} ///< Called when the filter is started, one time before the first prerender.
static void setFadeParameters(Int fadeFrames, Int direction)
{
m_curFadeFrame = 0;
m_fadeFrames = fadeFrames;
m_fadeDirection = direction;
}
static Real getCurrentFadeValue(void) { return m_curFadeValue;}
static TextureClass *getCurrentMaskTexture(void) { return m_fadePatternTexture;}
protected:
virtual Int set(enum FilterModes mode); ///<setup shader for the specified rendering pass.
virtual void reset(void); ///<do any custom resetting necessary to bring W3D in sync.
Bool updateFadeLevel(void); ///<updated current state of fade and return true if not finished.
static Int m_fadeFrames;
static Int m_fadeDirection;
static Int m_curFadeFrame;
static Real m_curFadeValue;
static Bool m_skipRender;
static TextureClass *m_fadePatternTexture; ///<shape/pattern of the fade
};
#endif //__W3DSHADERMANAGER_H_

View file

@ -0,0 +1,76 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DSHADOW_H_
#define __W3DSHADOW_H_
#include "matrix4.h"
#include "GameClient/Shadow.h"
class Drawable; //forward reference
// ShadowManager -------------------------------------------------------------
class W3DShadowManager
{
public:
W3DShadowManager( void );
~W3DShadowManager( void );
Bool init( void ); ///<initialize resources used by manager, must have valid D3D device.
void queueShadows(Bool state) {m_isShadowScene=state;} ///<flags system to process shadows on next render call.
// shadow list management
void Reset( void );
Shadow* addShadow( RenderObjClass *robj,Shadow::ShadowTypeInfo *shadowInfo=NULL, Drawable *draw=NULL); ///< adds shadow caster to rendering system.
void removeShadow(Shadow *shadow); ///< removed shadow from rendering system and frees its resources.
void removeAllShadows(void); ///< Remove all shadows.
void setShadowColor(UnsignedInt color) { m_shadowColor=color;} ///<sets the shadow color and alpha, value in ARGB format.
UnsignedInt getShadowColor() { return m_shadowColor;} ///<gets the shadow color and alpha, value in ARGB format.
void setLightPosition(Int lightIndex, Real x, Real y, Real z); ///<sets the position of a specific light source.
void setTimeOfDay(TimeOfDay tod);
void invalidateCachedLightPositions(void); ///<forces shadow volumes to update regardless of last lightposition
Vector3 &getLightPosWorld(Int lightIndex); ///<returns the position of specified light source.
Bool isShadowScene(void) {return m_isShadowScene;}
inline void setStencilShadowMask(int mask) {m_stencilShadowMask=mask;} ///<mask used to mask out stencil bits used for storing occlusion/playerColor
inline Int getStencilShadowMask(void) {return m_stencilShadowMask;}
// rendering
void RenderShadows( void );
void ReleaseResources(void);
Bool ReAcquireResources(void);
protected:
Bool m_isShadowScene; ///<flag if current scene needs shadows. No shadows on pre-pass and 2D.
UnsignedInt m_shadowColor; ///<color and alpha for all shadows in scene.
Int m_stencilShadowMask;
}; // end class W3DShadowManager
extern W3DShadowManager *TheW3DShadowManager;
#endif //__W3DSHADOW_H_

View file

@ -0,0 +1,131 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DSHROUD_H_
#define __W3DSHROUD_H_
#include "WW3D2/matpass.h"
#include "WW3D2/dx8wrapper.h"
class AABoxClass;
class WorldHeightMap;
typedef UnsignedByte W3DShroudLevel;
// In Global Data now
//const W3DShroudLevel FULL_SHROUD_LEVEL=0;
//const W3DShroudLevel FOG_SHROUD_LEVEL=127;
//const W3DShroudLevel NO_SHROUD_LEVEL=255;
/** Custom W3D material pass which has been modified to apply
a shroud texture projection.
*/
class W3DShroudMaterialPassClass : public MaterialPassClass
{
public:
W3DShroudMaterialPassClass(void) : m_isTransparentObjectPass(FALSE) {}
virtual void Install_Materials(void) const;
virtual void UnInstall_Materials(void) const;
void enableTransparentObjectPass(Bool enable) {m_isTransparentObjectPass = enable;}
protected:
//customized version to deal with transparent (alpha-tested) polys.
Bool m_isTransparentObjectPass;
};
/** Custom W3D material pass which has been modified to apply
a texture projection. Similar to the above code except
that it's more generic so could be used for non-shroud
projection of various masks.
*/
class W3DMaskMaterialPassClass : public MaterialPassClass
{
public:
W3DMaskMaterialPassClass(void) : m_texture(NULL), m_allowUninstall(TRUE) {}
virtual void Install_Materials(void) const;
virtual void UnInstall_Materials(void) const;
void setTexture(TextureClass *texture) {m_texture=texture;}
void setAllowUninstall(Bool state) { m_allowUninstall = state;}
protected:
TextureClass *m_texture; ///<texture to be projected.
Bool m_allowUninstall; ///<flag which allows uninstalling this material.
};
/** Terrain shroud rendering class */
class W3DShroud
{
public:
W3DShroud(void);
~W3DShroud(void);
void render(CameraClass *cam); ///< render the current shroud state as seen from camera
void init(WorldHeightMap *pMap, Real worldCellSizeX, Real worldCellSizeY);
void reset(void);
TextureClass *getShroudTexture(void) { return m_pDstTexture;} //<return shroud projection texture.
void ReleaseResources(void); ///<release resources that can't survive D3D device reset.
Bool ReAcquireResources(void); ///<allocate resources that can't survive D3D device reset.
void fillShroudData(W3DShroudLevel level); ///<sets the state of the current shroud to some constant value
Int getNumShroudCellsY(void) {return m_numCellsY;}
Int getNumShroudCellsX(void) {return m_numCellsX;}
Real getCellWidth(void) {return m_cellWidth;} ///<world-space width (x) of each shroud cell.
Real getCellHeight(void) {return m_cellHeight;} ///<world-space height (y)of each shroud cell.
Int getTextureWidth(void) {return m_dstTextureWidth;} ///<internal use by the shader system.
Int getTextureHeight(void) {return m_dstTextureHeight;}
W3DShroudLevel getShroudLevel(Int x, Int y);
void setShroudLevel(Int x, Int y, W3DShroudLevel,Bool textureOnly=FALSE);
void setShroudFilter(Bool enable); ///<turns on bilinear filtering of shroud cells.
void setBorderShroudLevel(W3DShroudLevel level); ///<color that will appear in unused border terrain.
Real getDrawOriginX(void) {return m_drawOriginX;} ///<returns ws origin of first pixel in shroud texture.
Real getDrawOriginY(void) {return m_drawOriginY;} ///<returns ws origin of first pixel in shroud texture.
protected:
Int m_numCellsX; ///<number of cells covering entire map
Int m_numCellsY; ///<number of cells covering entire map
Int m_numMaxVisibleCellsX; ///<maximum number of shroud cells that can be visible
Int m_numMaxVisibleCellsY; ///<maximum number of shroud cells that can be visible
Real m_cellWidth; ///<spacing between adjacent cells
Real m_cellHeight; ///<spacing between adjacent cells
Byte *m_shroudData; ///<holds amount of shroud per cell.
IDirect3DSurface8 *m_pSrcTexture; ///<stores sysmem copy of visible shroud.
void *m_srcTextureData; ///<pointer to shroud data
UnsignedInt m_srcTexturePitch; ///<width (in bytes) of shroud data buffer.
TextureClass *m_pDstTexture; ///<stores vidmem copy of visible shroud.
Int m_dstTextureWidth; ///<dimensions of m_pDstTexture
Int m_dstTextureHeight; ///<dimensions of m_pDstTexture
TextureClass::FilterType m_shroudFilter;
Real m_drawOriginX;
Real m_drawOriginY;
Bool m_drawFogOfWar; ///<switch to draw alternate fog style instead of solid black
Bool m_clearDstTexture; ///<flag indicating we must clear video memory destination texture
W3DShroudLevel m_boderShroudLevel; ///<color used to clear the shroud border
W3DShroudLevel *m_finalFogData; ///<copy of logical shroud in an easier to access array.
W3DShroudLevel *m_currentFogData; ///<copy of intermediate logical shroud while it's interpolated.
void interpolateFogLevels(RECT *rect); ///<fade current fog levels to actual logic side levels.
void fillBorderShroudData(W3DShroudLevel level, SurfaceClass* pDestSurface); ///<fill the destination texture with a known value
};
#endif //__W3DSHROUD_H_

View file

@ -0,0 +1,102 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __STATUS_CIRCLE_H_
#define __STATUS_CIRCLE_H_
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
//
// W3DStatusCircle: Object generated from 2D Height grid
//
//
class W3DStatusCircle : public RenderObjClass
{
public:
W3DStatusCircle(void);
W3DStatusCircle(const W3DStatusCircle & src);
W3DStatusCircle & operator = (const W3DStatusCircle &);
~W3DStatusCircle(void);
/////////////////////////////////////////////////////////////////////////////
// Render Object Interface
/////////////////////////////////////////////////////////////////////////////
virtual RenderObjClass * Clone(void) const;
virtual int Class_ID(void) const;
virtual void Render(RenderInfoClass & rinfo);
// virtual void Special_Render(SpecialRenderInfoClass & rinfo);
// virtual void Set_Transform(const Matrix3D &m);
// virtual void Set_Position(const Vector3 &v);
//TODO: MW: do these later - only needed for collision detection
virtual bool Cast_Ray(RayCollisionTestClass & raytest);
// virtual Bool Cast_AABox(AABoxCollisionTestClass & boxtest);
// virtual Bool Cast_OBBox(OBBoxCollisionTestClass & boxtest);
// virtual Bool Intersect_AABox(AABoxIntersectionTestClass & boxtest);
// virtual Bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest);
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const;
// virtual int Get_Num_Polys(void) const;
// virtual const char * Get_Name(void) const;
// virtual void Set_Name(const char * name);
// unsigned int Get_Flags(void) { return Flags; }
// void Set_Flags(unsigned int flags) { Flags = flags; }
// void Set_Flag(unsigned int flag, Bool onoff) { Flags &= (~flag); if (onoff) Flags |= flag; }
int updateBlock(void);
Int freeMapResources(void);
void static setColor(Int r, Int g, Int b) {m_needUpdate = true; m_diffuse = (b) + (g<<8) + (r<<16);};
protected:
Int m_numTriangles; //dimensions of list
static Int m_diffuse;
static Bool m_needUpdate;
DX8IndexBufferClass *m_indexBuffer; //indices defining a triangle strip the covers full terrain
ShaderClass m_shaderClass; //shader or rendering state for heightmap
VertexMaterialClass *m_vertexMaterialClass;
DX8VertexBufferClass *m_vertexBufferCircle; //collection of vertexes that make the circle.
DX8VertexBufferClass *m_vertexBufferScreen; //2 triangle quad that covers the screen.
int initData(void);
Int updateCircleVB(void);
Int updateScreenVB(Int diffuse);
};
#endif // end __DRAW_OBJECT_H_

View file

@ -0,0 +1,160 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DTERRAINTRACKS_H_
#define __W3DTERRAINTRACKS_H_
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#define MAX_TRACK_EDGE_COUNT 100 //maximum number of edges or divisions in track mark
#define MAX_TRACK_OPAQUE_EDGE 25 //linear fade of edges will begin at this edge
#define FADE_TIME_FRAMES 300000 // 300 seconds at 30 fps - time to fade out an edge and remove it from the system.
class TerrainTracksRenderObjClassSystem;
class Drawable;
/// Custom render object that draws tracks on the terrain.
/**
This render object handles drawing tracks left by objects moving on the terrain.
*/
class TerrainTracksRenderObjClass : public W3DMPO, public RenderObjClass
{
W3DMPO_GLUE(TerrainTracksRenderObjClass)
friend class TerrainTracksRenderObjClassSystem;
public:
TerrainTracksRenderObjClass(void);
~TerrainTracksRenderObjClass(void);
/////////////////////////////////////////////////////////////////////////////
// Render Object Interface (W3D methods)
/////////////////////////////////////////////////////////////////////////////
virtual RenderObjClass * Clone(void) const;
virtual int Class_ID(void) const;
virtual void Render(RenderInfoClass & rinfo);
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const;
Int freeTerrainTracksResources(void); ///<free W3D assets used for this track
void init( Real width, Real length, const Char *texturename); ///<allocate W3D resources and set size
void addEdgeToTrack(Real x, Real y); ///< add a new segment to the track
void addCapEdgeToTrack(Real x, Real y); ///< cap the existing segment so we can resume at an unconnected position.
void setAirborne(void) {m_airborne = true; } ///< Starts a new section of track, generally after going airborne.
void setOwnerDrawable(const Drawable *owner) {m_ownerDrawable = owner;}
protected:
TextureClass *m_stageZeroTexture; ///<primary texture
SphereClass m_boundingSphere; ///<bounding sphere of TerrainTracks
AABoxClass m_boundingBox; ///<bounding box of TerrainTracks
Int m_activeEdgeCount; ///<number of active edges in segment list
Int m_totalEdgesAdded; ///<number of edges ever added to this track
const Drawable *m_ownerDrawable; ///<logical object that's laying down tread marks.
struct edgeInfo{
Vector3 endPointPos[2]; ///<the 2 endpoints on the edge
Vector2 endPointUV[2]; ///< uv coordinates at each end point
Int timeAdded; ///< time when edge was created.
Real alpha; ///< current alpha value for rendering
};
edgeInfo m_edges[MAX_TRACK_EDGE_COUNT]; ///<edges at each segment break
Vector3 m_lastAnchor; ///<location of last edge center
Int m_bottomIndex; ///<points at oldest edge on track
Int m_topIndex; ///<points to newest edge on track
Bool m_haveAnchor; ///<set to false until first edge is added
Bool m_bound; ///<object is bound to owner and accepts new edges
Real m_width; ///<track width
Real m_length; ///<length of each track segment
Bool m_airborne; ///< Did the vehicle bounce up into the air?
Bool m_haveCap; ///< is the segment capped so we can stop and resume at new location.
TerrainTracksRenderObjClass *m_nextSystem; ///<next track system
TerrainTracksRenderObjClass *m_prevSystem; ///<previous track system
};
/// System for drawing, updating, and re-using tread mark render objects.
/**
This system keeps track of all the active track mark objects and reuses them
when they expire. It also renders all the track marks that were submitted in
this frame.
*/
class TerrainTracksRenderObjClassSystem
{
friend class TerrainTracksRenderObjClass;
public:
TerrainTracksRenderObjClassSystem( void );
~TerrainTracksRenderObjClassSystem( void );
void ReleaseResources(void); ///< Release all dx8 resources so the device can be reset.
void ReAcquireResources(void); ///< Reacquire all resources after device reset.
void setDetail(void);
void flush (void); ///<draw all tracks that were requested for rendering.
void update(void); ///<update the state of all edges (fade alpha, remove old, etc.)
void init( SceneClass *TerrainTracksScene); ///< pre-allocate track objects
void shutdown( void ); ///< release all pre-allocated track objects, called by destructor
void Reset(void); ///<empties the system, ready for a new scene.
TerrainTracksRenderObjClass *bindTrack(RenderObjClass *renderObject, Real length, const Char *texturename); ///<track object to be controlled by owner
void unbindTrack( TerrainTracksRenderObjClass *mod ); ///<releases control of track object
protected:
DX8VertexBufferClass *m_vertexBuffer; ///<vertex buffer used to draw all tracks
DX8IndexBufferClass *m_indexBuffer; ///<indices defining triangles in maximum length track
VertexMaterialClass *m_vertexMaterialClass; ///< vertex lighting material
ShaderClass m_shaderClass; ///<shader or rendering state for heightmap
TerrainTracksRenderObjClass *m_usedModules; ///<active objects being rendered in the scene
TerrainTracksRenderObjClass *m_freeModules; //<unused modules that are free to use again
SceneClass *m_TerrainTracksScene; ///<scene that will contain all the TerrainTracks
Int m_edgesToFlush; ///< number of edges to flush on next render.
void releaseTrack( TerrainTracksRenderObjClass *mod ); ///<returns track object to free store.
void clearTracks(void); ///<reset the amount of visible track marks of each object.
Int m_maxTankTrackEdges; ///<maximum length of tank track
Int m_maxTankTrackOpaqueEdges; ///<maximum length of tank track before it starts fading.
Int m_maxTankTrackFadeDelay; ///<maximum amount of time a tank track segment remains visible.
}; // end class TerrainTracksRenderObjClassSystem
extern TerrainTracksRenderObjClassSystem *TheTerrainTracksRenderObjClassSystem; ///< singleton for track drawing system.
#endif // end __W3DTERRAINTRACKS_H_

View file

@ -0,0 +1,138 @@
/*
** Command & Conquer Generals(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: W3DTerrainVisual.h ///////////////////////////////////////////////////////////////////////
// W3D implementation details for visual aspects of terrain
// Author: Colin Day, April 2001
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DTERRAINVISUAL_H_
#define __W3DTERRAINVISUAL_H_
#include "GameClient/TerrainVisual.h"
#include "W3DDevice/GameClient/W3DWater.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
class Matrix3D;
class WaterHandle;
class HeightMapRenderObjClass;
class WorldHeightMap;
//-------------------------------------------------------------------------------------------------
/** W3D impelmentation of visual terrain details singleton */
//-------------------------------------------------------------------------------------------------
class W3DTerrainVisual : public TerrainVisual
{
public:
W3DTerrainVisual();
virtual ~W3DTerrainVisual();
virtual void init( void );
virtual void reset( void );
virtual void update( void );
virtual Bool load( AsciiString filename );
void getTerrainColorAt( Real x, Real y, RGBColor *pColor );
/// get the terrain tile type at the world location in the (x,y) plane ignoring Z
TerrainType *getTerrainTile( Real x, Real y );
/** intersect the ray with the terrain, if a hit occurs TRUE is returned
and the result point on the terrain is returned in "result" */
virtual Bool intersectTerrain( Coord3D *rayStart, Coord3D *rayEnd, Coord3D *result );
//
// water methods
//
/// enable/disable the water grid
virtual void enableWaterGrid( Bool enable );
/// set min/max height values allowed in water grid pointed to by waterTable
virtual void setWaterGridHeightClamps( const WaterHandle *waterTable, Real minZ, Real maxZ );
/// adjust fallof parameters for grid change method
virtual void setWaterAttenuationFactors( const WaterHandle *waterTable,
Real a, Real b, Real c, Real range );
/// set the water table position and orientation in world space
virtual void setWaterTransform( const WaterHandle *waterTable,
Real angle, Real x, Real y, Real z );
virtual void setWaterTransform( const Matrix3D *transform );
virtual void getWaterTransform( const WaterHandle *waterTable, Matrix3D *transform );
/// water grid resolution spacing
virtual void setWaterGridResolution( const WaterHandle *waterTable,
Real gridCellsX, Real gridCellsY, Real cellSize );
virtual void getWaterGridResolution( const WaterHandle *waterTable,
Real *gridCellsX, Real *gridCellsY, Real *cellSize );
/// adjust the water grid in world coords by the delta
virtual void changeWaterHeight( Real x, Real y, Real delta );
/// adjust the velocity at a water grid point corresponding to the world x,y
virtual void addWaterVelocity( Real worldX, Real worldY,
Real velocity, Real preferredHeight );
virtual Bool getWaterGridHeight( Real worldX, Real worldY, Real *height);
virtual void setTerrainTracksDetail(void);
virtual void setShoreLineDetail(void);
/// Add a bib at location.
void addFactionBib(Object *factionBuilding, Bool highlight, Real extra = 0);
/// Remove a bib.
void removeFactionBib(Object *factionBuilding);
/// Add a bib at location.
void addFactionBibDrawable(Drawable *factionBuilding, Bool highlight, Real extra = 0);
/// Remove a bib.
void removeFactionBibDrawable(Drawable *factionBuilding);
virtual void removeAllBibs(void);
virtual void removeBibHighlighting(void);
//
// Modify height.
//
virtual void setRawMapHeight(const ICoord2D *gridPos, Int height);
/// Replace the skybox texture
virtual void replaceSkyboxTextures(const AsciiString *oldTexName[NumSkyboxTextures], const AsciiString *newTexName[NumSkyboxTextures]);
protected:
// snapshot methods
virtual void crc( Xfer *xfer );
virtual void xfer( Xfer *xfer );
virtual void loadPostProcess( void );
HeightMapRenderObjClass *m_terrainRenderObject; ///< W3D render object for terrain
WaterRenderObjClass *m_waterRenderObject; ///< W3D render object for water plane
WorldHeightMap *m_terrainHeightMap; ///< height map used for render obj building
Bool m_isWaterGridRenderingEnabled;
AsciiString m_currentSkyboxTexNames[NumSkyboxTextures]; ///<store current texture names applied to skybox.
AsciiString m_initialSkyboxTexNames[NumSkyboxTextures]; ///<store starting texture/default skybox textures.
}; // end class W3DTerrainVisual
#endif // end __W3DTERRAINVISUAL_H_

View file

@ -0,0 +1,149 @@
/*
** Command & Conquer Generals(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: W3DTreeBuffer.h //////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: W3DTreeBuffer.h
//
// Created: John Ahlquist, May 2001
//
// Desc: Draw buffer to handle all the trees in a scene.
//
//-----------------------------------------------------------------------------
#pragma once
#ifndef __W3DTREE_BUFFER_H_
#define __W3DTREE_BUFFER_H_
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#include "common/GameType.h"
#include "Common/AsciiString.h"
//-----------------------------------------------------------------------------
// Forward References
//-----------------------------------------------------------------------------
class MeshClass;
//-----------------------------------------------------------------------------
// Type Defines
//-----------------------------------------------------------------------------
typedef enum {
ALPINE_TREE = 0,
DECIDUOUS_TREE = 1,
SHRUB = 2,
FENCE = 3
} TTreeType;
/// The individual data for a tree.
typedef struct {
Vector3 location; ///< Drawing location
Real scale; ///< Scale at location.
Real sin; ///< Sine of the rotation angle at location.
Real cos; ///< Cosine of the rotation angle at location.
Int panelStart; ///< Index of the "panel" lod.
TTreeType treeType; ///< Type of tree. Currently only 3 supported.
Bool visible; ///< Visible flag, updated each frame.
Bool mirrorVisible; ///< Possibly visible in mirror.
Bool rotates; ///< Trees rotate to follow the camera in single panel mode, fences don't
SphereClass bounds; ///< Bounding sphere for culling to set the visible flag.
Real sortKey; ///< Sort key, essentially the distance along the look at vector.
} TTree;
//
// W3DTreeBuffer: Draw buffer for the trees.
//
//
class W3DTreeBuffer
{
friend class HeightMapRenderObjClass;
public:
W3DTreeBuffer(void);
~W3DTreeBuffer(void);
/// Add a tree at location. Name is the w3d model name.
void addTree(Coord3D location, Real scale, Real angle, AsciiString name, Bool visibleInMirror);
/// Empties the tree buffer.
void clearAllTrees(void);
/// Draws the trees. Uses camera for culling.
void drawTrees(CameraClass * camera, RefRenderObjListIterator *pDynamicLightsIterator);
/// Called when the view changes, and sort key needs to be recalculated.
/// Normally sortKey gets calculated when a tree becomes visible.
void doFullUpdate(void) {m_updateAllKeys = true;};
void setIsTerrain(void) {m_isTerrainPass = true;}; ///< Terrain calls this to tell trees to draw.
Bool needToDraw(void) {return m_isTerrainPass;};
protected:
enum { MAX_TREE_VERTEX=4000,
MAX_TREE_INDEX=2*4000,
MAX_TREES=2000};
enum {MAX_TYPES = 4,
SORT_ITERATIONS_PER_FRAME=10};
DX8VertexBufferClass *m_vertexTree; ///<Tree vertex buffer.
DX8IndexBufferClass *m_indexTree; ///<indices defining a triangles for the tree drawing.
TextureClass *m_treeTexture; ///<Trees texture
Int m_curNumTreeVertices; ///<Number of vertices used in m_vertexTree.
Int m_curNumTreeIndices; ///<Number of indices used in b_indexTree;
Int m_curTreeIndexOffset; ///<First index to draw at. We draw the trees backwards by filling up the index buffer backwards,
// so any trees that don't fit are far away from the camera.
TTree m_trees[MAX_TREES]; ///< The tree buffer. All trees are stored here.
Int m_numTrees; ///< Number of trees in m_trees.
Bool m_anythingChanged; ///< Set to true if visibility or sorting changed.
Bool m_updateAllKeys; ///< Set to true when the view changes.
Bool m_initialized; ///< True if the subsystem initialized.
Bool m_isTerrainPass; ///< True if the terrain was drawn in this W3D scene render pass.
SphereClass m_typeBounds[MAX_TYPES]; ///< Bounding boxes for the base tree models.
MeshClass *m_typeMesh[MAX_TYPES]; ///< W3D mesh models for the trees.
Vector3 m_cameraLookAtVector;
void loadTreesInVertexAndIndexBuffers(RefRenderObjListIterator *pDynamicLightsIterator); ///< Fills the index and vertex buffers for drawing.
void allocateTreeBuffers(void); ///< Allocates the buffers.
void cull(CameraClass * camera); ///< Culls the trees.
void cullMirror(CameraClass * camera); ///< Culls the trees in the mirror view.
Int doLighting(Vector3 *loc, Real r, Real g, Real b, SphereClass &bounds, RefRenderObjListIterator *pDynamicLightsIterator);
void freeTreeBuffers(void); ///< Frees the index and vertex buffers.
void sort( Int iterations ); ///< Performs partial bubble sort.
};
#endif // end __W3DTREE_BUFFER_H_

View file

@ -0,0 +1,105 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//----------------------------------------------------------------------------
//
// Project: Generals
//
// File name: W3DDevice/GameClient/W3DVideoBuffer.h
//
// Created: 10/23/01
//
//----------------------------------------------------------------------------
#pragma once
#ifndef __W3DDEVICE_GAMECLIENT_W3DVIDEOBUFFER_H_
#define __W3DDEVICE_GAMECLIENT_W3DVIDEOBUFFER_H_
//----------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------
#include "GameClient/VideoPlayer.h"
//----------------------------------------------------------------------------
// Forward References
//----------------------------------------------------------------------------
class TextureClass;
class SurfaceClass;
//----------------------------------------------------------------------------
// Type Defines
//----------------------------------------------------------------------------
//===============================
// W3DVideoBuffer
//===============================
/**
* Video buffer interface class to a W3D TextureClass
*/
//===============================
class W3DVideoBuffer : public VideoBuffer
{
protected:
TextureClass *m_texture;
SurfaceClass *m_surface;
public:
W3DVideoBuffer( Type format );
virtual ~W3DVideoBuffer();
virtual Bool allocate( UnsignedInt width, UnsignedInt height); ///< Allocates buffer
virtual void free( void); ///< Free buffer
virtual void* lock( void ); ///< Returns memory pointer to start of buffer
virtual void unlock( void ); ///< Release buffer
virtual Bool valid( void ); ///< Is the buffer valid to use
TextureClass *texture( void ); ///< Returns texture object
static WW3DFormat TypeToW3DFormat( VideoBuffer::Type format );
static VideoBuffer::Type W3DFormatToType( WW3DFormat w3dFormat );
};
//----------------------------------------------------------------------------
// Inlining
//----------------------------------------------------------------------------
inline TextureClass* W3DVideoBuffer::texture( void ) { return m_texture; }
#endif // __W3DDEVICE_GAMECLIENT_W3DVIDEOBUFFER_H_

View file

@ -0,0 +1,284 @@
/*
** Command & Conquer Generals(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: W3DView.h ////////////////////////////////////////////////////////////////////////////////
//
// W3D implementation of the game view window. View windows are literally
// a window into the game world that have width, height, and camera
// controls for what to look at
//
// Author: Colin Day, April 2001
//
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DVIEW_H_
#define __W3DVIEW_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
#include "Common/STLTypedefs.h"
#include "GameClient/View.h"
#include "WW3D2/Camera.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
class Drawable;
///////////////////////////////////////////////////////////////////////////////////////////////////
enum {MAX_WAYPOINTS=25};
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
typedef struct
{
Int numWaypoints;
Coord3D waypoints[MAX_WAYPOINTS+2]; // We pad first & last for interpolation.
Real waySegLength[MAX_WAYPOINTS+2]; // Length of each segment;
Real cameraAngle[MAX_WAYPOINTS+2]; // Camera Angle;
Real cameraFXPitch[MAX_WAYPOINTS+2]; // Camera Pitch;
Real cameraZoom[MAX_WAYPOINTS+2]; // Camera Zoom;
Int timeMultiplier[MAX_WAYPOINTS+2]; // Time speedup factor.
Real groundHeight[MAX_WAYPOINTS+1]; // Ground height.
Int totalTimeMilliseconds; // Num of ms to do this movement.
Int elapsedTimeMilliseconds; // Time since start.
Real totalDistance; // Total length of paths.
Real curSegDistance; // How far we are along the current seg.
Int shutter;
Int curSegment; // The current segment.
Int curShutter; // The current shutter.
Int rollingAverageFrames; // Number of frames to roll.
} TMoveAlongWaypointPathInfo;
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
typedef struct
{
Int numFrames; ///< Number of frames to rotate.
Int curFrame; ///< Current frame.
Real angle;
Real startZoom;
Real endZoom;
Real startPitch;
Real endPitch;
Int startTimeMultiplier;
Int endTimeMultiplier;
ObjectID targetObjectID; ///< Target if we are tracking an object instead of just rotating
Coord3D targetObjectPos; ///< Target's position (so we can stay looking at that spot if he dies)
Bool trackObject; ///< Are we tracking an object or just rotating?
Int numHoldFrames; ///< Number of frames to hold the camera before finishing the movement
} TRotateCameraInfo;
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
typedef struct
{
Int numFrames; ///< Number of frames to pitch.
Int curFrame; ///< Current frame.
Real angle;
Real startPitch;
Real endPitch;
Int startTimeMultiplier;
Int endTimeMultiplier;
} TPitchCameraInfo;
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
typedef struct
{
Int numFrames; ///< Number of frames to zoom.
Int curFrame; ///< Current frame.
Real startZoom;
Real endZoom;
Int startTimeMultiplier;
Int endTimeMultiplier;
} TZoomCameraInfo;
// ------------------------------------------------------------------------------------------------
/** W3DView implementation of the game view class. This allows us to create
* a "window" into the game world that can be sized and contains controls
* for manipulating the camera */
// ------------------------------------------------------------------------------------------------
class W3DView : public View, public SubsystemInterface
{
public:
W3DView();
~W3DView();
virtual void init( void ); ///< init/re-init the W3DView
virtual void reset( void );
virtual void drawView( void ); ///< draw this view
virtual void updateView(void); ///<called once per frame to determine the final camera and object transforms
virtual void draw( ); ///< draw this view
virtual void update( ); ///<called once per frame to determine the final camera and object transforms
virtual Drawable *pickDrawable( const ICoord2D *screen, Bool forceAttack, PickType pickType ); ///< pick drawable given the screen pixel coords. If force attack, picks bridges.
/// all drawables in the 2D screen region will call the 'callback'
virtual Int iterateDrawablesInRegion( IRegion2D *screenRegion,
Bool (*callback)( Drawable *draw, void *userData ),
void *userData );
virtual void setWidth( Int width );
virtual void setHeight( Int height );
virtual void setOrigin( Int x, Int y); ///< Sets location of top-left view corner on display
virtual void scrollBy( Coord2D *delta ); ///< Shift the view by the given delta
virtual void forceRedraw();
virtual void setAngle( Real angle ); ///< Rotate the view around the up axis by the given angle
virtual void setPitch( Real angle ); ///< Rotate the view around the horizontal axis to the given angle
virtual void setAngleAndPitchToDefault( void ); ///< Set the view angle back to default
virtual void lookAt( const Coord3D *o ); ///< Center the view on the given coordinate
virtual void initHeightForMap( void ); ///< Init the camera height for the map at the current position.
virtual void moveCameraTo(const Coord3D *o, Int miliseconds, Int shutter, Bool orient);
virtual void moveCameraAlongWaypointPath(Waypoint *pWay, Int frames, Int shutter, Bool orient);
virtual Bool isCameraMovementFinished(void);
virtual void resetCamera(const Coord3D *location, Int frames); ///< Move camera to location, and reset to default angle & zoom.
virtual void rotateCamera(Real rotations, Int frames); ///< Rotate camera about current viewpoint.
virtual void rotateCameraTowardObject(ObjectID id, Int milliseconds, Int holdMilliseconds); ///< Rotate camera to face an object, and hold on it
virtual void rotateCameraTowardPosition(const Coord3D *pLoc, Int milliseconds); ///< Rotate camera to face a location.
virtual void cameraModFreezeTime(void){ m_freezeTimeForCameraMovement = true;} ///< Freezes time during the next camera movement.
virtual void cameraModFreezeAngle(void); ///< Freezes time during the next camera movement.
virtual Bool isTimeFrozen(void){ return m_freezeTimeForCameraMovement;} ///< Freezes time during the next camera movement.
virtual void cameraModFinalZoom(Real finalZoom); ///< Final zoom for current camera movement.
virtual void cameraModRollingAverage(Int framesToAverage); ///< Number of frames to average movement for current camera movement.
virtual void cameraModFinalTimeMultiplier(Int finalMultiplier); ///< Final time multiplier for current camera movement.
virtual void cameraModFinalPitch(Real finalPitch); ///< Final pitch for current camera movement.
virtual void cameraModLookToward(Coord3D *pLoc); ///< Sets a look at point during camera movement.
virtual void cameraModFinalLookToward(Coord3D *pLoc); ///< Sets a look at point during camera movement.
virtual void cameraModFinalMoveTo(Coord3D *pLoc); ///< Sets a final move to.
virtual Int getTimeMultiplier(void) {return m_timeMultiplier;};///< Get the time multiplier.
virtual void setTimeMultiplier(Int multiple) {m_timeMultiplier = multiple;}; ///< Set the time multiplier.
virtual void setDefaultView(Real pitch, Real angle, Real maxHeight);
virtual void zoomCamera( Real finalZoom, Int milliseconds );
virtual void pitchCamera( Real finalPitch, Int milliseconds );
virtual void setHeightAboveGround(Real z);
virtual void setZoom(Real z);
virtual void setZoomToDefault( void ); ///< Set zoom to default value
virtual void setFieldOfView( Real angle ); ///< Set the horizontal field of view angle
virtual Bool worldToScreen( const Coord3D *w, ICoord2D *s ); ///< Transform world coordinate "w" into screen coordinate "s"
virtual void screenToWorld( const ICoord2D *s, Coord3D *w ); ///< Transform screen coordinate "s" into world coordinate "w"
virtual void screenToTerrain( const ICoord2D *screen, Coord3D *world ); ///< transform screen coord to a point on the 3D terrain
virtual void screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z ); ///< transform screen point to world point at the specified world Z value
CameraClass *get3DCamera() const { return m_3DCamera; }
virtual const Coord3D& get3DCameraPosition() const;
virtual void setCameraLock(ObjectID id);
virtual void setSnapMode( CameraLockType lockType, Real lockDist );
/// Add an impulse force to shake the camera
virtual void shake( const Coord3D *epicenter, CameraShakeType shakeType );
virtual Real getFXPitch( void ) const { return m_FXPitch; } ///< returns the FX pitch angle
virtual Bool setViewFilterMode(enum FilterModes filterMode); ///< Turns on viewport special effect (black & white mode)
virtual Bool setViewFilter(enum FilterTypes filter); ///< Turns on viewport special effect (black & white mode)
virtual void setViewFilterPos(const Coord3D *pos); ///< Passes a position to the special effect filter.
virtual enum FilterModes getViewFilterMode(void) {return m_viewFilterMode;} ///< Turns on viewport special effect (black & white mode)
virtual enum FilterTypes getViewFilterType(void) {return m_viewFilter;} ///< Turns on viewport special effect (black & white mode)
virtual void setFadeParameters(Int fadeFrames, Int direction);
virtual void set3DWireFrameMode(Bool enable); ///<enables custom wireframe rendering of 3D viewport
Bool updateCameraMovements(void);
virtual void forceCameraConstraintRecalc(void) { calcCameraConstraints(); }
virtual void setGuardBandBias( const Coord2D *gb ) { m_guardBandBias.x = gb->x; m_guardBandBias.y = gb->y; }
private:
CameraClass *m_3DCamera; ///< camera representation for 3D scene
CameraClass *m_2DCamera; ///< camera for UI overlayed on top of 3D scene
enum FilterModes m_viewFilterMode;
enum FilterTypes m_viewFilter;
Bool m_isWireFrameEnabled;
Bool m_nextWireFrameEnabled; ///< used to delay wireframe changes by 1 frame (needed for transitions).
Coord2D m_shakeOffset; ///< the offset to add to the camera position
Real m_shakeAngleCos; ///< the cosine of the orientation of the oscillation
Real m_shakeAngleSin; ///< the sine of the orientation of the oscillation
Real m_shakeIntensity; ///< the intensity of the oscillation
TRotateCameraInfo m_rcInfo;
Bool m_doingRotateCamera; ///< True if we are doing a camera rotate.
TPitchCameraInfo m_pcInfo;
Bool m_doingPitchCamera;
TZoomCameraInfo m_zcInfo;
Bool m_doingZoomCamera;
Bool m_doingScriptedCameraLock; ///< True if we are following a unit via script
Real m_FXPitch; ///< Camera effects pitch. 0 = flat, infinite = look down, 1 = normal.
TMoveAlongWaypointPathInfo m_mcwpInfo; ///< Move camera along waypoint path info.
Bool m_doingMoveCameraOnWaypointPath; ///< If true, moving camera along waypoint path.
Bool m_freezeTimeForCameraMovement;
Int m_timeMultiplier; ///< Time speedup multiplier.
Bool m_cameraHasMovedSinceRequest; ///< If true, throw out all saved locations
VecPosRequests m_locationRequests; ///< These are cached. New requests are added here
Coord3D m_cameraOffset; ///< offset for camera from view center
Coord3D m_previousLookAtPosition; ///< offset for camera from view center
Coord2D m_scrollAmount; ///< scroll speed
Real m_scrollAmountCutoff; ///< scroll speed at which we do not adjust height
Real m_groundLevel; ///< height of ground.
Region2D m_cameraConstraint; ///< m_pos should be constrained to be within this area
Bool m_cameraConstraintValid; ///< if f, recalc cam constraints
void setCameraTransform( void ); ///< set the transform matrix of m_3DCamera, based on m_pos & m_angle
void buildCameraTransform( Matrix3D *transform ) ; ///< calculate (but do not set) the transform matrix of m_3DCamera, based on m_pos & m_angle
void calcCameraConstraints() ; ///< recalc m_cameraConstraint
void moveAlongWaypointPath(Int milliseconds); ///< Move camera along path.
void getPickRay(const ICoord2D *screen, Vector3 *rayStart, Vector3 *rayEnd); ///<returns a line segment (ray) originating at the given screen position
void setupWaypointPath(Bool orient); ///< Calculates distances & angles for moving along a waypoint path.
void rotateCameraOneFrame(void); ///< Do one frame of a rotate camera movement.
void zoomCameraOneFrame(void); ///< Do one frame of a zoom camera movement.
void pitchCameraOneFrame(void); ///< Do one frame of a pitch camera movement.
void getAxisAlignedViewRegion(Region3D &axisAlignedRegion); ///< Find 3D Region enclosing all possible drawables.
void calcDeltaScroll(Coord2D &screenDelta);
}; // end class W3DView
// EXTERNALS //////////////////////////////////////////////////////////////////////////////////////
extern Int TheW3DFrameLengthInMsec; // default is 33msec/frame == 30fps. but we may change it depending on sys config.
#endif // end __W3DVIEW_H_

View file

@ -0,0 +1,194 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DVOLUMETRICSHADOW_H_
#define __W3DVOLUMETRICSHADOW_H_
#include "matrix4.h"
#include "W3DDevice/GameClient/W3DBufferManager.h"
#include "GameClient/Shadow.h"
///@todo Make the 100 below a 'better' number. Was 32, increased because of overcomplex models.
#define MAX_SHADOW_CASTER_MESHES 160 //number of meshes allowed in animated hierarchy (must be <256 since index is a byte).
class W3DShadowGeometry; //forward reference
class W3DShadowGeometryManager; //forward reference
struct Geometry; //forward reference
struct PolyNeighbor; //forward reference
class W3DVolumetricShadow; //forward reference
class Drawable; //forward reference
struct W3DVolumetricShadowRenderTask : public W3DBufferManager::W3DRenderTask
{
W3DVolumetricShadow *m_parentShadow; ///<main casting object to which this volume belongs.
UnsignedByte m_meshIndex; ///<mesh index of volume within parent to render.
UnsignedByte m_lightIndex; ///<light index of volume within parent to render.
};
// ShadowManager -------------------------------------------------------------
class W3DVolumetricShadowManager
{
public:
W3DVolumetricShadowManager( void );
~W3DVolumetricShadowManager( void );
Bool init( void ); ///<initialize resources used by manager, must have valid D3D device.
// shadow list management
void reset( void );
W3DVolumetricShadow* addShadow( RenderObjClass *robj, Shadow::ShadowTypeInfo *shadowInfo, Drawable *draw); ///< adds shadow caster to rendering system.
void removeShadow(W3DVolumetricShadow *shadow); ///< removed shadow from rendering system and frees its resources.
void removeAllShadows(void); ///< Remove all shadows.
/// queues up a dynamic shadow caster for rendering - only used internally by shadow system.
void addDynamicShadowTask(W3DVolumetricShadowRenderTask *task)
{ W3DBufferManager::W3DRenderTask *oldTask=m_dynamicShadowVolumesToRender;
m_dynamicShadowVolumesToRender=task;
m_dynamicShadowVolumesToRender->m_nextTask=oldTask;
}
void invalidateCachedLightPositions(void); ///<forces shadow volumes to update regardless of last lightposition
void loadTerrainShadows(void);
// rendering
void renderShadows( Bool forceStencilFill );
void ReleaseResources(void);
Bool ReAcquireResources(void);
protected:
// to render the stencil buffer polygon to the screen
void renderStencilShadows( void );
W3DVolumetricShadow *m_shadowList;
W3DVolumetricShadowRenderTask *m_dynamicShadowVolumesToRender;
W3DShadowGeometryManager *m_W3DShadowGeometryManager;
}; // end class W3DVolumetricShadowManager
extern W3DVolumetricShadowManager *TheW3DVolumetricShadowManager;
// W3DVolumetricShadow ---------------------------------------------------------------------
class W3DVolumetricShadow : public Shadow
{
friend class W3DVolumetricShadowManager;
enum
{
SHADOW_DYNAMIC = 0x1 //flag indicating a dynamic shadow caster (animated mesh).
};
public:
W3DVolumetricShadow( void );
~W3DVolumetricShadow( void );
protected:
virtual void release(void) {TheW3DVolumetricShadowManager->removeShadow(this);} ///<release shadow from manager
#if defined(_DEBUG) || defined(_INTERNAL)
virtual void getRenderCost(RenderCost & rc) const;
#endif
// tie in geometry and transformation for this shadow
void SetGeometry( W3DShadowGeometry *geometry );
void setShadowLengthScale(Real value) {m_shadowLengthScale = value;}
void updateOptimalExtrusionPadding(void); ///<for immobile objects, figure out the length of extrusion needed to hit ground - expensive!
void setOptimalExtrusionPadding(Real value) {m_extraExtrusionPadding=value;}
const W3DShadowGeometry *getGeometry(void) {return m_geometry;}
void setRenderObject( RenderObjClass *robj) {assert(m_robj==NULL); m_robj=robj;}
void setRenderObjExtent ( Real extent) { m_robjExtent = extent; }
// called once per frame, updates shadow volume when necessary
void Update();
void updateVolumes(Real zoffset); ///<update shadow volumes of all meshes in this model
void updateMeshVolume(Int meshIndex, Int lightIndex, const Matrix3D *meshXform, const AABoxClass &meshBox, float floorZ);///<update shadow volume of this mesh.
// rendering interface
void RenderVolume(Int meshIndex, Int lightIndex); ///<renders a specifc volume from the model hierarchy
///render single mesh which could belong to a larger hierarchy (optimized for static meshes).
void RenderMeshVolume(Int meshIndex, Int lightIndex, const Matrix3D *meshXform);
///render single mesh which could belong to a larger hierarchy (optimized for animated meshes).
void RenderDynamicMeshVolume(Int meshIndex, Int lightIndex, const Matrix3D *meshXform);
void RenderMeshVolumeBounds(Int meshIndex, Int lightIndex, const Matrix3D *meshXform); ///<render bounding volume around shadow volume - for debug use.
void setLightPosHistory(Int lightIndex, Int meshIndex, Vector3 &pos) {m_lightPosHistory[lightIndex][meshIndex]=pos;} ///<updates the last position of light
W3DVolumetricShadow *m_next; /// for the shadow manager list
// silhouette tools
void buildSilhouette(Int meshIndex, Vector3 *lightPosWorld);
void addSilhouetteEdge(Int meshIndex, PolyNeighbor *visible, PolyNeighbor *hidden );
void addNeighborlessEdges(Int meshIndex, PolyNeighbor *us );
void addSilhouetteIndices(Int meshIndex, Short edgeStart, Short edgeEnd );
Bool allocateSilhouette(Int meshIndex, Int numVertices ); // allocate memory for sil
void deleteSilhouette(Int meshIndex ); // resets and frees silhouette memory
void resetSilhouette( Int meshIndex ); // reset silhouette to empty
// shadow volume access
void constructVolume( Vector3 *lightPos, Real shadowExtrudeDistance, Int volumeIndex, Int meshIndex );
void constructVolumeVB( Vector3 *lightPosObject,Real shadowExtrudeDistance, Int volumeIndex, Int meshIndex );
Bool allocateShadowVolume( Int volumeIndex, Int meshIndex ); // allocate mem
void deleteShadowVolume( Int volumeIndex ); // delete all volume data
void resetShadowVolume( Int volumeIndex, Int meshIndex ); // reset shadow volume
// this is our current geometry we will derive the shadow from
W3DShadowGeometry *m_geometry;
RenderObjClass *m_robj; ///<render object belonging to model casting shadow
Real m_shadowLengthScale; ///<scale factor used to reduce/clamp shadow length
Real m_robjExtent; ///<maximum possible horizontal reach of shadow from center of object.
Real m_extraExtrusionPadding; ///<amount to extrude shadow beyond where it would normally stop (ground level below object).
//
// this geometry is our actual shadow volume data, we have an array
// of them so we can have separate shadow volume for each light source
// casting shadows
//
static Geometry m_tempShadowVolume; //scratch buffer to use by all shadows during volume construction.
Geometry *m_shadowVolume[ MAX_SHADOW_LIGHTS ][MAX_SHADOW_CASTER_MESHES];
W3DBufferManager::W3DVertexBufferSlot *m_shadowVolumeVB[ MAX_SHADOW_LIGHTS ][MAX_SHADOW_CASTER_MESHES];
W3DBufferManager::W3DIndexBufferSlot *m_shadowVolumeIB[ MAX_SHADOW_LIGHTS ][MAX_SHADOW_CASTER_MESHES];
W3DVolumetricShadowRenderTask m_shadowVolumeRenderTask[ MAX_SHADOW_LIGHTS ][MAX_SHADOW_CASTER_MESHES];
Int m_shadowVolumeCount[MAX_SHADOW_CASTER_MESHES]; // how man shadows are valid in m_shadowVolume
Vector3 m_lightPosHistory[ MAX_SHADOW_LIGHTS ][MAX_SHADOW_CASTER_MESHES];
Matrix4 m_objectXformHistory[ MAX_SHADOW_LIGHTS ][MAX_SHADOW_CASTER_MESHES];
// silhouette building space
Short *m_silhouetteIndex[MAX_SHADOW_CASTER_MESHES]; // silhouette vertex index list, edges occur
// as disjoint pairs. The acutal size of this
// piece of memory must accomodate #vertices*2
Short m_numSilhouetteIndices[MAX_SHADOW_CASTER_MESHES]; // total number of edge indices in the index
// array, these are pairs and therefore
// always a multiple of two
Short m_maxSilhouetteEntries[MAX_SHADOW_CASTER_MESHES]; // how big the silhouette index can hold max
Int m_numIndicesPerMesh[MAX_SHADOW_CASTER_MESHES]; ///<silhouette indices from each mesh.
}; // end class W3DVolumetricShadow
#endif //__W3DVOLUMETRICSHADOW_H_

View file

@ -0,0 +1,295 @@
/*
** Command & Conquer Generals(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: W3DWater.h ///////////////////////////////////////////////////
#pragma once
#ifndef __W3DWater_H_
#define __W3DWater_H_
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "light.h"
#include "Lib/BaseType.h"
#include "Common/GameType.h"
#include "Common/Snapshot.h"
#define INVALID_WATER_HEIGHT 0.0f ///water height guaranteed to be below all terrain.
#define NUM_BUMP_FRAMES 32 ///number of animation frames in bump map
//Offsets in constant register file to Vertex shader constants
#define CV_ZERO 0
#define CV_ONE 1
#define CV_WORLDVIEWPROJ_0 2
#define CV_TEXPROJ_0 6
#define CV_PATCH_SCALE_OFFSET 10
class PolygonTrigger;
class WaterTracksRenderSystem;
class Xfer;
/// Custom render object that draws mirrors, water, and skies.
/**
This render object handles drawing reflected W3D scenes. It will only work
with rectangular planar surfaces and was tuned with an emphasis on water.
Since skies are only visible in reflections, this code will also
render clouds and sky bodies.
*/
class WaterRenderObjClass : public Snapshot,
public RenderObjClass
{
public:
enum WaterType
{
WATER_TYPE_0_TRANSLUCENT = 0, //translucent water, no reflection
WATER_TYPE_1_FB_REFLECTION, //legacy frame buffer reflection (non translucent)
WATER_TYPE_2_PVSHADER, //pixel/vertex shader, texture reflection
WATER_TYPE_3_GRIDMESH, //3D Mesh based water
WATER_TYPE_MAX // end of enumeration
};
WaterRenderObjClass(void);
~WaterRenderObjClass(void);
/////////////////////////////////////////////////////////////////////////////
// Render Object Interface (W3D methods)
/////////////////////////////////////////////////////////////////////////////
virtual RenderObjClass * Clone(void) const;
virtual int Class_ID(void) const;
virtual void Render(RenderInfoClass & rinfo);
/// @todo: Add methods for collision detection with water surface
// virtual Bool Cast_Ray(RayCollisionTestClass & raytest);
// virtual Bool Cast_AABox(AABoxCollisionTestClass & boxtest);
// virtual Bool Cast_OBBox(OBBoxCollisionTestClass & boxtest);
// virtual Bool Intersect_AABox(AABoxIntersectionTestClass & boxtest);
// virtual Bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest);
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const;
// Get and set static sort level
virtual int Get_Sort_Level(void) const { return m_sortLevel; }
virtual void Set_Sort_Level(int level) { m_sortLevel = level;}
///allocate W3D resources needed to render water
void renderWater(void); ///<draw the water surface (flat)
Int init(Real waterLevel, Real dx, Real dy, SceneClass *parentScene, WaterType type);
void reset( void ); ///< reset any resources we need to
void load(void); ///< load/setup any map dependent features
void update( void ); ///< update phase of the water
void enableWaterGrid(Bool state); ///< used to active custom water for special maps. (i.e DAM).
void setTimeOfDay(TimeOfDay tod); ///<change sky/water for time of day
void toggleCloudLayer(Bool state) { m_useCloudLayer=state;} ///<enables/disables the cloud layer
void updateRenderTargetTextures(CameraClass *cam); ///< renders into any required textures.
void ReleaseResources(void); ///< Release all dx8 resources so the device can be reset.
void ReAcquireResources(void); ///< Reacquire all resources after device reset.
Real getWaterHeight(Real x, Real y); ///<return water height at given point - for use by WB.
void setGridHeightClamps(Real minz, Real maxz); ///<set min/max height values alllowed in grid
void addVelocity( Real worldX, Real worldY, Real zVelocity, Real preferredHeight ); ///< add velocity value
void changeGridHeight(Real x, Real y, Real delta); ///<change height of grid at world point including neighbors within falloff.
void setGridChangeAttenuationFactors(Real a, Real b, Real c, Real range); ///<adjust falloff parameters for grid change method.
void setGridTransform(Real angle, Real x, Real y, Real z); ///<positoin/orientation of grid in space
void setGridTransform(const Matrix3D *transform); ///< set transform by matrix
void getGridTransform(Matrix3D *transform); ///< get grid transform matrix
void setGridResolution(Real gridCellsX, Real gridCellsY, Real cellSize); ///<grid resolution and spacing
void getGridResolution(Real *gridCellsX, Real *gridCellsY, Real *cellSize); ///<get grid resolution params
inline void setGridVertexHeight(Int x, Int y, Real value);
inline void getGridVertexHeight(Int x, Int y, Real *value)
{ if (m_meshData) *value=m_meshData[(y+1)*(m_gridCellsX+1+2)+x+1].height+ Get_Position().Z;}
inline Bool worldToGridSpace(Real worldX, Real worldY, Real &gridX, Real &gridY); ///<convert from world coordinates to grid's local coordinate system.
void replaceSkyboxTexture(const AsciiString& oldTexName, const AsciiString& newTextName);
protected:
DX8IndexBufferClass *m_indexBuffer; ///<indices defining quad
SceneClass *m_parentScene; ///<scene to be reflected
ShaderClass m_shaderClass; ///<shader or rendering state for heightmap
VertexMaterialClass *m_vertexMaterialClass; ///<vertex lighting material
VertexMaterialClass *m_meshVertexMaterialClass; ///<vertex lighting marial for 3D water.
LightClass *m_meshLight; ///<light used for 3D Mesh Water.
TextureClass *m_alphaClippingTexture; ///<used for faked clipping using alpha
Real m_dx; ///<x extent of water surface (offset from local center)
Real m_dy; ///<y extent of water surface (offset from local center)
Vector3 m_planeNormal; ///<water plane normal
Real m_planeDistance; ///<water plane distance
Real m_level; ///<level of water (hack for water)
Real m_uOffset; ///<current texture offset on u axis
Real m_vOffset; ///<current texture offset on v axis
Real m_uScrollPerMs; ///<texels per/ms scroll rate in u direction
Real m_vScrollPerMs; ///<texels per/ms scroll rate in v direction
Int m_LastUpdateTime; ///<time of last cloud update
Bool m_useCloudLayer; ///<flag if clouds are on/off
WaterType m_waterType; ///<type of water being used
Int m_sortLevel; ///<sort order after main scene is rendered
//Data used in GeForce3 bump-mapped water (uses direct D3D resources for better
//performance and compatibility (most of these featues are not supported by W3D).
struct SEA_PATCH_VERTEX //vertex structure passed to D3D
{
float x,y,z;
unsigned int c;
float tu, tv;
};
LPDIRECT3DDEVICE8 m_pDev; ///<pointer to D3D Device
LPDIRECT3DVERTEXBUFFER8 m_vertexBufferD3D; ///<D3D vertex buffer
LPDIRECT3DINDEXBUFFER8 m_indexBufferD3D; ///<D3D index buffer
Int m_vertexBufferD3DOffset; ///<location to start writing vertices
DWORD m_dwWavePixelShader; ///<handle to D3D pixel shader
DWORD m_dwWaveVertexShader; ///<handle to D3D vertex shader
Int m_numVertices; ///<number of vertices in D3D vertex buffer
Int m_numIndices; ///<number of indices in D3D index buffer
LPDIRECT3DTEXTURE8 m_pBumpTexture[NUM_BUMP_FRAMES]; ///<animation frames
LPDIRECT3DTEXTURE8 m_pBumpTexture2[NUM_BUMP_FRAMES]; ///<animation frames
Int m_iBumpFrame; ///<current animation frame
Real m_fBumpScale; ///<scales bump map uv perturbation
TextureClass * m_pReflectionTexture; ///<render target for reflection
RenderObjClass *m_skyBox; ///<box around level
WaterTracksRenderSystem *m_waterTrackSystem; ///<object responsible for rendering water wakes
enum WaterMeshStatus
{
AT_REST = 0x00,
IN_MOTION = 0x01
};
struct WaterMeshData
{
Real height; ///< height of the 3D mesh at this point
Real velocity; ///< velocity in Z that this point is moving up and down
UnsignedByte status; ///< status for this grid point
UnsignedByte preferredHeight; ///< the hight we prefer to be
};
WaterMeshData *m_meshData; ///< heightmap data for 3D Mesh based water.
UnsignedInt m_meshDataSize; ///< size of m_meshData
Bool m_meshInMotion; ///< TRUE once we've messed with velocities and are in motion
Bool m_doWaterGrid; ///< allows/prevents water grid rendering.
Vector2 m_gridDirectionX; ///<vector along water grid's x-axis (scaled to world-space)
Vector2 m_gridDirectionY; ///<vector along water grid's y-axis (scaled to world-space)
Vector2 m_gridOrigin; ///<unit vector along water grid's x-axis
Real m_gridWidth; ///<object-space width of water grid
Real m_gridHeight; ///<object-space width of water grid
Real m_minGridHeight; ///<minimum height value allowed for water mesh
Real m_maxGridHeight; ///<maximum height value allowed for water mesh
Real m_gridChangeMaxRange; ///<maximum range of changeGridHeight() method
Real m_gridChangeAtt0;
Real m_gridChangeAtt1;
Real m_gridChangeAtt2;
Real m_gridCellSize; ///<world-space width/height of each cell.
Int m_gridCellsX; ///<number of cells along width
Int m_gridCellsY; ///<number of cells along height
Real m_riverVOrigin;
TextureClass *m_riverTexture;
TextureClass *m_whiteTexture; ///< a texture containing only white used for NULL pixel shader stages.
TextureClass *m_waterNoiseTexture;
DWORD m_waterPixelShader; ///<D3D handle to pixel shader.
DWORD m_riverWaterPixelShader; ///<D3D handle to pixel shader.
DWORD m_trapezoidWaterPixelShader; ///<handle to D3D vertex shader
TextureClass *m_waterSparklesTexture;
Real m_riverXOffset;
Real m_riverYOffset;
Bool m_drawingRiver;
Bool m_disableRiver;
TextureClass *m_riverAlphaEdge;
TimeOfDay m_tod; ///<time of day setting for reflected cloud layer
struct Setting
{
TextureClass *skyTexture;
TextureClass *waterTexture;
Int waterRepeatCount;
Real skyTexelsPerUnit; //texel density of sky plane (higher value repeats texture more).
DWORD vertex00Diffuse;
DWORD vertex10Diffuse;
DWORD vertex11Diffuse;
DWORD vertex01Diffuse;
DWORD waterDiffuse;
DWORD transparentWaterDiffuse;
Real uScrollPerMs;
Real vScrollPerMs;
};
Setting m_settings[ TIME_OF_DAY_COUNT ]; ///< settings for each time of day
void drawRiverWater(PolygonTrigger *pTrig);
void drawTrapezoidWater(Vector3 points[4]);
void loadSetting ( Setting *skySetting, TimeOfDay timeOfDay ); ///<init sky/water settings from GDF
void renderSky(void); ///<draw the sky layer (clouds, stars, etc.)
void testCurvedWater(void); ///<draw the sky layer (clouds, stars, etc.)
void renderSkyBody(Matrix3D *mat); ///<draw the sky body (sun, moon, etc.)
void renderWaterMesh(void); ///<draw the water surface mesh (deformed 3d mesh).
HRESULT initBumpMap(LPDIRECT3DTEXTURE8 *pTex, TextureClass *pBumpSource); ///<copies data into bump-map format.
void renderMirror(CameraClass *cam); ///< Draw reflected scene into texture
void drawSea(RenderInfoClass & rinfo); ///< Draw the surface of the water
///bounding box of frustum clipped polygon plane
Bool getClippedWaterPlane(CameraClass *cam, AABoxClass *box);
void setupFlatWaterShader(void);
void setupJbaWaterShader(void);
void cleanupJbaWaterShader(void);
//Methods used for GeForce3 specific water
HRESULT WaterRenderObjClass::generateIndexBuffer(int sizeX, int sizeY); ///<Generate static index buufer
HRESULT WaterRenderObjClass::generateVertexBuffer( Int sizeX, Int sizeY, Int vertexSize, Bool doFill);///<Generate static vertex buffer
// snapshot methods for save/load
virtual void crc( Xfer *xfer );
virtual void xfer( Xfer *xfer );
virtual void loadPostProcess( void );
};
//Public inline function declerations
inline Bool WaterRenderObjClass::worldToGridSpace(Real worldX, Real worldY, Real &gridX, Real &gridY)
{
Real dx,dy;
Real ooGridCellSize = 1.0f/m_gridCellSize;
dx=worldX - m_gridOrigin.X;
dy=worldY - m_gridOrigin.Y;
gridX = ooGridCellSize * (dx * m_gridDirectionX.X + dy * m_gridDirectionX.Y);
gridY = ooGridCellSize * (dx * m_gridDirectionY.X + dy * m_gridDirectionY.Y);
if (gridX < 0)
return FALSE;
if (gridX > m_gridCellsX-1 )
return FALSE;
if (gridY < 0)
return FALSE;
if (gridY > m_gridCellsY-1 )
return FALSE;
return TRUE;
}
extern WaterRenderObjClass *TheWaterRenderObj; ///<global water rendering object
#endif // end __W3DWater_H_

View file

@ -0,0 +1,146 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DWaterTracks_H_
#define __W3DWaterTracks_H_
enum waveType; //forward reference
/// Custom render object that draws animated tracks/waves on the water.
/**
This is an object which draws a small breaking wave or splash animation. These objects are
to be managed/accessed only by the WaterTracksRenderObjClassSystem
*/
class WaterTracksObj
{
friend class WaterTracksRenderSystem;
public:
WaterTracksObj(void);
~WaterTracksObj(void);
virtual void Render(void) {}; ///<draw this object
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const; ///<bounding sphere of this object
virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const; ///<bounding box of this object
Int freeWaterTracksResources(void); ///<free W3D assets used for this track
void init( Real width, Real length, Vector2 &start, Vector2 &end, Char *texturename, Int waveTimeOffset); ///<allocate W3D resources and set size
void init( Real width, Vector2 &start, Vector2 &end, Char *texturename); ///<allocate W3D resources and set size
Int update(Int msElapsed); ///< update animation state
Int render(DX8VertexBufferClass *vertexBuffer, Int batchStart); ///<draw this object
protected:
TextureClass *m_stageZeroTexture; ///<primary texture
SphereClass m_boundingSphere; ///<bounding sphere of WaterTracks
AABoxClass m_boundingBox; ///<bounding box of WaterTracks
waveType m_type; ///<used for render state sorting (set this to texture pointer for now).
Int m_x; ///<vertex count
Int m_y; ///<vertex count
Bool m_bound; ///<object is bound to owner and accepts new edges
Vector2 m_startPos; ///<starting position of wave
// Vector2 m_endPos; ///<ending position of wave
Vector2 m_waveDir; ///<direction of wave travel
Vector2 m_perpDir; ///<direction perpendicular to wave travel
Vector2 m_initStartPos; ///<original settings used to create wave
Vector2 m_initEndPos; ///<original settings used to create wave
Int m_initTimeOffset; ///<time offset when wave is added into the system
Int m_fadeMs; ///<time for wave to fade out after it stops moving
Int m_totalMs; ///<amount of time to complete full motion
Int m_elapsedMs; ///<amount of time since start of motion
//New version
Real m_waveInitialWidth; ///<width of wave segment when it first appears
Real m_waveInitialHeight; ///<height of wave segment when it first appears
Real m_waveFinalWidth; ///<width of wave segment at full size
Real m_waveFinalWidthPeakFrac; ///<fraction along path when wave reaches full width
Real m_waveFinalHeight; ///<final height of unstretched wave
Real m_initialVelocity; //initial velocity in world units per ms.
Real m_waveDistance; //<total distance traveled by wave front.
Real m_timeToReachBeach;
Real m_frontSlowDownAcc;
Real m_timeToStop;
Real m_timeToRetreat;
Real m_backSlowDownAcc;
Real m_timeToCompress;
Real m_flipU; ///<force uv coordinates to flip
WaterTracksObj *m_nextSystem; ///<next track in system
WaterTracksObj *m_prevSystem; ///<previous track in system
};
/// System for drawing, updating, and re-using water mark render objects.
/**
This system keeps track of all the active track mark objects and reuses them
when they expire. It also renders all the track marks that were submitted in
this frame.
*/
class WaterTracksRenderSystem
{
friend class WaterTracksObj;
public:
WaterTracksRenderSystem( void );
~WaterTracksRenderSystem( void );
void ReleaseResources(void); ///< Release all dx8 resources so the device can be reset.
void ReAcquireResources(void); ///< Reacquire all resources after device reset.
void flush (RenderInfoClass & rinfo); ///<draw all tracks that were requested for rendering.
void update(void); ///<update the state of all edges (fade alpha, remove old, etc.)
void init(void); ///< pre-allocate track objects
void shutdown( void ); ///< release all pre-allocated track objects, called by destructor
void reset(void); ///< free all map dependent items.
WaterTracksObj *bindTrack(waveType type); ///<track object to be controlled by owner
void unbindTrack( WaterTracksObj *mod ); ///<releases control of track object
void saveTracks(void); ///<save all used tracks to disk
void loadTracks(void); ///<load tracks from disk
WaterTracksObj *findTrack(Vector2 &start, Vector2 &end, waveType type);
protected:
DX8VertexBufferClass *m_vertexBuffer; ///<vertex buffer used to draw all tracks
DX8IndexBufferClass *m_indexBuffer; ///<indices defining triangles in maximum length track
VertexMaterialClass *m_vertexMaterialClass; ///< vertex lighting material
ShaderClass m_shaderClass; ///<shader or rendering state for heightmap
WaterTracksObj *m_usedModules; ///<active objects being rendered in the scene
WaterTracksObj *m_freeModules; //<unused modules that are free to use again
Int m_stripSizeX; ///< resolution (vertex count) of wave strip
Int m_stripSizeY; ///< resolution (vertex count) of wave strip
Int m_batchStart; ///< start of unused vertices in vertex buffer
Real m_level; ///< water level
void releaseTrack( WaterTracksObj *mod ); ///<returns track object to free store.
}; // end class WaterTracksRenderObjClassSystem
#endif //__W3DWaterTracks_H_

View file

@ -0,0 +1,89 @@
/*
** Command & Conquer Generals(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: W3DWaypointBuffer.h ////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Electronic Arts Pacific.
//
// Confidential Information
// Copyright (C) 2002 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: Command & Conquers: Generals
//
// File name: W3DWaypointBuffer.h
//
// Created: Kris Morness, October 2002
//
// Desc: Draw buffer to handle all the waypoints in the scene. Waypoints
// are rendered after terrain, after roads & bridges, and after
// global fog, but before structures, objects, units, trees, etc.
// This way if we have two waypoints at the bottom of a hill but
// going through the hill, the line won't get cut off. However,
// structures and units on top of paths will render above it. Waypoints
// are only shown for selected units while in waypoint plotting mode.
//
//-----------------------------------------------------------------------------
#pragma once
#ifndef __W3D_WAYPOINT_BUFFER_H
#define __W3D_WAYPOINT_BUFFER_H
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#include "common/GameType.h"
class SegmentedLineClass;
class W3DWaypointBuffer
{
friend class HeightMapRenderObjClass;
public:
W3DWaypointBuffer(void);
~W3DWaypointBuffer(void);
void drawWaypoints(RenderInfoClass &rinfo);
void freeWaypointBuffers();
private:
RenderObjClass *m_waypointNodeRobj;
SegmentedLineClass *m_line;
TextureClass *m_texture;
};
#endif // end __W3D_WAYPOINT_BUFFER_H

View file

@ -0,0 +1,49 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
///// W3DWebBrowser.h ////////////////////////
// July 2002, Bryan Cleveland
#pragma once
#ifndef W3DWEBBROWSER_H
#define W3DWEBBROWSER_H
#include "GameNetwork/WOLBrowser/WebBrowser.h"
class TextureClass;
class Image;
class GameWindow;
class W3DWebBrowser : public WebBrowser
{
public:
W3DWebBrowser();
virtual Bool createBrowserWindow(char *url, GameWindow *win);
virtual void closeBrowserWindow(GameWindow *win);
};
#endif // #ifndef W3DWEBBROWSER_H

View file

@ -0,0 +1,281 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
// WorldHeightMap.h
// Class to encapsulate height map.
// Author: John Ahlquist, April 2001
#pragma once
#ifndef WorldHeightMap_H
#define WorldHeightMap_H
#include "Lib/BaseType.h"
#include "WWLib/RefCount.h"
#include "WWMath/Vector3.h"
#include "W3DDevice/GameClient/TileData.h"
#include "../../gameengine/include/common/MapObject.h"
#include "Common/STLTypedefs.h"
typedef std::vector<ICoord2D> VecICoord2D;
/** MapObject class
Not ref counted. Do not store pointers to this class. */
#define K_MIN_HEIGHT 0
#define K_MAX_HEIGHT 255
#define NUM_SOURCE_TILES 1024
#define NUM_BLEND_TILES 16192
#define NUM_CLIFF_INFO 32384
#define FLAG_VAL 0x7ADA0000
// For backwards compatiblity.
#define TEX_PATH_LEN 256
/// Struct in memory.
typedef struct {
Int globalTextureClass;
Int firstTile;
Int numTiles;
Int width;
Int isBlendEdgeTile; ///< True if the texture contains blend edges.
AsciiString name;
ICoord2D positionInTexture;
} TXTextureClass;
typedef enum {POS_X, POS_Y, NEG_X, NEG_Y} TVDirection;
/// Struct in memory.
typedef struct {
Real u0, v0; // Upper left uv
Real u1, v1; // Lower left uv
Real u2, v2; // Lower right uv
Real u3, v3; // Upper right uv
Bool flip;
Bool mutant; // Mutant mapping needed to get this to fit.
Short tileIndex; // Tile texture.
} TCliffInfo;
#define NUM_TEXTURE_CLASSES 256
class TextureClass;
class ChunkInputStream;
class InputStream;
class OutputStream;
class DataChunkInput;
struct DataChunkInfo;
class AlphaEdgeTextureClass;
class WorldHeightMap : public RefCountClass
{
friend class TerrainTextureClass;
friend class AlphaTerrainTextureClass;
friend class W3DCustomEdging;
friend class AlphaEdgeTextureClass;
#define NO_EVAL_TILING_MODES
public:
#ifdef EVAL_TILING_MODES
enum {TILE_4x4, TILE_6x6, TILE_8x8} m_tileMode;
#endif
enum {
NORMAL_DRAW_WIDTH = 129,
NORMAL_DRAW_HEIGHT = 129,
STRETCH_DRAW_WIDTH = 65,
STRETCH_DRAW_HEIGHT = 65
};
protected:
Int m_width; ///< Height map width.
Int m_height; ///< Height map height (y size of array).
Int m_borderSize; ///< Non-playable border area.
VecICoord2D m_boundaries; ///< the in-game boundaries
Int m_dataSize; ///< size of m_data.
UnsignedByte *m_data; ///< array of z(height) values in the height map.
UnsignedByte *m_cellFlipState; ///< array of bits to indicate the flip state of each cell.
Int m_flipStateWidth; ///< with of the array holding cellFlipState
UnsignedByte *m_cellCliffState; ///< array of bits to indicate the cliff state of each cell.
/// Texture indices.
Short *m_tileNdxes; ///< matches m_Data, indexes into m_SourceTiles.
Short *m_blendTileNdxes; ///< matches m_Data, indexes into m_blendedTiles. 0 means no blend info.
Short *m_cliffInfoNdxes; ///< matches m_Data, indexes into m_cliffInfo. 0 means no cliff info.
Short *m_extraBlendTileNdxes; ///< matches m_Data, indexes into m_extraBlendedTiles. 0 means no blend info.
Int m_numBitmapTiles; // Number of tiles initialized from bitmaps in m_SourceTiles.
Int m_numEdgeTiles; // Number of tiles initialized from bitmaps in m_SourceTiles.
Int m_numBlendedTiles; // Number of blended tiles created from bitmap tiles.
TileData *m_sourceTiles[NUM_SOURCE_TILES]; ///< Tiles for m_textureClasses
TileData *m_edgeTiles[NUM_SOURCE_TILES]; ///< Tiles for m_textureClasses
TBlendTileInfo m_blendedTiles[NUM_BLEND_TILES];
TBlendTileInfo m_extraBlendedTiles[NUM_BLEND_TILES];
TCliffInfo m_cliffInfo[NUM_CLIFF_INFO];
Int m_numCliffInfo; ///< Number of cliffInfo's used in m_cliffInfo.
// Texture classes. There is one texture class for each bitmap read in.
// A class may have more than one tile. For example, if the grass bitmap is
// 128x128, it creates 4 64x64 tiles, so the grass texture class will have 4 tiles.
int m_numTextureClasses;
TXTextureClass m_textureClasses[NUM_TEXTURE_CLASSES];
// Edge Texture classes. There is one texture class for each bitmap read in.
// An edge class will normally have 4 tiles.
int m_numEdgeTextureClasses;
TXTextureClass m_edgeTextureClasses[NUM_TEXTURE_CLASSES];
/** The actual texture used to render the 3d mesh. Note that it is
basically m_SourceTiles laid out in rows, so by itself it is not useful.
Use GetUVData to get the mapping info for height cells to map into the
texture. */
TerrainTextureClass *m_terrainTex;
Int m_terrainTexHeight; /// Height of m_terrainTex allocated.
/** The texture that contains the alpha edge tiles that get blended on
top of the base texture. getAlphaUVData does the mapping. */
AlphaTerrainTextureClass *m_alphaTerrainTex;
Int m_alphaTexHeight; /// Height of m_alphaTerrainTex allocated.
/** The texture that contains custom blend edge tiles. */
AlphaEdgeTextureClass *m_alphaEdgeTex;
Int m_alphaEdgeHeight; /// Height of m_alphaEdgeTex allocated.
/// Drawing info - re the part of the map that is being drawn.
Int m_drawOriginX;
Int m_drawOriginY;
Int m_drawWidthX;
Int m_drawHeightY;
protected:
TileData *getSourceTile(UnsignedInt ndx) { if (ndx<NUM_SOURCE_TILES) return(m_sourceTiles[ndx]); return(NULL); };
TileData *getEdgeTile(UnsignedInt ndx) { if (ndx<NUM_SOURCE_TILES) return(m_edgeTiles[ndx]); return(NULL); };
static Bool readTiles(InputStream *pStrm, TileData **tiles, Int numRows);
static Int countTiles(InputStream *pStrm);
/// UV mapping data for a cell to map into the terrain texture.
void getUVForNdx(Int ndx, float *minU, float *minV, float *maxU, float*maxV, Bool fullTile);
Bool getUVForTileIndex(Int ndx, Short tileNdx, float U[4], float V[4], Bool fullTile);
Int getTextureClassFromNdx(Int tileNdx);
void readTexClass(TXTextureClass *texClass, TileData **tileData);
Int updateTileTexturePositions(Int *edgeHeight); ///< Places each tile in the texture.
void initCliffFlagsFromHeights(void);
void setCellCliffFlagFromHeights(Int xIndex, Int yIndex);
protected: // file reader callbacks.
static Bool ParseHeightMapDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
Bool ParseHeightMapData(DataChunkInput &file, DataChunkInfo *info, void *userData);
static Bool ParseSizeOnlyInChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
Bool ParseSizeOnly(DataChunkInput &file, DataChunkInfo *info, void *userData);
static Bool ParseBlendTileDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
Bool ParseBlendTileData(DataChunkInput &file, DataChunkInfo *info, void *userData);
static Bool ParseWorldDictDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
static Bool ParseObjectsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
static Bool ParseObjectDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
Bool ParseObjectData(DataChunkInput &file, DataChunkInfo *info, void *userData, Bool readDict);
static Bool ParseLightingDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
protected:
WorldHeightMap(void); ///< Simple constructor for WorldHeightMapEdit class.
public: // constructors/destructors
WorldHeightMap(ChunkInputStream *pFile, Bool bHMapOnly=false); // read from file.
~WorldHeightMap(void); // destroy.
public: // Boundary info
const VecICoord2D& getAllBoundaries(void) const { return m_boundaries; }
public: // height map info.
static Int getMinHeightValue(void) {return K_MIN_HEIGHT;}
static Int getMaxHeightValue(void) {return K_MAX_HEIGHT;}
UnsignedByte *getDataPtr(void) {return m_data;}
Int getXExtent(void) {return m_width;} ///<number of vertices in x
Int getYExtent(void) {return m_height;} ///<number of vertices in y
inline Int getDrawOrgX(void) {return m_drawOriginX;}
inline Int getDrawOrgY(void) {return m_drawOriginY;}
inline Int getDrawWidth(void) {return m_drawWidthX;}
inline Int getDrawHeight(void) {return m_drawHeightY;}
inline void setDrawWidth(Int width) {m_drawWidthX = width; if (m_drawWidthX>m_width) m_drawWidthX = m_width;}
inline void setDrawHeight(Int height) {m_drawHeightY = height; if (m_drawHeightY>m_height) m_drawHeightY = m_height;}
inline Int getBorderSize(void) {return m_borderSize;}
/// Get height with the offset that HeightMapRenderObjClass uses built in.
inline UnsignedByte getDisplayHeight(Int x, Int y) { return m_data[x+m_drawOriginX+m_width*(y+m_drawOriginY)];}
/// Get height in normal coordinates.
inline UnsignedByte getHeight(Int xIndex, Int yIndex)
{
Int ndx = (yIndex*m_width)+xIndex;
if ((ndx>=0) && (ndx<m_dataSize) && m_data)
return(m_data[ndx]);
else
return(0);
};
void getUVForBlend(Int edgeClass, Region2D *range);
Bool setDrawOrg(Int xOrg, Int yOrg);
static void freeListOfMapObjects(void);
Int getTextureClassNoBlend(Int xIndex, Int yIndex, Bool baseClass=false);
Int getTextureClass(Int xIndex, Int yIndex, Bool baseClass=false);
TXTextureClass getTextureFromIndex( Int textureIndex );
public: // tile and texture info.
TextureClass *getTerrainTexture(void); //< generates if needed and returns the terrain texture
TextureClass *getAlphaTerrainTexture(void); //< generates if needed and returns alpha terrain texture
TextureClass *getEdgeTerrainTexture(void); //< generates if needed and returns blend edge texture
/// UV mapping data for a cell to map into the terrain texture. Returns true if the textures had to be stretched for cliffs.
Bool getUVData(Int xIndex, Int yIndex, float U[4], float V[4], Bool fullTile);
Bool getFlipState(Int xIndex, Int yIndex) const;
Bool getCliffState(Int xIndex, Int yIndex) const;
Bool getExtraAlphaUVData(Int xIndex, Int yIndex, float U[4], float V[4], UnsignedByte alpha[4], Bool *flip, Bool *cliff);
/// UV mapping data for a cell to map into the alpha terrain texture.
void getAlphaUVData(Int xIndex, Int yIndex, float U[4], float V[4], UnsignedByte alpha[4], Bool *flip, Bool fullTile);
void getTerrainColorAt(Real x, Real y, RGBColor *pColor);
AsciiString getTerrainNameAt(Real x, Real y);
Bool isCliffMappedTexture(Int xIndex, Int yIndex);
public: // modify height value
void setRawHeight(Int xIndex, Int yIndex, UnsignedByte height) {
Int ndx = (yIndex*m_width)+xIndex;
if ((ndx>=0) && (ndx<m_dataSize) && m_data) m_data[ndx]=height;
};
protected:
void setCliffState(Int xIndex, Int yIndex, Bool state);
};
#endif

View file

@ -0,0 +1,69 @@
/*
** Command & Conquer Generals(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: W3DGameLogic.h ///////////////////////////////////////////////////////
//
// W3D game logic class, there shouldn't be a lot of new functionality
// in this class, but there are certain things that need to have close
// knowledge of each other like ther logical and visual terrain
//
// Author: Colin Day, April 2001
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DGAMELOGIC_H_
#define __W3DGAMELOGIC_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GameLogic/GameLogic.h"
#include "W3DDevice/GameLogic/W3DTerrainLogic.h"
#include "W3DDevice/GameLogic/W3DGhostObject.h"
class W3DGhostObjectManager;
///////////////////////////////////////////////////////////////////////////////
// PROTOTYPES /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// W3DGameLogic
//-----------------------------------------------------------------------------
/** W3D specific functionality for game logic */
//-----------------------------------------------------------------------------
class W3DGameLogic : public GameLogic
{
public:
protected:
/// factory for TheTerrainLogic, called from init()
virtual TerrainLogic *createTerrainLogic( void ) { return NEW W3DTerrainLogic; };
virtual GhostObjectManager *createGhostObjectManager(void) { return NEW W3DGhostObjectManager; }
}; // end class W3DGameLogic
#endif // end __W3DGAMELOGIC_H_

View file

@ -0,0 +1,96 @@
/*
** Command & Conquer Generals(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: W3DGhostObject.h ////////////////////////////////////////////////////////////
// Placeholder for objects that have been deleted but need to be maintained because
// a player can see them fogged.
// Author: Mark Wilczynski, August 2002
#pragma once
#ifndef _W3DGHOSTOBJECT_H_
#define _W3DGHOSTOBJECT_H_
#include "GameLogic/GhostObject.h"
#include "Lib/BaseType.h"
#include "Common/GameCommon.h"
#include "GameClient/DrawableInfo.h"
class Object;
class W3DGhostObjectManager;
class W3DRenderObjectSnapshot;
class PartitionData;
class W3DGhostObject: public GhostObject
{
friend W3DGhostObjectManager;
public:
W3DGhostObject();
virtual ~W3DGhostObject();
virtual void snapShot(int playerIndex);
virtual void updateParentObject(Object *object, PartitionData *mod);
virtual void freeSnapShot(int playerIndex);
protected:
virtual void crc( Xfer *xfer);
virtual void xfer( Xfer *xfer );
virtual void loadPostProcess( void );
void removeParentObject(void);
void restoreParentObject(void); ///< restore the original non-ghosted object to scene.
void addToScene(int playerIndex);
void removeFromScene(int playerIndex);
void release(void); ///< used by manager to return object to free store.
void getShroudStatus(int playerIndex); ///< used to get the partition manager to update ghost objects without parent objects.
void freeAllSnapShots(void); ///< used to free all snapshots from all players.
W3DRenderObjectSnapshot *m_parentSnapshots[MAX_PLAYER_COUNT];
DrawableInfo m_drawableInfo;
///@todo this list should really be part of the device independent base class (CBD 12-3-2002)
W3DGhostObject *m_nextSystem;
W3DGhostObject *m_prevSystem;
};
class W3DGhostObjectManager : public GhostObjectManager
{
public:
W3DGhostObjectManager();
virtual ~W3DGhostObjectManager();
virtual void reset(void);
virtual GhostObject *addGhostObject(Object *object, PartitionData *pd);
virtual void removeGhostObject(GhostObject *mod);
virtual void setLocalPlayerIndex(int index);
virtual void updateOrphanedObjects(int *playerIndexList, int numNonLocalPlayers);
virtual void W3DGhostObjectManager::releasePartitionData(void);
virtual void W3DGhostObjectManager::restorePartitionData(void);
protected:
virtual void crc( Xfer *xfer );
virtual void xfer( Xfer *xfer );
virtual void loadPostProcess( void );
///@todo this list should really be part of the device independent base class (CBD 12-3-2002)
W3DGhostObject *m_freeModules;
W3DGhostObject *m_usedModules;
};
#endif // _W3DGHOSTOBJECT_H_

View file

@ -0,0 +1,85 @@
/*
** Command & Conquer Generals(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: W3DTerrainLogic.h ////////////////////////////////////////////////////////////////////////
// W3D implementation details for logical terrain
// Author: Colin Day, April 2001
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __W3DTERRAINLOGIC_H_
#define __W3DTERRAINLOGIC_H_
#include "GameLogic/TerrainLogic.h"
//-------------------------------------------------------------------------------------------------
/** W3D specific implementation details for logical terrain ... we have this
* because the logic and visual terrain are closely tied together in that
* they represent the same thing, but need to be broken up into logical
* and graphical representations */
//-------------------------------------------------------------------------------------------------
class W3DTerrainLogic : public TerrainLogic
{
public:
W3DTerrainLogic();
virtual ~W3DTerrainLogic();
virtual void init( void ); ///< Init
virtual void reset( void ); ///< Reset
virtual void update( void ); ///< Update
/// @todo The loading of the raw height data should be device independent
virtual Bool loadMap( AsciiString filename , Bool query );
virtual void newMap( Bool saveGame ); ///< Initialize the logic for new map.
virtual Real getGroundHeight( Real x, Real y, Coord3D* normal = NULL ) const;
virtual Bool isCliffCell( Real x, Real y) const; ///< is point cliff cell.
virtual Real getLayerHeight(Real x, Real y, PathfindLayerEnum layer, Coord3D* normal = NULL, Bool clip = true) const;
virtual void getExtent( Region3D *extent ) const ; ///< Get the 3D extent of the terrain in world coordinates
virtual void getMaximumPathfindExtent( Region3D *extent ) const;
virtual void getExtentIncludingBorder( Region3D *extent ) const;
virtual Bool isClearLineOfSight(const Coord3D& pos, const Coord3D& posOther) const;
protected:
// snapshot methods
virtual void crc( Xfer *xfer );
virtual void xfer( Xfer *xfer );
virtual void loadPostProcess( void );
Real m_mapMinZ; ///< Minimum terrain z value.
Real m_mapMaxZ; ///< Maximum terrain z value.
}; // end W3DTerrainLogic
#endif // end __W3DTERRAINLOGIC_H_

View file

@ -0,0 +1,58 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
/////// Win32BIGFile.h ////////////////////////////////////
// Bryan Cleveland, August 2002
///////////////////////////////////////////////////////////
#pragma once
#ifndef __WIN32BIGFILE_H
#define __WIN32BIGFILE_H
#include "Common/ArchiveFile.h"
#include "Common/AsciiString.h"
#include "Common/List.h"
class Win32BIGFile : public ArchiveFile
{
public:
Win32BIGFile();
virtual ~Win32BIGFile();
virtual Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const; ///< fill in the fileInfo struct with info about the requested file.
virtual File* openFile( const Char *filename, Int access = 0 );///< Open the specified file within the BIG file
virtual void closeAllFiles( void ); ///< Close all file opened in this BIG file
virtual AsciiString getName( void ); ///< Returns the name of the BIG file
virtual AsciiString getPath( void ); ///< Returns full path and name of BIG file
virtual void setSearchPriority( Int new_priority ); ///< Set this BIG file's search priority
virtual void close( void ); ///< Close this BIG file
protected:
AsciiString m_name; ///< BIG file name
AsciiString m_path; ///< BIG file path
};
#endif // __WIN32BIGFILE_H

View file

@ -0,0 +1,60 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
//////// Win32BIGFileSystem.h ///////////////////////////
// Bryan Cleveland, August 2002
/////////////////////////////////////////////////////////////
#pragma once
#ifndef __WIN32BIGFILESYSTEM_H
#define __WIN32BIGFILESYSTEM_H
#include "Common/ArchiveFileSystem.h"
class Win32BIGFileSystem : public ArchiveFileSystem
{
public:
Win32BIGFileSystem();
virtual ~Win32BIGFileSystem();
virtual void init( void );
virtual void update( void );
virtual void reset( void );
virtual void postProcessLoad( void );
// ArchiveFile operations
virtual void closeAllArchiveFiles( void ); ///< Close all Archivefiles currently open
// File operations
virtual ArchiveFile * openArchiveFile(const Char *filename);
virtual void closeArchiveFile(const Char *filename);
virtual void closeAllFiles( void ); ///< Close all files associated with ArchiveFiles
virtual Bool loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite = FALSE);
protected:
};
#endif // __WIN32BIGFILESYSTEM_H

View file

@ -0,0 +1,109 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//----------------------------------------------------------------------------
//
// Project: Generals
//
// Module: Game Engine DEvice Win32 Common
//
// File name: Win32Device/Common/Win32CDManager.h
//
// Created: 11/26/01 TR
//
//----------------------------------------------------------------------------
#pragma once
#ifndef _WIN32DEVICE_COMMON_WIN32CDMANAGER_H_
#define _WIN32DEVICE_COMMON_WIN32CDMANAGER_H_
//----------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------
#include "Common/CDManager.h"
//----------------------------------------------------------------------------
// Forward References
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// Type Defines
//----------------------------------------------------------------------------
//===============================
// Win32CDDrive
//===============================
class Win32CDDrive : public CDDrive
{
public:
Win32CDDrive();
virtual ~Win32CDDrive();
virtual void refreshInfo( void ); ///< Update drive with least
};
//===============================
// Win32CDManager
//===============================
class Win32CDManager : public CDManager
{
public:
Win32CDManager();
virtual ~Win32CDManager();
// sub system operations
virtual void init( void );
virtual void update( void );
virtual void reset( void );
virtual void refreshDrives( void ); ///< Refresh drive info
protected:
virtual CDDriveInterface* createDrive( void );
};
//----------------------------------------------------------------------------
// Inlining
//----------------------------------------------------------------------------
#endif // _WIN32DEVICE_COMMON_WIN32CDMANAGER_H_

View file

@ -0,0 +1,107 @@
/*
** Command & Conquer Generals(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: Win32GameEngine.h ////////////////////////////////////////////////////////////////////////
// Author: Colin Day, April 2001
// Description:
// Device implementation of the game engine ... this is, of course, the
// highest level of the game that creates the necessary interfaces to the
// devices we need
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __WIN32GAMEENGINE_H_
#define __WIN32GAMEENGINE_H_
#include "Common/GameEngine.h"
#include "GameLogic/GameLogic.h"
#include "GameNetwork/NetworkInterface.h"
#include "MilesAudioDevice/MilesAudioManager.h"
#include "Win32Device/Common/Win32BIGFileSystem.h"
#include "Win32Device/Common/Win32LocalFileSystem.h"
#include "W3DDevice/Common/W3DModuleFactory.h"
#include "W3DDevice/GameLogic/W3DGameLogic.h"
#include "W3DDevice/GameClient/W3DGameClient.h"
#include "W3DDevice/GameClient/W3DWebBrowser.h"
#include "W3DDevice/Common/W3DFunctionLexicon.h"
#include "W3DDevice/Common/W3DRadar.h"
#include "W3DDevice/Common/W3DFunctionLexicon.h"
#include "W3DDevice/Common/W3DThingFactory.h"
//-------------------------------------------------------------------------------------------------
/** Class declaration for the Win32 game engine */
//-------------------------------------------------------------------------------------------------
class Win32GameEngine : public GameEngine
{
public:
Win32GameEngine();
virtual ~Win32GameEngine();
virtual void init( void ); ///< initialization
virtual void reset( void ); ///< reset engine
virtual void update( void ); ///< update the game engine
virtual void serviceWindowsOS( void ); ///< allow windows maintenance in background
protected:
virtual GameLogic *createGameLogic( void ); ///< factory for game logic
virtual GameClient *createGameClient( void ); ///< factory for game client
virtual ModuleFactory *createModuleFactory( void ); ///< factory for creating modules
virtual ThingFactory *createThingFactory( void ); ///< factory for the thing factory
virtual FunctionLexicon *createFunctionLexicon( void ); ///< factory for function lexicon
virtual LocalFileSystem *createLocalFileSystem( void ); ///< factory for local file system
virtual ArchiveFileSystem *createArchiveFileSystem( void ); ///< factory for archive file system
virtual NetworkInterface *createNetwork( void ); ///< Factory for the network
virtual Radar *createRadar( void ); ///< Factory for radar
virtual WebBrowser *createWebBrowser( void ); ///< Factory for embedded browser
virtual AudioManager *createAudioManager( void ); ///< Factory for audio device
virtual ParticleSystemManager* createParticleSystemManager( void );
protected:
UINT m_previousErrorMode;
}; // end Win32GameEngine
// INLINE -----------------------------------------------------------------------------------------
inline GameLogic *Win32GameEngine::createGameLogic( void ) { return NEW W3DGameLogic; }
inline GameClient *Win32GameEngine::createGameClient( void ) { return NEW W3DGameClient; }
inline ModuleFactory *Win32GameEngine::createModuleFactory( void ) { return NEW W3DModuleFactory; }
inline ThingFactory *Win32GameEngine::createThingFactory( void ) { return NEW W3DThingFactory; }
inline FunctionLexicon *Win32GameEngine::createFunctionLexicon( void ) { return NEW W3DFunctionLexicon; }
inline LocalFileSystem *Win32GameEngine::createLocalFileSystem( void ) { return NEW Win32LocalFileSystem; }
inline ArchiveFileSystem *Win32GameEngine::createArchiveFileSystem( void ) { return NEW Win32BIGFileSystem; }
inline ParticleSystemManager* Win32GameEngine::createParticleSystemManager( void ) { return NEW W3DParticleSystemManager; }
inline NetworkInterface *Win32GameEngine::createNetwork( void ) { return NetworkInterface::createNetwork(); }
inline Radar *Win32GameEngine::createRadar( void ) { return NEW W3DRadar; }
inline WebBrowser *Win32GameEngine::createWebBrowser( void ) { return NEW CComObject<W3DWebBrowser>; }
inline AudioManager *Win32GameEngine::createAudioManager( void ) { return NEW MilesAudioManager; }
#endif // end __WIN32GAMEENGINE_H_

View file

@ -0,0 +1,46 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
///// Win32LocalFile.h ///////////////////////////
// Bryan Cleveland, August 2002
//////////////////////////////////////////////////
#pragma once
#ifndef __WIN32LOCALFILE_H
#define __WIN32LOCALFILE_H
#include "Common/LocalFile.h"
class Win32LocalFile : public LocalFile
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(Win32LocalFile, "Win32LocalFile")
public:
Win32LocalFile();
//virtual ~Win32LocalFile();
protected:
};
#endif // __WIN32LOCALFILE_H

View file

@ -0,0 +1,56 @@
/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
///// Win32LocalFileSystem.h //////////////////////////////////
// Bryan Cleveland, August 2002
///////////////////////////////////////////////////////////////
#pragma once
#ifndef __WIN32LOCALFILESYSTEM_H
#define __WIN32LOCALFILESYSTEM_H
#include "Common/LocalFileSystem.h"
class Win32LocalFileSystem : public LocalFileSystem
{
public:
Win32LocalFileSystem();
virtual ~Win32LocalFileSystem();
virtual void init();
virtual void reset();
virtual void update();
virtual File * openFile(const Char *filename, Int access = 0); ///< open the given file.
virtual Bool doesFileExist(const Char *filename) const; ///< does the given file exist?
virtual void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories.
virtual Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const;
virtual Bool createDirectory(AsciiString directory);
protected:
};
#endif // __WIN32LOCALFILESYSTEM_H

View file

@ -0,0 +1,106 @@
/*
** Command & Conquer Generals(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: Win32DIKeyboard.h ////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: Win32DIKeyboard.h
//
// Created: Colin Day, June 2001
//
// Desc: Device implementation of the keyboard interface on Win32
// using Microsoft Direct Input
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __WIN32DIKEYBOARD_H_
#define __WIN32DIKEYBOARD_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#ifndef DIRECTINPUT_VERSION
# define DIRECTINPUT_VERSION 0x800
#endif
#include <dinput.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GameClient/Keyboard.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// class DirectInputKeyboard --------------------------------------------------
/** Class for interfacing with the keyboard using direct input as the
* implementation */
//-----------------------------------------------------------------------------
class DirectInputKeyboard : public Keyboard
{
public:
DirectInputKeyboard( void );
virtual ~DirectInputKeyboard( void );
// extend methods from the base class
virtual void init( void ); ///< initialize the keyboard, extending init functionality
virtual void reset( void ); ///< Reset the keybaord system
virtual void update( void ); ///< update call, extending update functionality
virtual Bool getCapsState( void ); ///< get state of caps lock key, return TRUE if down
protected:
// extended methods from the base class
virtual void getKey( KeyboardIO *key ); ///< get a single key event
//-----------------------------------------------------------------------------------------------
// new methods to this derived class
void openKeyboard( void ); ///< create direct input keyboard
void closeKeyboard( void ); ///< release direct input keyboard
// direct input data members
LPDIRECTINPUT8 m_pDirectInput; ///< pointer to direct input interface
LPDIRECTINPUTDEVICE8 m_pKeyboardDevice; ///< pointer to keyboard device
}; // end class DirectInputKeyboard
// INLINING ///////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
#endif // __WIN32DIKEYBOARD_H_

View file

@ -0,0 +1,105 @@
/*
** Command & Conquer Generals(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/>.
*/
// FILE: Win32DIMouse.h ///////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: Win32DIMouse.h
//
// Created: Colin Day, June 2001
//
// Desc: Win32 direct input implementation for the mouse
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __WIN32DIMOUSE_H_
#define __WIN32DIMOUSE_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#ifndef DIRECTINPUT_VERSION
# define DIRECTINPUT_VERSION 0x800
#endif
#include <dinput.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GameClient/Mouse.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
// class DirectInputMouse -----------------------------------------------------
/** Direct input implementation for the mouse device */
//-----------------------------------------------------------------------------
class DirectInputMouse : public Mouse
{
public:
DirectInputMouse( void );
virtual ~DirectInputMouse( void );
// extended methods from base class
virtual void init( void ); ///< initialize the direct input mouse, extending functionality
virtual void reset( void ); ///< reset system
virtual void update( void ); ///< update the mouse data, extending functionality
virtual void setPosition( Int x, Int y ); ///< set position for mouse
virtual void setMouseLimits( void ); ///< update the limit extents the mouse can move in
virtual void setCursor( MouseCursor cursor ); ///< set mouse cursor
virtual void capture( void ); ///< capture the mouse
virtual void releaseCapture( void ); ///< release mouse capture
protected:
/// device implementation to get mouse event
virtual UnsignedByte getMouseEvent( MouseIO *result, Bool flush );
// new internal methods for our direct input implemetation
void openMouse( void ); ///< create the direct input mouse
void closeMouse( void ); ///< close and release mouse resources
/// map direct input mouse data to our own format
void mapDirectInputMouse( MouseIO *mouse, DIDEVICEOBJECTDATA *mdat );
// internal data members for our direct input mouse
LPDIRECTINPUT8 m_pDirectInput; ///< pointer to direct input interface
LPDIRECTINPUTDEVICE8 m_pMouseDevice; ///< pointer to mouse device
}; // end class DirectInputMouse
// INLINING ///////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
#endif // __WIN32DIMOUSE_H_

View file

@ -0,0 +1,117 @@
/*
** Command & Conquer Generals(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: Win32Mouse.h /////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: RTS3
//
// File name: Win32Mouse.h
//
// Created: Colin Day, July 2001
//
// Desc: Interface for the mouse using only the Win32 messages
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __WIN32MOUSE_H_
#define __WIN32MOUSE_H_
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GameClient/Mouse.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////
// TYPE DEFINES ///////////////////////////////////////////////////////////////
enum { NO_TIME_FROM_WINDOWS = 0 };
// Win32Mouse -----------------------------------------------------------------
/** Mouse interface for when using only the Win32 messages */
//-----------------------------------------------------------------------------
class Win32Mouse : public Mouse
{
public:
Win32Mouse( void );
virtual ~Win32Mouse( void );
virtual void init( void ); ///< init mouse, extend this functionality, do not replace
virtual void reset( void ); ///< reset the system
virtual void update( void ); ///< update
virtual void initCursorResources(void); ///< load windows resources needed for 2d cursors.
virtual void setCursor( MouseCursor cursor ); ///< set mouse cursor
virtual void capture( void ); ///< capture the mouse
virtual void releaseCapture( void ); ///< release mouse capture
virtual void setVisibility(Bool visible);
/// add an event from a win32 window procedure
void addWin32Event( UINT msg, WPARAM wParam, LPARAM lParam, DWORD time );
void lostFocus (Bool state) { m_lostFocus = state;}
protected:
/// get the next event available in the buffer
virtual UnsignedByte getMouseEvent( MouseIO *result, Bool flush );
/// translate a win32 mouse event to our own info
void translateEvent( UnsignedInt eventIndex, MouseIO *result );
struct Win32MouseEvent
{
UINT msg; ///< WM_* message
WPARAM wParam; ///< WPARAM from the WM_* message
LPARAM lParam; ///< LPARAM from the WM_* message
DWORD time; ///< TIME from the WM_* message
};
/// this is our buffer of events that we receive via a WndProc message
Win32MouseEvent m_eventBuffer[ Mouse::NUM_MOUSE_EVENTS ];
UnsignedInt m_nextFreeIndex; ///< insert new events at this index
UnsignedInt m_nextGetIndex; /** events retrieved through getMouseEvent
will come from this index, then it will be
incremented to the next index */
MouseCursor m_currentWin32Cursor; ///< keep track of last cursor image sent to D3D.
Int m_directionFrame; ///< current frame of directional cursor (frome 0 points up).
Bool m_lostFocus; ///< flag if window has lost focues and mouse should stop being updated.
}; // end Win32Mouse
// INLINING ///////////////////////////////////////////////////////////////////
// EXTERNALS //////////////////////////////////////////////////////////////////
#endif // __WIN32MOUSE_H_