2 #include "IAttributeFields.h" 3 #include "terrain/TTerrain.h" 40 void FrameMove(
float fDeltaTime);
49 list<RippleItem> m_ripples;
63 enum eProcessingStages
73 k_total_process_stages
77 k_total_water_meshes = 3,
78 k_total_terrain_meshes = 1,
136 ATTRIBUTE_METHOD1(
COceanManager, OceanEnabled_s,
bool*) {*p1 = cls->OceanEnabled();
return S_OK;}
137 ATTRIBUTE_METHOD1(
COceanManager, EnableOcean_s,
bool) {cls->EnableOcean(p1);
return S_OK;}
139 ATTRIBUTE_METHOD1(
COceanManager, GetWaterLevel_s,
float*) {*p1 = cls->GetWaterLevel();
return S_OK;}
140 ATTRIBUTE_METHOD1(
COceanManager, SetWaterLevel_s,
float) {cls->SetWaterLevel(p1);
return S_OK;}
142 ATTRIBUTE_METHOD1(
COceanManager, IsUnderWater_s,
bool*) {*p1 = cls->IsUnderWater();
return S_OK;}
144 ATTRIBUTE_METHOD1(
COceanManager, GetOceanColor_s,
Vector3*) {*p1 = cls->GetOceanColor().ToVector3();
return S_OK;}
147 ATTRIBUTE_METHOD1(
COceanManager, GetWindSpeed_s,
float*) {*p1 = cls->GetWindSpeed();
return S_OK;}
148 ATTRIBUTE_METHOD1(
COceanManager, SetWindSpeed_s,
float) {cls->SetWindSpeed(p1);
return S_OK;}
149 ATTRIBUTE_METHOD1(
COceanManager, GetWindDirection_s,
float*) {*p1 = cls->GetWindDirection();
return S_OK;}
150 ATTRIBUTE_METHOD1(
COceanManager, SetWindDirection_s,
float) {cls->SetWindDirection(p1);
return S_OK;}
152 ATTRIBUTE_METHOD1(
COceanManager, GetRenderTechnique_s,
int*) {*p1 = cls->GetRenderTechnique();
return S_OK;}
153 ATTRIBUTE_METHOD1(
COceanManager, SetRenderTechnique_s,
int) {cls->SetRenderTechnique(p1);
return S_OK;}
155 ATTRIBUTE_METHOD1(
COceanManager, IsTerrainReflectionEnabled_s,
bool*) {*p1 = cls->IsTerrainReflectionEnabled();
return S_OK;}
156 ATTRIBUTE_METHOD1(
COceanManager, EnableTerrainReflection_s,
bool) {cls->EnableTerrainReflection(p1);
return S_OK;}
158 ATTRIBUTE_METHOD1(
COceanManager, IsMeshReflectionEnabled_s,
bool*) {*p1 = cls->IsMeshReflectionEnabled();
return S_OK;}
159 ATTRIBUTE_METHOD1(
COceanManager, EnableMeshReflection_s,
bool) {cls->EnableMeshReflection(p1);
return S_OK;}
161 ATTRIBUTE_METHOD1(
COceanManager, IsPlayerReflectionEnabled_s,
bool*) {*p1 = cls->IsPlayerReflectionEnabled();
return S_OK;}
162 ATTRIBUTE_METHOD1(
COceanManager, EnablePlayerReflection_s,
bool) {cls->EnablePlayerReflection(p1);
return S_OK;}
164 ATTRIBUTE_METHOD1(
COceanManager, IsCharacterReflectionEnabled_s,
bool*) {*p1 = cls->IsCharacterReflectionEnabled();
return S_OK;}
165 ATTRIBUTE_METHOD1(
COceanManager, EnableCharacterReflection_s,
bool) {cls->EnableCharacterReflection(p1);
return S_OK;}
167 ATTRIBUTE_METHOD1(
COceanManager, IsAnimateFFT_s,
bool*) {*p1 = cls->IsAnimateFFT();
return S_OK;}
168 ATTRIBUTE_METHOD1(
COceanManager, SetAnimateFFT_s,
bool) {cls->SetAnimateFFT(p1);
return S_OK;}
170 ATTRIBUTE_METHOD(
COceanManager, CleanupTerrainCache_s) {cls->CleanupTerrainCache();
return S_OK;}
187 void EnableOcean(
bool Enable);
190 float GetWaterLevel();
193 void SetWaterLevel(
float fLevel);
199 R_MESH_FRONT_TO_BACK,
200 R_MESH_BACK_TO_FRONT,
211 void EnableReflectionItem(ReflectionItem item,
bool bEnabled);
212 bool IsReflectionItemEnabled(ReflectionItem item);
214 void EnableTerrainReflection(
bool bEnabled){EnableReflectionItem(R_GLOBAL_TERRAIN, bEnabled);};
215 bool IsTerrainReflectionEnabled(){
return IsReflectionItemEnabled(R_GLOBAL_TERRAIN);};
217 void EnableMeshReflection(
bool bEnabled){EnableReflectionItem(R_MESH_FRONT_TO_BACK, bEnabled); EnableReflectionItem(R_MESH_BACK_TO_FRONT, bEnabled);};
218 bool IsMeshReflectionEnabled(){
return IsReflectionItemEnabled(R_MESH_FRONT_TO_BACK);};
220 void EnablePlayerReflection(
bool bEnabled){EnableReflectionItem(R_CURRENT_PLAYER, bEnabled);};
221 bool IsPlayerReflectionEnabled(){
return IsReflectionItemEnabled(R_CURRENT_PLAYER);};
223 void EnableCharacterReflection(
bool bEnabled){EnableReflectionItem(R_CHARACTERS, bEnabled);};
224 bool IsCharacterReflectionEnabled(){
return IsReflectionItemEnabled(R_CHARACTERS);};
230 bool IsRedrawStillReflection();
236 float GetWindSpeed();
238 void SetWindSpeed(
float fSpeed);
240 float GetWindDirection();
242 void SetWindDirection(
float fWindDirection);
250 void SetGlobalWater(
bool bEnable,
float fWaterLevel = 0.0f);
253 float GetMaxWaterLevel();
260 void AddRipple(
const Vector3& vPos);
266 int m_nMaxRippleNumber;
270 float m_fGlobalWaterLevel;
272 bool m_bDrawGlobalWater;
277 bool m_bRenderOceanReflection;
280 int m_half_grid_size;
286 void SetFFTGrid(
int nSize);
293 float m_fDirectionalDependence;
294 float m_fSuppressSmallWavesFactor;
296 float m_fLargestPossibleWave;
297 float m_fSuppressSmallWaves;
300 float m_ocean_tile_size;
302 float m_ocean_tile_height;
307 bool m_bDrawShoreline;
309 map <int, TerrainTileCacheItem> m_pCachedTerrains;
313 static int GetTileIDFromXY(
int X,
int Y);
316 static bool GetXYFromTileID(
int nTileID,
int* X,
int* Y);
322 TTerrain* GetTerrainHeightField(
int nID);
325 void FrameMoveCachedTerrainTiles();
330 static const float GRAVITY_CONSTANT;
333 static const float m_fDefaultWindDirection;
334 static const float m_fDefaultWindSpeed;
335 static const float m_fDefaultWaveHeight;
343 static const float m_fDefaultDirectionalDependence;
346 static const float m_fDefaultSuppressSmallWavesFactor;
357 float m_fInterpolation;
362 Plane m_refractionClipPlaneAboveWater;
363 Plane m_reflectionClipPlaneAboveWater;
364 Plane m_refractionClipPlaneBelowWater;
365 Plane m_reflectionClipPlaneBelowWater;
367 float m_refractionMapOverdraw;
368 float m_reflectionMapOverdraw;
370 int m_reflectionTextureWidth;
371 int m_reflectionTextureHeight;
372 int m_refractionTextureWidth;
373 int m_refractionTextureHeight;
374 #ifdef USE_DIRECTX_RENDERER 375 LPDIRECT3DSURFACE9 m_pDepthStencilSurface;
376 LPDIRECT3DTEXTURE9 m_waveReflectionTexture;
377 LPDIRECT3DSURFACE9 m_waveReflectionSurface;
378 LPDIRECT3DTEXTURE9 m_waveRefractionTexture;
379 LPDIRECT3DSURFACE9 m_waveRefractionSurface;
380 LPDIRECT3DTEXTURE9 m_waveReflectionNearTexture;
381 LPDIRECT3DSURFACE9 m_waveReflectionNearSurface;
382 LPDIRECT3DTEXTURE9 m_waveRefractionNearTexture;
383 LPDIRECT3DSURFACE9 m_waveRefractionNearSurface;
389 Matrix4 m_reflectionProjectionMatrix;
390 Matrix4 m_refractionProjectionMatrix;
391 Matrix4 m_worldViewProjectionInverseTransposeMatrix;
393 bool m_reflectViewMatrix;
398 float m_fLastReflectionTime;
405 void SetMatrices(
bool bPostPushMatrices=
false,
bool bPrePopMatrices=
false);
408 bool m_ReflectionItems[R_LAST_ITEM];
411 bool m_bDisableFogInReflection;
415 asset_ptr<TextureEntity> m_pRippleBumpMappingTexture;
417 asset_ptr<TextureEntity> m_pShorelineTexture;
419 asset_ptr<TextureEntity> m_pRippleTexture;
421 bool m_bUseShorelineTexture;
423 asset_ptr<TextureEntity> m_pWaterColorTexture;
426 asset_ptr<TextureEntity> m_pWaterFadeTexture;
428 asset_ptr<TextureEntity> m_pSimpleReflectionTexture;
430 asset_ptr<TextureEntity> m_pSimpleBumpTexture;
432 asset_ptr<TextureEntity> m_pCloudTexture;
434 asset_ptr<TextureEntity> m_pSunsetTexture;
435 #ifdef USE_DIRECTX_RENDERER 437 LPDIRECT3DVERTEXBUFFER9 m_pBaseBuffer;
439 LPDIRECT3DINDEXBUFFER9 m_pIndexBuffer;
442 LPDIRECT3DVERTEXBUFFER9 m_pAnimBuffer[k_total_water_meshes];
443 LPDIRECT3DVERTEXBUFFER9 m_pTerrainHeightmapBuffer[k_total_terrain_meshes];
466 float* m_colAngularFreq;
469 float getOceanHeight(
int x,
int y);
470 float getOceanNormalX(
int x,
int y);
471 float getOceanNormalY(
int x,
int y);
475 float getAngularFrequency(
float fKLength);
477 int getIndexH0(
int x,
int y);
478 int getIndex(
int x,
int y);
479 int getIndexFFT(
int x,
int y);
480 int getOffset(
int x,
int y);
481 int getOffsetWrap(
int x,
int y);
486 void setOceanParameters(
487 unsigned long ulSeed,
488 float fWindDirection,
491 float fDirectionalDependence,
492 float fSuppressSmallWavesFactor );
494 float phillipsSpectrum(
float fKx,
float fKy );
495 #ifdef USE_DIRECTX_RENDERER 497 void fillVertexBuffer(LPDIRECT3DVERTEXBUFFER9 pVertexBuffer);
500 bool CreateStripGridIndexBuffer(
511 void animateHeightTable();
512 void animateNormalTable();
513 void horizontalFFT(
sComplex* pCmpTable );
514 void verticalFFT(
sComplex* pCmpTable );
518 void RenderTechnique_Quad();
520 int RenderTechnique_Simple(
SceneState* pSceneState,
float x0,
float y0,
float x1,
float y1);
522 int RenderTechnique_FFT_HIGH(
SceneState* pSceneState,
float x0,
float y0,
float x1,
float y1);
524 int RenderTechnique_Cloud(
SceneState* pSceneState,
float x0,
float y0,
float x1,
float y1);
527 int RenderTechnique_OccusionTest(
SceneState* pSceneState,
float x0,
float y0,
float x1,
float y1);
529 void RenderRipples(
float fTimeDelta);
532 void RenderUnderwaterEffect(
SceneState* pSceneState);
535 void CalculateTileToRender(
SceneState* pSceneState,
float& x0,
float& y0,
float& x1,
float& y1);
544 void CheckLoadOceanTextures(
int nTechnique=0);
548 void InitDeviceObjects();
550 void RestoreDeviceObjects();
552 void InvalidateDeviceObjects();
554 void DeleteDeviceObjects();
560 void update(
float fTimeDelta);
565 bool UpdateReflectionTexture(
SceneState & sceneState);
568 void ForceUpdateOcean();
573 bool RenderReflectionTexture();
575 enum OCEAN_RENDER_TECHNIQUE{
578 OCEAN_TECH_REFLECTION,
587 void SetRenderTechnique(DWORD dwTechnique);
589 DWORD GetRenderTechnique();
593 bool IsPointUnderWater(
const Vector3& vPos);
596 bool IsDrawShoreLine();
598 void DrawShoreLine(
bool bDraw);
600 void CleanupTerrainCache();
603 bool IsOceanVisible();
608 void SetAnimateFFT(
bool bEnable);
613 bool m_useScreenSpaceFog;
617 void EnableScreenSpaceFog(
bool value){
618 m_useScreenSpaceFog = value;
620 bool IsScreenSpaceFog(){
return m_useScreenSpaceFog;}
virtual const char * GetAttributeClassName()
a static string, describing the attribute class object's name
Definition: OceanManager.h:130
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
It's used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
temp height field terrain data used by terrain filters.
Definition: TTerrain.h:16
the base vertex for ocean tile.
Definition: OceanManager.h:82
a ripple
Definition: OceanManager.h:15
different physics engine has different winding order.
Definition: EventBinding.h:32
void SetGetOceanColor(const LinearColor &color)
a color to be multiplied to the sky, giving it a special color hue
Definition: OceanManager.h:181
vertex data for terrain terrain height field.
Definition: OceanManager.h:99
typedef floating-point complex numbers to hold pairs of real and imaginary numbers ...
Definition: OceanManager.h:109
virtual const char * GetAttributeClassDescription()
a static string, describing the attribute class object
Definition: OceanManager.h:132
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
vertex data for animation
Definition: OceanManager.h:91
a list of active RippleItem
Definition: OceanManager.h:29
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
Defines a plane in 3D space.
Definition: ParaPlane.h:23
float zPos
the height of the vertex
Definition: OceanManager.h:94
Definition: enum_maker.hpp:46
Vector2 vNormal
the normal of the vertex
Definition: OceanManager.h:96
A common interface for all classes implementing IAttributeFields By implementing this class's virtual...
Definition: IAttributeFields.h:59
The top level scene management class.
Definition: SceneObject.h:58
virtual int GetAttributeClassID()
attribute class ID should be identical, unless one knows how overriding rules work.
Definition: OceanManager.h:128
A linear, 32-bit/component floating point RGBA color.
Definition: ParaColor.h:12
const LinearColor & GetOceanColor()
a color to be multiplied to the sky, giving it a special color hue
Definition: OceanManager.h:176
FFT based ocean rendering class.
Definition: OceanManager.h:56