Triton
Visual simulation library for ocean rendering.
Public Member Functions | Static Public Member Functions

Triton::Ocean Class Reference

The Ocean class allows you to configure and draw Triton's water simulation. More...

#include <Ocean.h>

Inheritance diagram for Triton::Ocean:
Inheritance graph
[legend]
Collaboration diagram for Triton::Ocean:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~Ocean ()
 Virtual destructor.
virtual void TRITONAPI Draw (double time, bool depthWrites=true)
 Draws an infinite ocean surrounding the camera (as specified in the Environment object) for the simulated conditions at the given time.
void TRITONAPI D3D9DeviceLost ()
 DirectX9 users must call D3D9DeviceLost() in response to lost devices, prior to resetting the device.
void TRITONAPI D3D9DeviceReset ()
 DirectX9 users must call D3D9DeviceReset() in response to device resets done in response to lost devices.
float TRITONAPI GetChoppiness () const
 Retrieves the choppiness setting of the Ocean, which controls how peaked the waves are.
void TRITONAPI SetChoppiness (float chop)
 Set the choppiness of the waves, which controls how peaked the waves are.
float TRITONAPI GetDepth (Triton::Vector3 &floorNormal) const
 Retrieves the simulated depth of the water in world units, and the surface normal of the sea floor, both at the current camera position.
void TRITONAPI SetDepth (float depth, const Triton::Vector3 &floorNormal)
 Sets the simulated depth of the water in world units at the camera position, and the slope of the sea floor as specified by its surface normal at the camera position.
void TRITONAPI EnableWireframe (bool wireframeOn)
 Enables or disables wireframe rendering of the ocean's mesh.
const char *TRITONAPI GetFFTName () const
 Returns a description of the FFT transform being used, if a FFT water model is active.
unsigned int TRITONAPI GetNumTriangles () const
 Returns the number of triangles rendered by the underlying projected grid.
ShaderHandle TRITONAPI GetShaderObject () const
 Retrieves the underlying shader object used to render the water.
bool TRITONAPI GetHeight (const Vector3 &point, const Vector3 &direction, float &height, Vector3 &normal, bool visualCorrelation=true)
 Retrieves the height and normal of the ocean surface at the intersection point of the given ray.
float GetWaveHeading () const
 Retrieves the wave direction.
void EnableSpray (bool enable)
 Enables or disables spray particle effects on breaking waves.
bool SprayEnabled () const
 Returns if spray particle effects on breaking waves are enabled, which they are by default.
void SetRefractionColor (const Vector3 &refractionColor)
 Modifies the color used for refracted light rays that go into deep water.
const Vector3GetRefractionColor () const
 Returns the color of light refracted into the water.

Static Public Member Functions

static Ocean *TRITONAPI Create (const Environment *env, WaterModelTypes type=TESSENDORF, bool enableHeightTests=false)
 Creates an Ocean instance tied to the given Environment, using the specified wave model.

Detailed Description

The Ocean class allows you to configure and draw Triton's water simulation.


Constructor & Destructor Documentation

virtual Triton::Ocean::~Ocean ( ) [virtual]

Virtual destructor.


Member Function Documentation

static Ocean* TRITONAPI Triton::Ocean::Create ( const Environment env,
WaterModelTypes  type = TESSENDORF,
bool  enableHeightTests = false 
) [static]

Creates an Ocean instance tied to the given Environment, using the specified wave model.

Parameters:
envA pointer to an Environment object created previously, which contains the environmental conditions, coordinate system, camera, and rendering system used by the Ocean. The caller is responsible for deleting this object after the Ocean is deleted.
typeSpecifies whether a FFT-based ocean wave model (Tessendorf) should be used, or a simpler but less visually appealling Gerstner wave model that sums up individual waves in the spacial domain.
enableHeightTestsSpecifies whether the application will call Ocean::GetHeight() or not. If false, Triton may be able to keep the ocean simulation entirely on the GPU leading to better performance, but any calls to Ocean::GetHeight() may return 0. Set to true if you need to read back height information from the water surface.
Returns:
An instance of Ocean that may be used for rendering. The caller is responsible for deleting this object when finished. NULL may be returned if the ocean could not initialize itself; in this case, enable the setting enable-debug-messages in resource/triton.config to get more details on what went wrong sent to your debugger output window. Contact support@sundog-soft.com with this output if necessary.
void TRITONAPI Triton::Ocean::D3D9DeviceLost ( )

DirectX9 users must call D3D9DeviceLost() in response to lost devices, prior to resetting the device.

A lost device may occur when the user locks and unlocks a system or changes the monitor resolution, and must be explicitly handled under DX9. Call D3D9DeviceReset() once the device has been recreated.

void TRITONAPI Triton::Ocean::D3D9DeviceReset ( )

DirectX9 users must call D3D9DeviceReset() in response to device resets done in response to lost devices.

You must have called D3D9DeviceLost() first in response to the lost device.

virtual void TRITONAPI Triton::Ocean::Draw ( double  time,
bool  depthWrites = true 
) [virtual]

Draws an infinite ocean surrounding the camera (as specified in the Environment object) for the simulated conditions at the given time.

Parameters:
timeThe simulated point in time to render, in seconds. Note that this is an absolute time which can be relative to any arbitrary point in time. It's not the delta time between frames.
depthWritesWhether the ocean will write to the depth buffer. One technique for integrating the ocean with terrain is to draw the ocean first with depth writes disabled, then draw the terrain on top of it, thereby avoiding any depth buffer precision issues. Be sure to remove or disable any existing ocean surfaces from your terrain database first if using this technique.
void Triton::Ocean::EnableSpray ( bool  enable) [inline]

Enables or disables spray particle effects on breaking waves.

This does incur a performance penalty, so if you need faster performance, try disabling spray effects or even disable it entirely with the fft-enable-spray config setting in resources/Triton.config.

void TRITONAPI Triton::Ocean::EnableWireframe ( bool  wireframeOn)

Enables or disables wireframe rendering of the ocean's mesh.

Parameters:
wireframeOnSet to true to render in wireframe mode, false to render normally.
float TRITONAPI Triton::Ocean::GetChoppiness ( ) const

Retrieves the choppiness setting of the Ocean, which controls how peaked the waves are.

See also:
SetChoppiness()
float TRITONAPI Triton::Ocean::GetDepth ( Triton::Vector3 floorNormal) const

Retrieves the simulated depth of the water in world units, and the surface normal of the sea floor, both at the current camera position.

Only returns the values set by SetDepth().

See also:
SetDepth()
Parameters:
floorNormalA reference to a Vector3 to retrieve the surface normal of the sea floor as set by SetDepth().
Returns:
The depth of the sea floor at the camera position, as set by SetDepth().
const char* TRITONAPI Triton::Ocean::GetFFTName ( ) const

Returns a description of the FFT transform being used, if a FFT water model is active.

bool TRITONAPI Triton::Ocean::GetHeight ( const Vector3 point,
const Vector3 direction,
float &  height,
Vector3 normal,
bool  visualCorrelation = true 
)

Retrieves the height and normal of the ocean surface at the intersection point of the given ray.

The results of this method are only valid if Ocean::Create() was called with the parameter enableHeightReads set to true. The height returned is relative to sea level, as specified by Triton::Environment::SetSeaLevel(). For example, the crest of a one-meter-high wave will always return a height of one meter, irrespective of the environment's sea level height. Depending on the application, you may want to add in the result of Triton::Environment::GetSeaLevel() to the height returned.

Parameters:
pointThe origin of the ray to test the height against.
directionThe normalized direction vector of the ray.
heightReceives the height at the ray's intersection with the ocean, if an intersection was found.
normalReceives a normalized unit vector pointing in the direction of the normal vector of the sea surface at the intersection point.
visualCorrelationSet to true in order to have the height returned match the visuals, which dampen height offsets with distance to avoid sampling artifacts. To return the true wave height at the given location, set to false.
Returns:
True if an intersection was found, false if not.
unsigned int TRITONAPI Triton::Ocean::GetNumTriangles ( ) const

Returns the number of triangles rendered by the underlying projected grid.

const Vector3& Triton::Ocean::GetRefractionColor ( ) const

Returns the color of light refracted into the water.

See also:
SetRefractionColor();
Returns:
The RGB value of the refraction color.
ShaderHandle TRITONAPI Triton::Ocean::GetShaderObject ( ) const

Retrieves the underlying shader object used to render the water.

If you make modifications to our shaders to add additional effects, you can use this in order to pass your own uniform variables into the shader. Depending on the renderer you're using, you'll need to cast this to a GLhandleARB, ID3DXEffect, or ID3DX11Effect.

Returns:
The GLhandleARB, ID3DXEffect, or ID3DX11Effect representing the shader object used to draw the ocean, or 0 if no shader is loaded.
float Triton::Ocean::GetWaveHeading ( ) const [inline]

Retrieves the wave direction.

Normally this is the same as the wind direction, but in shallow water it will align with the slope of the sea floor as specified in SetDepth().

void TRITONAPI Triton::Ocean::SetChoppiness ( float  chop)

Set the choppiness of the waves, which controls how peaked the waves are.

See also:
GetChoppiness()
Parameters:
chopThe choppiness parameter; 0.0 yields no chop, 3.0 yields strong chop. Values that are too high may result in wave geometry folding over itself, so take care to set reasonable values.
void TRITONAPI Triton::Ocean::SetDepth ( float  depth,
const Triton::Vector3 floorNormal 
)

Sets the simulated depth of the water in world units at the camera position, and the slope of the sea floor as specified by its surface normal at the camera position.

This information is used to interpolate the water depth at various positions in the scene, affecting the transparency of the water as well as the height of the waves. Avoid changing this every frame for performance reasons.

See also:
GetDepth()
Parameters:
depthThe depth of the water, in world units, at the camera position. Negative values will be clamped to zero. For open ocean, either do not call this method or set depth to a large number (like 1000).
floorNormalThe surface normal of the sea floor at the camera position. The point defined by the depth parameter under the camera position together with this normal will define a plane that approximates the position of the sea floor surrounding the current location.
void Triton::Ocean::SetRefractionColor ( const Vector3 refractionColor)

Modifies the color used for refracted light rays that go into deep water.

You can use this to modify the color of the water in areas that are not purely reflective.

Parameters:
refractionColorthe RGB color value of the deep water color; each component should be in the range 0-1.
bool Triton::Ocean::SprayEnabled ( ) const [inline]

Returns if spray particle effects on breaking waves are enabled, which they are by default.

See also:
EnableSpray().

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Friends