My Project
|
FFT based ocean rendering class. More...
#include <OceanManager.h>
Classes | |
struct | sAnimVertex |
vertex data for animation More... | |
struct | sBaseVertex |
the base vertex for ocean tile. More... | |
struct | sComplex |
typedef floating-point complex numbers to hold pairs of real and imaginary numbers More... | |
struct | sTerrainVertex |
vertex data for terrain terrain height field. More... | |
Public Types | |
enum | eProcessingStages { k_animateHeight = 0, k_animateNormal, k_heightFFTv, k_heightFFTh, k_normalFFTv, k_normalFFTh, k_uploadBuffer, k_rotateBuffer, k_total_process_stages } |
enum | eWaterMeshes { k_total_water_meshes = 3, k_total_terrain_meshes = 1 } |
enum | ReflectionItem { R_SKY_BOX = 0, R_GLOBAL_TERRAIN, R_MESH_FRONT_TO_BACK, R_MESH_BACK_TO_FRONT, R_CHARACTERS, R_CURRENT_PLAYER, R_MESH_TRANSPARENT, R_LAST_ITEM } |
enum | OCEAN_RENDER_TECHNIQUE { OCEAN_TECH_QUAD =0, OCEAN_TECH_FFT, OCEAN_TECH_REFLECTION, OCEAN_TECH_FULL, OCEAN_TECH_SIMPLE, OCEAN_TECH_CLOUD } |
![]() | |
typedef ParaEngine::weak_ptr< IObject, IAttributeFields > | WeakPtr_type |
![]() | |
typedef ParaEngine::weak_ptr< IObject > | WeakPtr_type |
Public Member Functions | |
virtual int | GetAttributeClassID () |
attribute class ID should be identical, unless one knows how overriding rules work. More... | |
virtual const char * | GetAttributeClassName () |
a static string, describing the attribute class object's name | |
virtual const char * | GetAttributeClassDescription () |
a static string, describing the attribute class object | |
virtual int | InstallFields (CAttributeClass *pClass, bool bOverride) |
this class should be implemented if one wants to add new attribute. More... | |
ATTRIBUTE_METHOD1 (COceanManager, OceanEnabled_s, bool *) | |
ATTRIBUTE_METHOD1 (COceanManager, EnableOcean_s, bool) | |
ATTRIBUTE_METHOD1 (COceanManager, GetWaterLevel_s, float *) | |
ATTRIBUTE_METHOD1 (COceanManager, SetWaterLevel_s, float) | |
ATTRIBUTE_METHOD1 (COceanManager, IsUnderWater_s, bool *) | |
ATTRIBUTE_METHOD1 (COceanManager, GetOceanColor_s, Vector3 *) | |
ATTRIBUTE_METHOD1 (COceanManager, SetGetOceanColor_s, Vector3) | |
ATTRIBUTE_METHOD1 (COceanManager, GetWindSpeed_s, float *) | |
ATTRIBUTE_METHOD1 (COceanManager, SetWindSpeed_s, float) | |
ATTRIBUTE_METHOD1 (COceanManager, GetWindDirection_s, float *) | |
ATTRIBUTE_METHOD1 (COceanManager, SetWindDirection_s, float) | |
ATTRIBUTE_METHOD1 (COceanManager, GetRenderTechnique_s, int *) | |
ATTRIBUTE_METHOD1 (COceanManager, SetRenderTechnique_s, int) | |
ATTRIBUTE_METHOD1 (COceanManager, IsTerrainReflectionEnabled_s, bool *) | |
ATTRIBUTE_METHOD1 (COceanManager, EnableTerrainReflection_s, bool) | |
ATTRIBUTE_METHOD1 (COceanManager, IsMeshReflectionEnabled_s, bool *) | |
ATTRIBUTE_METHOD1 (COceanManager, EnableMeshReflection_s, bool) | |
ATTRIBUTE_METHOD1 (COceanManager, IsPlayerReflectionEnabled_s, bool *) | |
ATTRIBUTE_METHOD1 (COceanManager, EnablePlayerReflection_s, bool) | |
ATTRIBUTE_METHOD1 (COceanManager, IsCharacterReflectionEnabled_s, bool *) | |
ATTRIBUTE_METHOD1 (COceanManager, EnableCharacterReflection_s, bool) | |
ATTRIBUTE_METHOD1 (COceanManager, IsAnimateFFT_s, bool *) | |
ATTRIBUTE_METHOD1 (COceanManager, SetAnimateFFT_s, bool) | |
ATTRIBUTE_METHOD (COceanManager, CleanupTerrainCache_s) | |
const LinearColor & | GetOceanColor () |
a color to be multiplied to the sky, giving it a special color hue More... | |
void | SetGetOceanColor (const LinearColor &color) |
a color to be multiplied to the sky, giving it a special color hue More... | |
bool | OceanEnabled () |
whether ocean should be drawn and simulated. More... | |
void | EnableOcean (bool Enable) |
set whether ocean should be drawn and simulated. More... | |
float | GetWaterLevel () |
void | SetWaterLevel (float fLevel) |
set the water level More... | |
void | EnableReflectionItem (ReflectionItem item, bool bEnabled) |
Set which group of items will be drawn in the reflection. More... | |
bool | IsReflectionItemEnabled (ReflectionItem item) |
void | EnableTerrainReflection (bool bEnabled) |
bool | IsTerrainReflectionEnabled () |
void | EnableMeshReflection (bool bEnabled) |
bool | IsMeshReflectionEnabled () |
void | EnablePlayerReflection (bool bEnabled) |
bool | IsPlayerReflectionEnabled () |
void | EnableCharacterReflection (bool bEnabled) |
bool | IsCharacterReflectionEnabled () |
bool | IsRedrawStillReflection () |
whether to redraw reflection even if the camera does not move. More... | |
bool | IsUnderWater () |
float | GetWindSpeed () |
get the wind speed. More... | |
void | SetWindSpeed (float fSpeed) |
set the wind speed. More... | |
float | GetWindDirection () |
get the wind Direction. More... | |
void | SetWindDirection (float fWindDirection) |
set the wind Direction. More... | |
void | SetGlobalWater (bool bEnable, float fWaterLevel=0.0f) |
Set the global water drawing attribute. More... | |
float | GetMaxWaterLevel () |
void | AddRipple (const Vector3 &vPos) |
add a ripple at the given position using the default wave parameters of the ocean. More... | |
bool | create () |
create the default ocean. More... | |
void | CheckLoadOceanTextures (int nTechnique=0) |
check load ocean textures | |
void | InitDeviceObjects () |
init device objects. More... | |
void | RestoreDeviceObjects () |
restore device object | |
void | InvalidateDeviceObjects () |
Invalid device object. | |
void | DeleteDeviceObjects () |
delete device objects | |
void | Cleanup () |
clean up all resource objects | |
void | update (float fTimeDelta) |
this function should be called as often as possible to animate the ocean. More... | |
bool | UpdateReflectionTexture (SceneState &sceneState) |
redraw reflection texture only necessary. More... | |
void | ForceUpdateOcean () |
force updating reflection texture in the next render frame. More... | |
void | Render (SceneState *pSceneState) |
render the ocean More... | |
bool | RenderReflectionTexture () |
whether we have reflection texture drawn. More... | |
void | SetRenderTechnique (DWORD dwTechnique) |
obsolete: set the current ocean rendering technique. More... | |
DWORD | GetRenderTechnique () |
obsolete: get ocean simulation and rendering technique. More... | |
bool | IsPointUnderWater (const Vector3 &vPos) |
check whether a specified point is under the water surface. More... | |
bool | IsDrawShoreLine () |
return true if draw shoreline | |
void | DrawShoreLine (bool bDraw) |
set whether drawing shoreline | |
void | CleanupTerrainCache () |
clean up terrain height field cache. More... | |
bool | IsOceanVisible () |
whether the ocean has passed the occlusion test in the last frame | |
bool | IsAnimateFFT () |
shall we animate FFT, animating FFT will consume quite a lot of CPU per frame. More... | |
void | SetAnimateFFT (bool bEnable) |
Set whether we shall animate FFT, animating FFT will consume quite a lot of CPU per frame. More... | |
void | EnableScreenSpaceFog (bool value) |
bool | IsScreenSpaceFog () |
![]() | |
virtual int | GetChildAttributeColumnCount () |
we support multi-dimensional child object. More... | |
virtual int | GetChildAttributeObjectCount (int nColumnIndex=0) |
get the number of child objects (row count) in the given column. More... | |
virtual IAttributeFields * | GetChildAttributeObject (int nRowIndex, int nColumnIndex=0) |
virtual IAttributeFields * | GetChildAttributeObject (const std::string &sName) |
get attribute by child object. More... | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetName_s, const char **) | |
ATTRIBUTE_METHOD1 (IAttributeFields, SetName_s, const char *) | |
ATTRIBUTE_METHOD (IAttributeFields, PrintObject_s) | |
ATTRIBUTE_METHOD (IAttributeFields, AddRef_s) | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetRefCount_s, int *) | |
ATTRIBUTE_METHOD1 (IAttributeFields, SetTime_s, int) | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetTime_s, int *) | |
ATTRIBUTE_METHOD (IAttributeFields, Release_s) | |
virtual const std::string & | GetIdentifier () |
virtual void | SetIdentifier (const std::string &sID) |
virtual bool | IsModified () |
whether some of the fields are modified.It is up to the implementation class to provide this functionality if necessary. More... | |
virtual void | SetModified (bool bModified) |
set whether any field has been modified. More... | |
virtual bool | ValidateFields () |
validate all fields and return true if validation passed. More... | |
virtual string | GetValidationMessage () |
get the recent validation message due to the most recent call to ValidateFields() | |
virtual bool | ResetField (int nFieldID) |
Reset the field to its initial or default value. More... | |
virtual bool | InvokeEditor (int nFieldID, const std::string &sParameters) |
Invoke an (external) editor for a given field. More... | |
virtual bool | AddChildAttributeObject (IAttributeFields *pChild, int nRowIndex=-1, int nColumnIndex=0) |
add child object. More... | |
virtual void * | QueryObjectByName (const std::string &sObjectType) |
convert to object of a given type. More... | |
virtual void * | QueryObject (int nObjectType) |
convert to object of a given type. More... | |
virtual int | GetTime () |
get the current local time in case it is animated in milli seconds frames. More... | |
virtual void | SetTime (int nTime) |
virtual CDynamicAttributeField * | GetDynamicField (const std::string &sName) |
Get a dynamic field with a given name. More... | |
virtual CDynamicAttributeField * | GetDynamicField (int nIndex) |
Get a dynamic field with a given index. More... | |
virtual const char * | GetDynamicFieldNameByIndex (int nIndex) |
get field name by index | |
virtual int | GetDynamicFieldCount () |
how many dynamic field this object currently have. More... | |
virtual int | SetDynamicField (const std::string &sName, const CVariable &value) |
set a dynamic field with a given name. More... | |
virtual int | AddDynamicField (const std::string &sName, ATTRIBUTE_FIELDTYPE dwType) |
add dynamic field and return field index | |
virtual void | RemoveAllDynamicFields () |
remove all dynamic fields | |
virtual int | SaveDynamicFieldsToString (std::string &output) |
save only text dynamic fields to fieldname = value text strings. More... | |
virtual int | LoadDynamicFieldsFromString (const std::string &input) |
load only text dynamic fields from string More... | |
CAttributeClass * | GetAttributeClass () |
get the main attribute class object. More... | |
void | PrintObject () |
print the content of this object to a text file at temp/doc/[ClassName].txt. More... | |
![]() | |
virtual void | Clone (IObject *obj) const |
Clone the object's contains to a pointer. More... | |
virtual IObject * | Clone () const |
Clone the object's contains and return a pointer to the newly created object. More... | |
virtual bool | Equals (const IObject *obj) const |
Compare the object with another object. More... | |
virtual const IType * | GetType () const |
virtual std::string | ToString () const |
WeakPtr_type & | GetWeakReference () |
get weak reference object. More... | |
virtual int | ProcessObjectEvent (const ObjectEvent &event) |
this function is only used to backward compatibility of ParaObject:AddEvent() function. More... | |
![]() | |
void | addref () const |
add reference count of the object. More... | |
bool | delref () const |
decrease reference count of the object. More... | |
int | GetRefCount () const |
get the reference count | |
virtual int | Release () |
CRefCounted * | AddToAutoReleasePool () |
addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More... | |
Static Public Member Functions | |
static COceanManager * | GetInstance () |
![]() | |
static HRESULT | GetAttributeClassID_s (IAttributeFields *cls, int *p1) |
static HRESULT | GetAttributeClassName_s (IAttributeFields *cls, const char **p1) |
static bool | OpenWithDefaultEditor (const char *sFilename, bool bWaitOnReturn=false) |
Open a given file with the default registered editor in the game engine. More... | |
Friends | |
class | CSceneObject |
Additional Inherited Members | |
![]() | |
virtual CAttributeClass * | CreateAttributeClass () |
initialize fields | |
virtual CDynamicAttributesSet * | GetDynamicAttributes (bool bCreateIfNotExist=false) |
![]() | |
WeakPtr_type | m_weak_reference |
![]() | |
int | m_refcount |
FFT based ocean rendering class.
FFT is used to generate the ocean wave mesh. Bump mapping is used to add high frequency wavelets.
void ParaEngine::COceanManager::AddRipple | ( | const Vector3 & | vPos | ) |
add a ripple at the given position using the default wave parameters of the ocean.
vPos | the position of the center of the ripple in world coordinate system. |
void ParaEngine::COceanManager::CleanupTerrainCache | ( | ) |
clean up terrain height field cache.
This is usually called when the user has changed the global terrain
bool ParaEngine::COceanManager::create | ( | ) |
create the default ocean.
the initial ocean wave at time t=0 is prepared. FFT tables are build. But no device objects are created.
void ParaEngine::COceanManager::EnableOcean | ( | bool | Enable | ) |
set whether ocean should be drawn and simulated.
void ParaEngine::COceanManager::EnableReflectionItem | ( | ReflectionItem | item, |
bool | bEnabled | ||
) |
Set which group of items will be drawn in the reflection.
item | see ReflectionItem |
bEnabled |
void ParaEngine::COceanManager::ForceUpdateOcean | ( | ) |
force updating reflection texture in the next render frame.
|
inlinevirtual |
attribute class ID should be identical, unless one knows how overriding rules work.
Reimplemented from ParaEngine::IAttributeFields.
float ParaEngine::COceanManager::GetMaxWaterLevel | ( | ) |
|
inline |
a color to be multiplied to the sky, giving it a special color hue
DWORD ParaEngine::COceanManager::GetRenderTechnique | ( | ) |
obsolete: get ocean simulation and rendering technique.
float ParaEngine::COceanManager::GetWaterLevel | ( | ) |
float ParaEngine::COceanManager::GetWindDirection | ( | ) |
get the wind Direction.
float ParaEngine::COceanManager::GetWindSpeed | ( | ) |
get the wind speed.
void ParaEngine::COceanManager::InitDeviceObjects | ( | ) |
init device objects.
the create() function must be called, before this function is called.
|
virtual |
this class should be implemented if one wants to add new attribute.
This function is always called internally.
Reimplemented from ParaEngine::IAttributeFields.
bool ParaEngine::COceanManager::IsAnimateFFT | ( | ) |
shall we animate FFT, animating FFT will consume quite a lot of CPU per frame.
bool ParaEngine::COceanManager::IsPointUnderWater | ( | const Vector3 & | vPos | ) |
check whether a specified point is under the water surface.
bool ParaEngine::COceanManager::IsRedrawStillReflection | ( | ) |
whether to redraw reflection even if the camera does not move.
this function is automatically true, if animated characters are enabled for reflection drawing.
bool ParaEngine::COceanManager::IsUnderWater | ( | ) |
bool ParaEngine::COceanManager::OceanEnabled | ( | ) |
whether ocean should be drawn and simulated.
void ParaEngine::COceanManager::Render | ( | SceneState * | pSceneState | ) |
render the ocean
check whether the camera eye is under the water surface or not
bool ParaEngine::COceanManager::RenderReflectionTexture | ( | void | ) |
whether we have reflection texture drawn.
void ParaEngine::COceanManager::SetAnimateFFT | ( | bool | bEnable | ) |
Set whether we shall animate FFT, animating FFT will consume quite a lot of CPU per frame.
|
inline |
a color to be multiplied to the sky, giving it a special color hue
color |
void ParaEngine::COceanManager::SetGlobalWater | ( | bool | bEnable, |
float | fWaterLevel = 0.0f |
||
) |
Set the global water drawing attribute.
the global water level is just a water surface at a given height near the current camera location
bEnable | whether to draw global water |
fWaterLevel | water level in meters. Default value is 0.0f; |
void ParaEngine::COceanManager::SetRenderTechnique | ( | DWORD | dwTechnique | ) |
obsolete: set the current ocean rendering technique.
It will always fall back to a valid device. Hence, it may be different from GetRenderTechnique()
dwTechnique |
void ParaEngine::COceanManager::SetWaterLevel | ( | float | fLevel | ) |
set the water level
fLevel | water level |
void ParaEngine::COceanManager::SetWindDirection | ( | float | fWindDirection | ) |
set the wind Direction.
void ParaEngine::COceanManager::SetWindSpeed | ( | float | fSpeed | ) |
set the wind speed.
void ParaEngine::COceanManager::update | ( | float | fTimeDelta | ) |
this function should be called as often as possible to animate the ocean.
currently a fixed time delta is used.
bool ParaEngine::COceanManager::UpdateReflectionTexture | ( | SceneState & | sceneState | ) |
redraw reflection texture only necessary.
Call this function at the start of each rendering frame