RigsofRods
Soft-body Physics Simulation
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Functions
_
a
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Variables
a
b
c
d
e
f
g
i
k
l
m
n
p
r
s
t
u
v
w
Typedefs
a
c
d
e
f
g
l
m
n
o
p
r
s
t
v
w
Enumerations
a
b
c
d
e
f
g
h
i
k
l
m
n
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
a
b
c
d
g
h
l
m
n
o
p
r
s
t
v
Enumerator
a
b
c
d
f
g
h
l
m
n
o
r
s
t
v
Related Functions
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Enumerator
k
o
Macros
_
a
b
c
d
e
f
h
i
l
m
n
o
p
r
s
t
x
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
source
main
gfx
HydraxWater.cpp
Go to the documentation of this file.
1
/*
2
This source file is part of Rigs of Rods
3
Copyright 2005-2012 Pierre-Michel Ricordel
4
Copyright 2007-2012 Thomas Fischer
5
Copyright 2013-2016 Petr Ohlidal
6
7
For more information, see http://www.rigsofrods.org/
8
Rigs of Rods is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License version 3, as
10
published by the Free Software Foundation.
11
12
Rigs of Rods is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
21
#include "
HydraxWater.h
"
22
23
#include "
Actor.h
"
24
#include "
AppContext.h
"
25
#include "
CameraManager.h
"
26
#include "
GameContext.h
"
27
#include "
GfxScene.h
"
28
#include "
SkyManager.h
"
29
#include "
Terrain.h
"
30
31
#ifdef USE_CAELUM
32
#include <Caelum.h>
33
#endif // USE_CAELUM
34
35
using namespace
Ogre
;
36
using namespace
RoR
;
37
38
// HydraxWater
39
HydraxWater::HydraxWater(
float
water_height, Ogre::String conf_file):
40
waternoise(0)
41
, mHydrax(0)
42
, waterHeight(water_height)
43
, waveHeight(water_height)
44
, CurrentConfigFile(conf_file)
45
{
46
App::GetCameraManager
()->
GetCamera
()->setNearClipDistance(0.1f);
47
48
InitHydrax
();
49
}
50
51
HydraxWater::~HydraxWater
()
52
{
53
mHydrax
->
remove
();
54
mHydrax
=
nullptr
;
55
}
56
57
void
HydraxWater::InitHydrax
()
58
{
59
mHydrax
=
new
Hydrax::Hydrax
(
App::GetGfxScene
()->GetSceneManager(),
App::GetCameraManager
()->GetCamera(),
RoR::App::GetAppContext
()->GetViewport());
60
61
waternoise
=
new
Hydrax::Noise::Perlin
();
62
mModule
=
new
Hydrax::Module::ProjectedGrid
(
// Hydrax parent pointer
63
mHydrax
,
64
// Noise module
65
waternoise
,
66
// Base plane
67
Ogre::Plane(Ogre::Vector3::UNIT_Y, 0),
68
// Normal mode
69
Hydrax::MaterialManager::NM_VERTEX
,
70
// Projected grid options
71
Hydrax::Module::ProjectedGrid::Options
());
72
73
mHydrax
->
setModule
(
static_cast<
Hydrax::Module::Module
*
>
(
mModule
));
74
75
mHydrax
->
loadCfg
(
CurrentConfigFile
);
76
77
// Choose shader language based on renderer (HLSL=0, CG=1, GLSL=2)
78
if
(Root::getSingleton().getRenderSystem()->
getName
() ==
"Direct3D9 Rendering Subsystem"
|| Root::getSingleton().getRenderSystem()->
getName
() ==
"Direct3D11 Rendering Subsystem"
)
79
{
80
mHydrax
->
setShaderMode
(
static_cast<
Hydrax::MaterialManager::ShaderMode
>
(0));
81
}
82
else
83
{
84
mHydrax
->
setShaderMode
(
static_cast<
Hydrax::MaterialManager::ShaderMode
>
(2));
85
}
86
87
mHydrax
->
create
();
88
mHydrax
->
setPosition
(Ogre::Vector3(0,
waterHeight
, 0));
89
}
90
91
bool
HydraxWater::IsUnderWater
(Ogre::Vector3 pos)
92
{
93
if
(pos.y <
CalcWavesHeight
(Ogre::Vector3(pos.x, pos.y, pos.z)))
94
return
true
;
95
return
false
;
96
}
97
98
void
HydraxWater::UpdateWater
()
99
{
100
#ifdef USE_CAELUM
101
if
(
RoR::App::GetGameContext
()->GetTerrain()->getSkyManager() !=
nullptr
)
102
{
103
SkyManager* sky =
RoR::App::GetGameContext
()->
GetTerrain
()->
getSkyManager
();
104
Ogre::Vector3 sunPosition =
App::GetCameraManager
()->
GetCameraNode
()->_getDerivedPosition();
105
sunPosition -= sky->GetCaelumSys()->getSun()->getLightDirection() * 80000;
106
mHydrax
->
setSunPosition
(sunPosition);
107
mHydrax
->
setSunColor
(Ogre::Vector3(sky->GetCaelumSys()->getSun()->getBodyColour().r, sky->GetCaelumSys()->getSun()->getBodyColour().g, sky->GetCaelumSys()->getSun()->getBodyColour().b));
108
}
109
#endif // USE_CAELUM
110
}
111
112
float
HydraxWater::GetStaticWaterHeight
()
113
{
114
return
waterHeight
;
115
}
116
117
void
HydraxWater::SetStaticWaterHeight
(
float
value)
118
{
119
waterHeight
= value;
120
}
121
122
void
HydraxWater::SetWaterVisible
(
bool
value)
123
{
124
if
(
mHydrax
)
125
mHydrax
->
setVisible
(value);
126
}
127
128
float
HydraxWater::CalcWavesHeight
(Vector3 pos)
129
{
130
if
(!
RoR::App::gfx_water_waves
->getBool())
131
{
132
return
waterHeight
;
133
}
134
waveHeight
=
mHydrax
->
getHeigth
(pos);
135
return
waveHeight
;
136
}
137
138
Vector3
HydraxWater::CalcWavesVelocity
(Vector3 pos)
139
{
140
if
(!
RoR::App::gfx_water_waves
->getBool())
141
return
Vector3(0, 0, 0);
142
143
return
Vector3(0, 0, 0);
//TODO
144
}
145
146
void
HydraxWater::WaterSetSunPosition
(Ogre::Vector3 pos)
147
{
148
if
(
mHydrax
)
149
mHydrax
->
setSunPosition
(pos);
150
}
151
152
void
HydraxWater::FrameStepWater
(
float
dt)
153
{
154
if
(
mHydrax
)
155
{
156
mHydrax
->
update
(dt);
157
}
158
this->
UpdateWater
();
159
}
160
GameContext.h
Game state manager and message-queue provider.
Hydrax::Hydrax::setSunColor
void setSunColor(const Ogre::Vector3 &SunColor)
Set sun color.
Definition:
Hydrax.cpp:947
RoR::HydraxWater::CalcWavesVelocity
Ogre::Vector3 CalcWavesVelocity(Ogre::Vector3 pos) override
Definition:
HydraxWater.cpp:138
RoR::App::GetCameraManager
CameraManager * GetCameraManager()
Definition:
Application.cpp:279
Hydrax::Hydrax::update
void update(const Ogre::Real &timeSinceLastFrame)
Call every frame.
Definition:
Hydrax.cpp:291
SkyManager.h
RoR::HydraxWater::WaterSetSunPosition
void WaterSetSunPosition(Ogre::Vector3) override
Definition:
HydraxWater.cpp:146
RoR::App::GetAppContext
AppContext * GetAppContext()
Definition:
Application.cpp:270
Hydrax::Hydrax::setSunPosition
void setSunPosition(const Ogre::Vector3 &SunPosition)
Set sun position.
Definition:
Hydrax.cpp:884
RoR::Terrain::getSkyManager
SkyManager * getSkyManager()
Definition:
Terrain.cpp:515
CameraManager.h
RoR::HydraxWater::SetWaterVisible
void SetWaterVisible(bool value) override
Definition:
HydraxWater.cpp:122
AppContext.h
System integration layer; inspired by OgreBites::ApplicationContext.
RoR::CameraManager::GetCameraNode
Ogre::SceneNode * GetCameraNode()
Definition:
CameraManager.h:63
Hydrax::Hydrax::create
void create()
Create all resources according with current Hydrax components and add Hydrax to the scene.
Definition:
Hydrax.cpp:103
RoR::HydraxWater::IsUnderWater
bool IsUnderWater(Ogre::Vector3 pos) override
Definition:
HydraxWater.cpp:91
Actor.h
RoR::HydraxWater::~HydraxWater
~HydraxWater()
Definition:
HydraxWater.cpp:51
RoR::HydraxWater::waternoise
Hydrax::Noise::Perlin * waternoise
Definition:
HydraxWater.h:60
RoR::HydraxWater::mHydrax
Hydrax::Hydrax * mHydrax
Definition:
HydraxWater.h:57
RoR::HydraxWater::waveHeight
float waveHeight
Definition:
HydraxWater.h:58
RoR::HydraxWater::SetStaticWaterHeight
void SetStaticWaterHeight(float value) override
Definition:
HydraxWater.cpp:117
RoR::CameraManager::GetCamera
Ogre::Camera * GetCamera()
Definition:
CameraManager.h:64
RoR::HydraxWater::GetStaticWaterHeight
float GetStaticWaterHeight() override
Returns static water level configured in 'terrn2'.
Definition:
HydraxWater.cpp:112
Hydrax::Hydrax::setModule
void setModule(Module::Module *Module, const bool &DeleteOldModule=true)
Set Hydrax module.
Definition:
Hydrax.cpp:527
GfxScene.h
RoR::HydraxWater::UpdateWater
void UpdateWater() override
Definition:
HydraxWater.cpp:98
Hydrax::Module::Module
Base module class, Override it for create different ways of create water noise.
Definition:
Module.h:46
RoR::App::GetGameContext
GameContext * GetGameContext()
Definition:
Application.cpp:284
Hydrax::Module::ProjectedGrid
Hydrax projected grid module.
Definition:
ProjectedGrid.h:50
Hydrax::Hydrax::loadCfg
const bool loadCfg(const Ogre::String &File) const
Load config from file.
Definition:
Hydrax.h:142
Hydrax::Hydrax::remove
void remove()
Remove hydrax, you can call this method to remove Hydrax from the scene or release (secondary) Hydrax...
Definition:
Hydrax.cpp:177
RoR::HydraxWater::CurrentConfigFile
Ogre::String CurrentConfigFile
Definition:
HydraxWater.h:62
Hydrax::Hydrax::setPosition
void setPosition(const Ogre::Vector3 &Position)
Set water position.
Definition:
Hydrax.cpp:720
Hydrax::Hydrax
Main Hydrax class.
Definition:
Hydrax.h:56
Hydrax::Module::ProjectedGrid::Options
Struct wich contains Hydrax projected grid module options.
Definition:
ProjectedGrid.h:55
RoR::App::gfx_water_waves
CVar * gfx_water_waves
Definition:
Application.cpp:226
RoR::HydraxWater::waterHeight
float waterHeight
Definition:
HydraxWater.h:59
Hydrax::Hydrax::setVisible
void setVisible(const bool &Visible)
Show/Hide hydrax water.
Definition:
Hydrax.cpp:197
AngelOgre::getName
class AngelOgre::OverlayManager & getName
Terrain.h
Ogre
Definition:
ExtinguishableFireAffector.cpp:35
RoR::HydraxWater::CalcWavesHeight
float CalcWavesHeight(Ogre::Vector3 pos) override
Definition:
HydraxWater.cpp:128
RoR::HydraxWater::mModule
Hydrax::Module::ProjectedGrid * mModule
Definition:
HydraxWater.h:61
Hydrax::Hydrax::setShaderMode
void setShaderMode(const MaterialManager::ShaderMode &ShaderMode)
Set shader mode.
Definition:
Hydrax.cpp:279
Hydrax::MaterialManager::ShaderMode
ShaderMode
Shader mode.
Definition:
MaterialManager.h:88
Hydrax::Noise::Perlin
Perlin noise module class.
Definition:
Perlin.h:73
RoR
Definition:
AppContext.h:36
RoR::HydraxWater::FrameStepWater
void FrameStepWater(float dt) override
Definition:
HydraxWater.cpp:152
RoR::App::GetGfxScene
GfxScene * GetGfxScene()
Definition:
Application.cpp:280
Hydrax::Hydrax::getHeigth
float getHeigth(const Ogre::Vector2 &Position)
Get the current heigth at a especified world-space point.
Definition:
Hydrax.h:430
HydraxWater.h
RoR::HydraxWater::InitHydrax
void InitHydrax()
Definition:
HydraxWater.cpp:57
RoR::GameContext::GetTerrain
const TerrainPtr & GetTerrain()
Definition:
GameContext.h:117
Hydrax::MaterialManager::NM_VERTEX
@ NM_VERTEX
Definition:
MaterialManager.h:105
Generated by
1.8.17