From 9a198c251912bf39b873783f7c7a6bd54261b610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Thu, 26 Jan 2012 22:30:20 +0000 Subject: [PATCH] paysages: Small changes. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@239 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- gui_qt/baseform.cpp | 1 + gui_qt/baseform.h | 3 +++ gui_qt/formterrain.cpp | 28 ++++++++++++++++++++++++---- gui_qt/formwater.cpp | 15 +++++++++++++-- gui_qt/mainwindow.cpp | 20 ++++++++++++++++---- lib_paysages/auto.c | 2 +- lib_paysages/textures.c | 2 +- 7 files changed, 59 insertions(+), 12 deletions(-) diff --git a/gui_qt/baseform.cpp b/gui_qt/baseform.cpp index 314d99d..1c4f630 100644 --- a/gui_qt/baseform.cpp +++ b/gui_qt/baseform.cpp @@ -81,6 +81,7 @@ void BaseForm::revertConfig() void BaseForm::applyConfig() { revertConfig(); + emit(configApplied()); } void BaseForm::addPreview(Preview* preview, QString label) diff --git a/gui_qt/baseform.h b/gui_qt/baseform.h index 6a9a632..d760503 100644 --- a/gui_qt/baseform.h +++ b/gui_qt/baseform.h @@ -15,6 +15,9 @@ class BaseForm:public QWidget public: BaseForm(QWidget* parent); +signals: + void configApplied(); + public slots: virtual void revertConfig(); virtual void applyConfig(); diff --git a/gui_qt/formterrain.cpp b/gui_qt/formterrain.cpp index e370fe2..9a38f51 100644 --- a/gui_qt/formterrain.cpp +++ b/gui_qt/formterrain.cpp @@ -42,20 +42,40 @@ public: PreviewTerrainColor(QWidget* parent):Preview(parent) { _renderer = rendererGetFake(); - _preview_definition = terrainCreateDefinition(); + _renderer.applyTextures = _applyTextures; + _renderer.getTerrainHeight = _getTerrainHeight; + /*_renderer.applyLightingToSurface = _applyLightingToSurface;*/ + + _terrain = terrainCreateDefinition(); + _textures = texturesCreateDefinition(); + + _renderer.customData[0] = &_terrain; + _renderer.customData[1] = &_textures; } protected: QColor getColor(double x, double y) { - return colorToQColor(terrainGetColor(&_preview_definition, &_renderer, x, y, scaling)); + return colorToQColor(terrainGetColor(&_terrain, &_renderer, x, y, scaling)); } void updateData() { - terrainCopyDefinition(&_definition, &_preview_definition); + terrainCopyDefinition(&_definition, &_terrain); + sceneryGetTextures(&_textures); } private: Renderer _renderer; - TerrainDefinition _preview_definition; + TerrainDefinition _terrain; + TexturesDefinition _textures; + + static double _getTerrainHeight(Renderer* renderer, double x, double z) + { + return terrainGetHeight((TerrainDefinition*)(renderer->customData[0]), x, z); + } + + static Color _applyTextures(Renderer* renderer, Vector3 location, double precision) + { + return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location, precision); + } }; /**************** Form ****************/ diff --git a/gui_qt/formwater.cpp b/gui_qt/formwater.cpp index 25c634d..c51d9b7 100644 --- a/gui_qt/formwater.cpp +++ b/gui_qt/formwater.cpp @@ -20,8 +20,8 @@ class PreviewWaterCoverage:public Preview public: PreviewWaterCoverage(QWidget* parent):Preview(parent) { + _water = waterCreateDefinition(); _terrain = terrainCreateDefinition(); - sceneryGetTerrain(&_terrain); } protected: QColor getColor(double x, double y) @@ -39,7 +39,13 @@ protected: return colorToQColor(_definition.main_color); } } + void updateData() + { + waterCopyDefinition(&_definition, &_water); + sceneryGetTerrain(&_terrain); + } private: + WaterDefinition _water; TerrainDefinition _terrain; }; @@ -49,6 +55,7 @@ public: PreviewWaterColor(QWidget* parent):Preview(parent) { _water = waterCreateDefinition(); + _renderer = rendererGetFake(); _renderer.rayWalking = _rayWalking; // TODO Lighting @@ -80,8 +87,12 @@ protected: return colorToQColor(_rayWalking(&_renderer, eye, look, 0, 0, 0, 0).hit_color); } + return colorToQColor(waterGetColor(&_water, &_renderer, location, look)); + } + void updateData() + { + waterCopyDefinition(&_definition, &_water); _water.height = 0.0; - return colorToQColor(waterGetColor(&_definition, &_renderer, location, look)); } private: diff --git a/gui_qt/mainwindow.cpp b/gui_qt/mainwindow.cpp index 85f4ca6..0f57037 100644 --- a/gui_qt/mainwindow.cpp +++ b/gui_qt/mainwindow.cpp @@ -30,14 +30,26 @@ int main(int argc, char** argv) MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { + BaseForm* form; QTabWidget* tabs; QMenu* menu; tabs = new QTabWidget(this); - tabs->addTab(new FormTerrain(tabs), "Terrain"); - tabs->addTab(new FormWater(tabs), "Water"); - tabs->addTab(new FormSky(tabs), "Sky"); - tabs->addTab(new FormRender(tabs), "Render"); + + form = new FormTerrain(tabs); + tabs->addTab(form, "Terrain"); + QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll())); + + form = new FormWater(tabs); + tabs->addTab(form, "Water"); + QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll())); + + form = new FormSky(tabs); + tabs->addTab(form, "Sky"); + QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll())); + + form = new FormRender(tabs); + tabs->addTab(form, "Render"); menu = menuBar()->addMenu("Scene"); menu->addAction("New", this, SLOT(fileNew())); diff --git a/lib_paysages/auto.c b/lib_paysages/auto.c index e9d23f8..67779d5 100644 --- a/lib_paysages/auto.c +++ b/lib_paysages/auto.c @@ -201,7 +201,7 @@ void autoGenRealisticLandscape(int seed) texture->color.b = 0.57; texture = texturesGetLayer(&textures, texturesAddLayer(&textures)); zoneAddHeightRange(texture->zone, 1.0, -1.0, 0.0, 3.0, 15.0); - zoneAddSteepnessRange(texture->zone, 1.0, 0.0, 0.0, 0.3, 0.4); + zoneAddSteepnessRange(texture->zone, 1.0, 0.0, 0.0, 0.2, 0.3); noiseGenerateBaseNoise(texture->bump_noise, 102400); noiseAddLevelsSimple(texture->bump_noise, 6, 0.02, 0.008); texture->color.r = 0.2; diff --git a/lib_paysages/textures.c b/lib_paysages/textures.c index d4e2517..b9b25d3 100644 --- a/lib_paysages/textures.c +++ b/lib_paysages/textures.c @@ -214,7 +214,7 @@ Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* render SurfaceMaterial material; result = COLOR_TRANSPARENT; - normal = _getNormal(definition, renderer, location, detail * 0.3); + normal = _getNormal(definition, renderer, location, detail); coverage = zoneGetValue(definition->zone, location, normal); if (coverage > 0.0)