Colobot
Loading...
Searching...
No Matches
Gfx::CWater Class Reference

Water manager/renderer. More...

#include <src/graphics/engine/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.
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.
void DrawBack ()
 Draw the back surface of the water.
void DrawSurf ()
 Draws the flat surface of the water.
void SetLevel (float level)
 Changes the level of the water.
float GetLevel ()
 Returns the current level of water.
float GetLevel (CObject *object)
 Returns the current level of water for a given object.
void SetLava (bool lava)
 Management of the mode of lava/water.
bool GetLava ()
void AdjustEye (Math::Vector &eye)
 Adjusts the eye of the camera, not to be in the water.

Protected Member Functions

bool EventFrame (const Event &event)
 Makes water evolve.
void LavaFrame (float rTime)
 Makes evolve the steam jets on the lava.
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.
bool GetWater (int x, int y)
 Indicates if there is water in a given position.
void CreateLine (int x, int y, int len)
 Updates the positions, relative to the ground.
void VaporFlush ()
 Removes all the steam jets.
bool VaporCreate (ParticleType type, Math::Vector pos, float delay)
 Creates a new steam.
void VaporFrame (int i, float rTime)
 Makes evolve a steam jet.

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.
float m_glint = 0.0f
 Amplitude of reflections.
Math::Vector m_eddy
 Amplitude of swirls.
Color m_diffuse
 Diffuse color.
Color m_ambient
 Ambient color.
float m_time = 0.0f
float m_lastLava = 0.0f
int m_subdiv = 4
int m_brickCount = 0
 Number of brick*mosaics.
float m_brickSize = 0
 Size of a item in an brick.
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

◆ Flush()

void Gfx::CWater::Flush ( )

Removes all the water.

◆ Create()

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.

◆ DrawBack()

void Gfx::CWater::DrawBack ( )

Draw the back surface of the water.

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

◆ DrawSurf()

void Gfx::CWater::DrawSurf ( )

Draws the flat surface of the water.

◆ SetLevel()

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

Changes the level of the water.

◆ GetLevel() [1/2]

float Gfx::CWater::GetLevel ( )

Returns the current level of water.

◆ GetLevel() [2/2]

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

Returns the current level of water for a given object.

◆ SetLava()

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

Management of the mode of lava/water.

◆ AdjustEye()

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

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

◆ EventFrame()

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

Makes water evolve.

◆ LavaFrame()

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

Makes evolve the steam jets on the lava.

◆ AdjustLevel()

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.

◆ GetWater()

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

Indicates if there is water in a given position.

◆ CreateLine()

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

Updates the positions, relative to the ground.

◆ VaporFlush()

void Gfx::CWater::VaporFlush ( )
protected

Removes all the steam jets.

◆ VaporCreate()

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

Creates a new steam.

◆ VaporFrame()

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

Makes evolve a steam jet.

Member Data Documentation

◆ m_level

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

Overall level.

◆ m_glint

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

Amplitude of reflections.

◆ m_eddy

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

Amplitude of swirls.

◆ m_diffuse

Color Gfx::CWater::m_diffuse
protected

Diffuse color.

◆ m_ambient

Color Gfx::CWater::m_ambient
protected

Ambient color.

◆ m_brickCount

int Gfx::CWater::m_brickCount = 0
protected

Number of brick*mosaics.

◆ m_brickSize

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: