From a35a9c6e8a0fe819e7c81fc71ab6d802d77dcc90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Mon, 11 Mar 2013 14:15:30 +0000 Subject: [PATCH] paysages : Added clouds option to render preview. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@539 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- gui_qt/formrender.cpp | 28 ++++++++++++++++++++-------- lib_paysages/scenery.c | 12 ++++++++---- lib_paysages/scenery.h | 1 + 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/gui_qt/formrender.cpp b/gui_qt/formrender.cpp index 63d5e9f..dbea1c2 100644 --- a/gui_qt/formrender.cpp +++ b/gui_qt/formrender.cpp @@ -12,7 +12,7 @@ class PreviewRenderLandscape:public BasePreview public: PreviewRenderLandscape(QWidget* parent):BasePreview(parent) { - _renderer = rendererCreate(); + _renderer = sceneryCreateStandardRenderer(); _renderer->applyTextures = _applyTextures; _renderer->getCameraLocation = _getCameraLocation; lightingManagerDisableSpecularity(_renderer->lighting); @@ -22,10 +22,14 @@ public: _atmosphere = (AtmosphereDefinition*)AtmosphereDefinitionClass.create(); _terrain = (TerrainDefinition*)TerrainDefinitionClass.create(); _water = (WaterDefinition*)WaterDefinitionClass.create(); + _clouds = (CloudsDefinition*)CloudsDefinitionClass.create(); _renderer->customData[0] = &_textures; + _clouds_enabled = true; + addOsd(QString("geolocation")); + addToggle("clouds", tr("Clouds"), false); configHdrToneMapping(true); configScaling(0.5, 200.0, 3.0, 50.0); @@ -53,18 +57,26 @@ protected: { sceneryGetTextures(&_textures); - sceneryGetWater(_water); - WaterRendererClass.bind(_renderer, _water); - - sceneryGetAtmosphere(_atmosphere); - AtmosphereRendererClass.bind(_renderer, _atmosphere); + sceneryBindRenderer(_renderer); _renderer->atmosphere->applyAerialPerspective = _applyAerialPerspective; - sceneryGetTerrain(_terrain); - TerrainRendererClass.bind(_renderer, _terrain); + if (!_clouds_enabled) + { + CloudsRendererClass.bind(_renderer, _clouds); + } + } + void toggleChangeEvent(QString key, bool value) + { + if (key == "clouds") + { + _clouds_enabled = value; + redraw(); + } } private: Renderer* _renderer; + bool _clouds_enabled; + CloudsDefinition* _clouds; TerrainDefinition* _terrain; WaterDefinition *_water; TexturesDefinition _textures; diff --git a/lib_paysages/scenery.c b/lib_paysages/scenery.c index 68691c7..7e09826 100644 --- a/lib_paysages/scenery.c +++ b/lib_paysages/scenery.c @@ -232,11 +232,15 @@ Renderer* sceneryCreateStandardRenderer() result->unprojectPoint = _unprojectPoint; result->getPrecision = _getPrecision; - AtmosphereRendererClass.bind(result, _atmosphere); - TerrainRendererClass.bind(result, _terrain); - CloudsRendererClass.bind(result, _clouds); - WaterRendererClass.bind(result, _water); + sceneryBindRenderer(result); return result; } +void sceneryBindRenderer(Renderer* renderer) +{ + AtmosphereRendererClass.bind(renderer, _atmosphere); + TerrainRendererClass.bind(renderer, _terrain); + CloudsRendererClass.bind(renderer, _clouds); + WaterRendererClass.bind(renderer, _water); +} diff --git a/lib_paysages/scenery.h b/lib_paysages/scenery.h index 71ccc90..3b09155 100644 --- a/lib_paysages/scenery.h +++ b/lib_paysages/scenery.h @@ -52,6 +52,7 @@ void scenerySetWater(WaterDefinition* water); void sceneryGetWater(WaterDefinition* water); Renderer* sceneryCreateStandardRenderer(); +void sceneryBindRenderer(Renderer* renderer); void sceneryRenderFirstPass(Renderer* renderer); #ifdef __cplusplus