Colobot
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Gfx::CWater Class Reference

Water manager/renderer. More...

#include <water.h>

Classes

struct  WaterLine
 Water strip. More...
 
struct  WaterVapor
 Water particle effect. More...
 

Public Member Functions

 CWater (CEngine *engine)
 
bool EventProcess (const Event &event)
 
void Flush ()
 Removes all the water. More...
 
void Create (WaterType type1, WaterType type2, const std::string &fileName, Color diffuse, Color ambient, float level, float glint, Math::Vector eddy)
 Creates all expanses of water. More...
 
void DrawBack ()
 Draw the back surface of the water. More...
 
void DrawSurf ()
 Draws the flat surface of the water. More...
 
void SetLevel (float level)
 Changes the level of the water. More...
 
float GetLevel ()
 Returns the current level of water. More...
 
float GetLevel (CObject *object)
 Returns the current level of water for a given object. More...
 
void AdjustEye (Math::Vector &eye)
 Adjusts the eye of the camera, not to be in the water. More...
 
void SetLava (bool lava)
 Management of the mode of lava/water. More...
 
bool GetLava ()
 

Protected Member Functions

bool EventFrame (const Event &event)
 Makes water evolve. More...
 
void LavaFrame (float rTime)
 Makes evolve the steam jets on the lava. More...
 
void AdjustLevel (Math::Vector &pos, Math::Vector &norm, Math::Point &uv1, Math::Point &uv2)
 Adjusts the position to normal, to imitate reflections on an expanse of water at rest. More...
 
bool GetWater (int x, int y)
 Indicates if there is water in a given position. More...
 
void CreateLine (int x, int y, int len)
 Updates the positions, relative to the ground. More...
 
void VaporFlush ()
 Removes all the steam jets. More...
 
bool VaporCreate (ParticleType type, Math::Vector pos, float delay)
 Creates a new steam. More...
 
void VaporFrame (int i, float rTime)
 Makes evolve a steam jet. More...
 

Protected Attributes

CEnginem_engine = nullptr
 
CDevicem_device = nullptr
 
CTerrainm_terrain = nullptr
 
CParticlem_particle = nullptr
 
CSoundInterfacem_sound = nullptr
 
WaterType m_type [2] = {}
 
std::string m_fileName
 
float m_level = 0.0f
 Overall level. More...
 
float m_glint = 0.0f
 Amplitude of reflections. More...
 
Math::Vector m_eddy
 Amplitude of swirls. More...
 
Color m_diffuse
 Diffuse color. More...
 
Color m_ambient
 Ambient color. More...
 
float m_time = 0.0f
 
float m_lastLava = 0.0f
 
int m_subdiv = 4
 
int m_brickCount = 0
 Number of brick*mosaics. More...
 
float m_brickSize = 0
 Size of a item in an brick. More...
 
std::vector< WaterLinem_lines
 
std::vector< WaterVaporm_vapors
 
bool m_draw = true
 
bool m_lava = false
 
Color m_color = Color(1.0f, 1.0f, 1.0f, 1.0f)
 

Detailed Description

Water manager/renderer.

Water is drawn where the terrain is below specified level. The mapping is based on terrain coordinates - for each "brick" coordinate, the level of terrain is tested. For every Y coordinate, many lines in X direction are created (WaterLines).

There are two parts of drawing process: drawing the background image blocking the normal sky layer and drawing the surface of water. The surface is drawn with texture, so with proper texture it can be lava.

Member Function Documentation

void Gfx::CWater::Flush ( )

Removes all the water.

void Gfx::CWater::Create ( WaterType  type1,
WaterType  type2,
const std::string &  fileName,
Color  diffuse,
Color  ambient,
float  level,
float  glint,
Math::Vector  eddy 
)

Creates all expanses of water.

void Gfx::CWater::DrawBack ( )

Draw the back surface of the water.

This surface prevents to see the sky (background) underwater!

void Gfx::CWater::DrawSurf ( )

Draws the flat surface of the water.

void Gfx::CWater::SetLevel ( float  level)

Changes the level of the water.

float Gfx::CWater::GetLevel ( )

Returns the current level of water.

float Gfx::CWater::GetLevel ( CObject object)

Returns the current level of water for a given object.

void Gfx::CWater::SetLava ( bool  lava)

Management of the mode of lava/water.

void Gfx::CWater::AdjustEye ( Math::Vector eye)

Adjusts the eye of the camera, not to be in the water.

bool Gfx::CWater::EventFrame ( const Event event)
protected

Makes water evolve.

void Gfx::CWater::LavaFrame ( float  rTime)
protected

Makes evolve the steam jets on the lava.

void Gfx::CWater::AdjustLevel ( Math::Vector pos,
Math::Vector norm,
Math::Point uv1,
Math::Point uv2 
)
protected

Adjusts the position to normal, to imitate reflections on an expanse of water at rest.

bool Gfx::CWater::GetWater ( int  x,
int  y 
)
protected

Indicates if there is water in a given position.

void Gfx::CWater::CreateLine ( int  x,
int  y,
int  len 
)
protected

Updates the positions, relative to the ground.

void Gfx::CWater::VaporFlush ( )
protected

Removes all the steam jets.

bool Gfx::CWater::VaporCreate ( ParticleType  type,
Math::Vector  pos,
float  delay 
)
protected

Creates a new steam.

void Gfx::CWater::VaporFrame ( int  i,
float  rTime 
)
protected

Makes evolve a steam jet.

Member Data Documentation

float Gfx::CWater::m_level = 0.0f
protected

Overall level.

float Gfx::CWater::m_glint = 0.0f
protected

Amplitude of reflections.

Math::Vector Gfx::CWater::m_eddy
protected

Amplitude of swirls.

Color Gfx::CWater::m_diffuse
protected

Diffuse color.

Color Gfx::CWater::m_ambient
protected

Ambient color.

int Gfx::CWater::m_brickCount = 0
protected

Number of brick*mosaics.

float Gfx::CWater::m_brickSize = 0
protected

Size of a item in an brick.


The documentation for this class was generated from the following files: