From dd0fceb5c983539e57a840370010be9678cdb2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Fri, 18 Jan 2013 10:31:13 +0000 Subject: [PATCH] paysages : Apply HDR to 3d explorer. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@499 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- gui_qt/baseexplorerchunk.cpp | 3 +++ gui_qt/baseexplorerchunk.h | 9 +++++---- gui_qt/explorerchunksky.cpp | 7 ++++++- gui_qt/widgetexplorer.cpp | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gui_qt/baseexplorerchunk.cpp b/gui_qt/baseexplorerchunk.cpp index 70b6379..731751b 100644 --- a/gui_qt/baseexplorerchunk.cpp +++ b/gui_qt/baseexplorerchunk.cpp @@ -3,6 +3,7 @@ BaseExplorerChunk::BaseExplorerChunk(Renderer* renderer) { _renderer = renderer; + _color_profile = colorProfileCreate(); priority = 0.0; _reset_needed = false; @@ -17,6 +18,7 @@ BaseExplorerChunk::BaseExplorerChunk(Renderer* renderer) BaseExplorerChunk::~BaseExplorerChunk() { _lock_data.lock(); + colorProfileDelete(_color_profile); delete _texture; _lock_data.unlock(); } @@ -48,6 +50,7 @@ bool BaseExplorerChunk::maintain() if (_texture_current_size <= 1 || i % 2 != 0 || j % 2 != 0) { Color color = getTextureColor((double)i / (double)new_texture_size, 1.0 - (double)j / (double)new_texture_size); + color = colorProfileApply(_color_profile, color); colorNormalize(&color); new_image->setPixel(i, j, colorTo32BitBGRA(&color)); } diff --git a/gui_qt/baseexplorerchunk.h b/gui_qt/baseexplorerchunk.h index 3f64290..2b7b036 100644 --- a/gui_qt/baseexplorerchunk.h +++ b/gui_qt/baseexplorerchunk.h @@ -14,27 +14,28 @@ public: bool maintain(); void updatePriority(CameraDefinition* camera); void render(QGLWidget* widget); - + double priority; protected: BaseExplorerChunk(Renderer* renderer); - + inline Renderer* renderer() {return _renderer;}; void askReset(); void setMaxTextureSize(int size); - + virtual void onCameraEvent(CameraDefinition* camera); virtual void onResetEvent(); virtual bool onMaintainEvent(); virtual void onRenderEvent(QGLWidget* widget); virtual double getDisplayedSizeHint(CameraDefinition* camera); virtual Color getTextureColor(double x, double y); - + QMutex _lock_data; private: Renderer* _renderer; + ColorProfile* _color_profile; bool _reset_needed; diff --git a/gui_qt/explorerchunksky.cpp b/gui_qt/explorerchunksky.cpp index e73d6d3..6fffa19 100644 --- a/gui_qt/explorerchunksky.cpp +++ b/gui_qt/explorerchunksky.cpp @@ -130,5 +130,10 @@ Color ExplorerChunkSky::getTextureColor(double x, double y) location.z = y; break; } - return renderer()->atmosphere->getSkyColor(renderer(), v3Normalize(location)); + location = v3Normalize(location); + if (location.y < 0.0) + { + location.y = 0.0; + } + return renderer()->atmosphere->getSkyColor(renderer(), location); } diff --git a/gui_qt/widgetexplorer.cpp b/gui_qt/widgetexplorer.cpp index ad59a61..75749ce 100644 --- a/gui_qt/widgetexplorer.cpp +++ b/gui_qt/widgetexplorer.cpp @@ -100,7 +100,7 @@ WidgetExplorer::WidgetExplorer(QWidget *parent, CameraDefinition* camera): } // Add skybox - for (int orientation = 0; orientation < 6; orientation++) + for (int orientation = 0; orientation < 5; orientation++) { ExplorerChunkSky* chunk = new ExplorerChunkSky(&_renderer, 500.0, (SkyboxOrientation)orientation); _chunks.append(chunk);