diff --git a/graphics/icons.svg b/graphics/icons.svg
index ab65164..bec6ff5 100644
--- a/graphics/icons.svg
+++ b/graphics/icons.svg
@@ -14,7 +14,7 @@
height="297mm"
id="svg2"
version="1.1"
- inkscape:version="0.48.4 r9939"
+ inkscape:version="0.91 r13725"
sodipodi:docname="icons.svg"
inkscape:export-filename="/home/michael/workspace/paysages3d/graphics/icons.png"
inkscape:export-xdpi="154.89854"
@@ -28,19 +28,21 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="1.979899"
- inkscape:cx="468.77289"
- inkscape:cy="831.55692"
+ inkscape:zoom="2.8"
+ inkscape:cx="274.84974"
+ inkscape:cy="462.35469"
inkscape:document-units="px"
inkscape:current-layer="g3986"
showgrid="true"
inkscape:window-width="1920"
- inkscape:window-height="1030"
+ inkscape:window-height="1037"
inkscape:window-x="1440"
- inkscape:window-y="25"
- inkscape:window-maximized="1"
+ inkscape:window-y="20"
+ inkscape:window-maximized="0"
showguides="true"
- inkscape:snap-object-midpoints="false">
+ inkscape:snap-object-midpoints="false"
+ inkscape:object-nodes="false"
+ inkscape:snap-grids="true">
@@ -99,6 +101,13 @@
sodipodi:nodetypes="ccccccccccc" />
+
@@ -191,6 +200,18 @@
d="m 440,292.36218 65,95 70,-95"
id="path4025"
inkscape:connector-curvature="0" />
+
+
diff --git a/src/definition/WaterDefinition.cpp b/src/definition/WaterDefinition.cpp
index e238755..e6bd72a 100644
--- a/src/definition/WaterDefinition.cpp
+++ b/src/definition/WaterDefinition.cpp
@@ -4,10 +4,13 @@
#include "NoiseState.h"
#include "Color.h"
#include "SurfaceMaterial.h"
+#include "FloatNode.h"
WaterDefinition::WaterDefinition(DefinitionNode* parent):
DefinitionNode(parent, "water", "water")
{
+ reflection = new FloatNode(this, "reflection");
+
material = new SurfaceMaterial;
depth_color = new Color;
foam_material = new SurfaceMaterial;
@@ -15,7 +18,6 @@ WaterDefinition::WaterDefinition(DefinitionNode* parent):
transparency_depth = 0.0;
transparency = 0.0;
- reflection = 0.0;
lighting_depth = 0.0;
scaling = 1.0;
waves_height = 0.0;
@@ -40,7 +42,6 @@ void WaterDefinition::save(PackStream* stream) const
depth_color->save(stream);
stream->write(&transparency_depth);
stream->write(&transparency);
- stream->write(&reflection);
stream->write(&lighting_depth);
stream->write(&scaling);
@@ -62,7 +63,6 @@ void WaterDefinition::load(PackStream* stream)
depth_color->load(stream);
stream->read(&transparency_depth);
stream->read(&transparency);
- stream->read(&reflection);
stream->read(&lighting_depth);
stream->read(&scaling);
@@ -87,7 +87,6 @@ void WaterDefinition::copy(DefinitionNode* _destination) const
*destination->depth_color = *depth_color;
destination->transparency_depth = transparency_depth;
destination->transparency = transparency;
- destination->reflection = reflection;
destination->lighting_depth = lighting_depth;
destination->scaling = scaling;
destination->waves_height = waves_height;
@@ -113,7 +112,7 @@ void WaterDefinition::applyPreset(WaterPreset preset)
if (preset == WATER_PRESET_LAKE)
{
transparency = 0.5;
- reflection = 0.2;
+ reflection->setValue(0.2);
transparency_depth = 4.0;
material->setColor(0.08, 0.15, 0.2, 1.0);
depth_color->r = 0.0;
@@ -129,7 +128,7 @@ void WaterDefinition::applyPreset(WaterPreset preset)
else if (preset == WATER_PRESET_SEA)
{
transparency = 0.3;
- reflection = 0.07;
+ reflection->setValue(0.07);
transparency_depth = 3.0;
material->setColor(0.05, 0.18, 0.2, 1.0);
depth_color->r = 0.0;
diff --git a/src/definition/WaterDefinition.h b/src/definition/WaterDefinition.h
index 5564c0a..c55f999 100644
--- a/src/definition/WaterDefinition.h
+++ b/src/definition/WaterDefinition.h
@@ -20,6 +20,8 @@ public:
virtual void copy(DefinitionNode* destination) const override;
virtual void validate() override;
+ inline FloatNode *propReflection() const {return reflection;}
+
public:
typedef enum
{
@@ -30,7 +32,6 @@ public:
public:
double transparency;
- double reflection;
SurfaceMaterial* material;
Color* depth_color;
double transparency_depth;
@@ -45,6 +46,9 @@ public:
SurfaceMaterial* foam_material;
NoiseState* noise_state;
+
+private:
+ FloatNode *reflection;
};
}
diff --git a/src/interface/modeler/quickapp/WaterModeler.cpp b/src/interface/modeler/quickapp/WaterModeler.cpp
index 4ee6884..4f4fe73 100644
--- a/src/interface/modeler/quickapp/WaterModeler.cpp
+++ b/src/interface/modeler/quickapp/WaterModeler.cpp
@@ -3,6 +3,7 @@
#include "MainModelerWindow.h"
#include "Scenery.h"
#include "TerrainDefinition.h"
+#include "WaterDefinition.h"
#include "FloatPropertyBind.h"
#include "OpenGLRenderer.h"
#include "OpenGLWater.h"
@@ -17,11 +18,13 @@ WaterModeler::WaterModeler(MainModelerWindow *ui):
}
prop_water_height = new FloatPropertyBind(ui, "water_height", "value", ui->getScenery()->getTerrain()->propWaterHeight());
+ prop_water_reflexion = new FloatPropertyBind(ui, "water_reflection", "value", ui->getScenery()->getWater()->propReflection());
}
WaterModeler::~WaterModeler()
{
delete prop_water_height;
+ delete prop_water_reflexion;
}
void WaterModeler::enableRendering(bool enable)
diff --git a/src/interface/modeler/quickapp/WaterModeler.h b/src/interface/modeler/quickapp/WaterModeler.h
index d2840d5..a50a9a1 100644
--- a/src/interface/modeler/quickapp/WaterModeler.h
+++ b/src/interface/modeler/quickapp/WaterModeler.h
@@ -21,6 +21,7 @@ public slots:
private:
MainModelerWindow *ui;
FloatPropertyBind *prop_water_height;
+ FloatPropertyBind *prop_water_reflexion;
};
}
diff --git a/src/interface/modeler/quickapp/qml/WaterSection.qml b/src/interface/modeler/quickapp/qml/WaterSection.qml
index f549c8c..d77d6ce 100644
--- a/src/interface/modeler/quickapp/qml/WaterSection.qml
+++ b/src/interface/modeler/quickapp/qml/WaterSection.qml
@@ -13,6 +13,13 @@ BaseSection {
picture: "images/icon_water_level.png"
hovertext: qsTr("Change the water altitude")
}
+
+ ToolbarButton {
+ id: tool_water_reflection
+ checked: false
+ picture: "images/icon_water_reflection.png"
+ hovertext: qsTr("Reflection of the water surface")
+ }
}
PanelSimpleFloat {
@@ -24,6 +31,13 @@ BaseSection {
objectName: "water_height"
}
+ PanelSimpleFloat {
+ id: panel_water_reflection
+ enabled: false
+ anchors.left: toolbar.right
+ objectName: "water_reflection"
+ }
+
states: [
State {
name: "WaterHeight"
@@ -32,6 +46,14 @@ BaseSection {
target: panel_water_level
enabled: true
}
+ },
+ State {
+ name: "WaterReflection"
+ when: tool_water_reflection.checked
+ PropertyChanges {
+ target: panel_water_reflection
+ enabled: true
+ }
}
]
}
diff --git a/src/interface/modeler/quickapp/qml/app.qrc b/src/interface/modeler/quickapp/qml/app.qrc
index b33947d..73d2d65 100644
--- a/src/interface/modeler/quickapp/qml/app.qrc
+++ b/src/interface/modeler/quickapp/qml/app.qrc
@@ -43,5 +43,6 @@
BaseSection.qml
AtmosphereSection.qml
PanelSimpleFloat.qml
+ images/icon_water_reflection.png
diff --git a/src/interface/modeler/quickapp/qml/images/icon_water_reflection.png b/src/interface/modeler/quickapp/qml/images/icon_water_reflection.png
new file mode 100644
index 0000000..5939053
Binary files /dev/null and b/src/interface/modeler/quickapp/qml/images/icon_water_reflection.png differ
diff --git a/src/render/opengl/OpenGLRenderer.cpp b/src/render/opengl/OpenGLRenderer.cpp
index 89ae900..f6567da 100644
--- a/src/render/opengl/OpenGLRenderer.cpp
+++ b/src/render/opengl/OpenGLRenderer.cpp
@@ -156,7 +156,7 @@ void OpenGLRenderer::paint()
}
int error_code;
- while ((error_code = glGetError()) != GL_NO_ERROR)
+ while ((error_code = functions->glGetError()) != GL_NO_ERROR)
{
Logs::warning() << "[OpenGL] ERROR : " << error_code << std::endl;
}
diff --git a/src/render/opengl/OpenGLWater.cpp b/src/render/opengl/OpenGLWater.cpp
index 5406e1e..7d057d4 100644
--- a/src/render/opengl/OpenGLWater.cpp
+++ b/src/render/opengl/OpenGLWater.cpp
@@ -41,6 +41,7 @@ void OpenGLWater::initialize()
// Watch for definition changes
renderer->getScenery()->getTerrain()->propWaterHeight()->addWatcher(this, true);
+ renderer->getScenery()->getWater()->propReflection()->addWatcher(this, true);
}
void OpenGLWater::update()
@@ -48,9 +49,6 @@ void OpenGLWater::update()
Color water_color = *renderer->getScenery()->getWater()->material->base;
renderer->getSharedState()->set("waterColor", water_color);
- double water_reflection = renderer->getScenery()->getWater()->reflection;
- renderer->getSharedState()->set("waterReflection", water_reflection);
-
renderer->getSharedState()->set("simplexSampler", NoiseFunctionSimplex::getNormalTexture(), true, true);
}
@@ -75,6 +73,10 @@ void OpenGLWater::nodeChanged(const DefinitionNode *node, const DefinitionDiff *
{
renderer->getSharedState()->set("waterOffset", renderer->getScenery()->getTerrain()->getWaterOffset());
}
+ else if (node->getPath() == "/water/reflection")
+ {
+ renderer->getSharedState()->set("waterReflection", renderer->getScenery()->getWater()->propReflection()->getValue());
+ }
}
void OpenGLWater::setEnabled(bool enabled)
diff --git a/src/render/software/WaterRenderer.cpp b/src/render/software/WaterRenderer.cpp
index 75ca18c..a1a0a11 100644
--- a/src/render/software/WaterRenderer.cpp
+++ b/src/render/software/WaterRenderer.cpp
@@ -8,6 +8,7 @@
#include "Scenery.h"
#include "SurfaceMaterial.h"
#include "NoiseFunctionSimplex.h"
+#include "FloatNode.h"
WaterRenderer::WaterRenderer(SoftwareRenderer* parent):
parent(parent)
@@ -172,6 +173,7 @@ WaterRenderer::WaterResult WaterRenderer::getResult(double x, double z)
Vector3 location, normal, look_direction;
Color color, foam;
double detail, depth;
+ double reflection = definition->propReflection()->getValue();
location.x = x;
location.y = _getHeight(noise, x, z);
@@ -188,7 +190,7 @@ WaterRenderer::WaterResult WaterRenderer::getResult(double x, double z)
look_direction = location.sub(parent->getCameraLocation(location)).normalize();
/* Reflection */
- if (definition->reflection == 0.0)
+ if (reflection == 0.0)
{
result.reflected = COLOR_BLACK;
}
@@ -225,9 +227,9 @@ WaterRenderer::WaterResult WaterRenderer::getResult(double x, double z)
/* Lighting from environment */
color = parent->applyLightingToSurface(location, normal, *definition->material);
- color.r += result.reflected.r * definition->reflection + result.refracted.r * definition->transparency;
- color.g += result.reflected.g * definition->reflection + result.refracted.g * definition->transparency;
- color.b += result.reflected.b * definition->reflection + result.refracted.b * definition->transparency;
+ color.r += result.reflected.r * reflection + result.refracted.r * definition->transparency;
+ color.g += result.reflected.g * reflection + result.refracted.g * definition->transparency;
+ color.b += result.reflected.b * reflection + result.refracted.b * definition->transparency;
/* Merge with foam */
foam = _getFoamMask(parent, definition, noise, location, normal, detail);