From d71c09e0d2869c74d806e23c692eb569673e7f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Thu, 5 Apr 2012 17:47:43 +0000 Subject: [PATCH] paysages: Textures form (WIP) + about dialog. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@287 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 2 +- gui_qt/formtextures.cpp | 23 +++++++++-- gui_qt/mainwindow.cpp | 9 +++++ gui_qt/mainwindow.h | 2 + i18n/paysages_fr.ts | 90 +++++++++++++++++++++++++++++------------ lib_paysages/textures.c | 9 +++++ lib_paysages/textures.h | 1 + 7 files changed, 107 insertions(+), 29 deletions(-) diff --git a/TODO b/TODO index 52b452a..c06f22d 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,6 @@ - Add a material editor dialog. - Replace FILE* by a custom type for Save and Load. - Water and terrain LOD moves with the camera, fix it like in the wanderer. -- Add a splash screen / about dialog. +- Implement a file header/versioning. - Restore render progress. - Find a licence and apply it. diff --git a/gui_qt/formtextures.cpp b/gui_qt/formtextures.cpp index 14cd2c0..4e1a3c4 100644 --- a/gui_qt/formtextures.cpp +++ b/gui_qt/formtextures.cpp @@ -13,24 +13,41 @@ class PreviewTexturesCoverage:public BasePreview public: PreviewTexturesCoverage(QWidget* parent):BasePreview(parent) { + _terrain = terrainCreateDefinition(); + _renderer = rendererCreate(); _renderer.render_quality = 3; + _renderer.getTerrainHeight = _getTerrainHeight; + _renderer.customData[0] = &_terrain; _preview_layer = texturesLayerCreateDefinition(); } protected: QColor getColor(double x, double y) { - return QColor(0, 0, 0); + Vector3 location; + double coverage; + location.x = x; + location.y = terrainGetHeight(&_terrain, x, y); + location.z = y; + coverage = texturesGetLayerCoverage(&_preview_layer, &_renderer, location, this->scaling); + return QColor::fromRgbF(coverage, coverage, coverage, 1.0); } void updateData() { + sceneryGetTerrain(&_terrain); texturesLayerCopyDefinition(&_layer, &_preview_layer); } private: + static double _getTerrainHeight(Renderer* renderer, double x, double z) + { + return terrainGetHeight((TerrainDefinition*)(renderer->customData[0]), x, z); + } + Renderer _renderer; TextureLayerDefinition _preview_layer; + TerrainDefinition _terrain; }; class PreviewTexturesColor:public BasePreview @@ -92,8 +109,8 @@ FormTextures::FormTextures(QWidget *parent): previewCoverage = new PreviewTexturesCoverage(this); previewColor = new PreviewTexturesColor(this); - addPreview(previewCoverage, QString("Coverage preview")); - addPreview(previewColor, QString("Colored preview")); + addPreview(previewCoverage, tr("Coverage preview")); + addPreview(previewColor, tr("Lighted sample")); addInputNoise(tr("Surface noise"), _layer.bump_noise); addInputDouble(tr("Surface noise height"), &_layer.bump_height, 0.0, 0.5, 0.001, 0.05); diff --git a/gui_qt/mainwindow.cpp b/gui_qt/mainwindow.cpp index 29d4192..733dcf6 100644 --- a/gui_qt/mainwindow.cpp +++ b/gui_qt/mainwindow.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "formatmosphere.h" #include "formclouds.h" @@ -113,6 +114,9 @@ MainWindow::MainWindow(QWidget *parent) : menu->addAction(tr("&Explore in 3D"), this, SLOT(explore3D()), QKeySequence("F2")); menu->addAction(tr("&Quick render"), this, SLOT(quickPreview()), QKeySequence("F5")); + menu = menuBar()->addMenu(tr("&Help")); + menu->addAction(tr("&About"), this, SLOT(showAboutDialog())); + setCentralWidget(tabs); setWindowTitle("Paysages 3D"); @@ -154,6 +158,11 @@ void MainWindow::fileLoad() } } +void MainWindow::showAboutDialog() +{ + QMessageBox::about(this, tr("Paysages 3D"), tr("A 3D landscape editing and rendering software.\n\nCredits :\nProgramming - Michael Lemaire")); +} + void MainWindow::quickPreview() { _form_render->startQuickRender(); diff --git a/gui_qt/mainwindow.h b/gui_qt/mainwindow.h index 64e79b9..08fdf1f 100644 --- a/gui_qt/mainwindow.h +++ b/gui_qt/mainwindow.h @@ -17,6 +17,8 @@ public slots: void fileNew(); void fileSave(); void fileLoad(); + + void showAboutDialog(); void quickPreview(); void explore3D(); diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts index c6c8870..11dd933 100644 --- a/i18n/paysages_fr.ts +++ b/i18n/paysages_fr.ts @@ -477,32 +477,46 @@ Maintenir Ctrl : Plus rapide FormTextures - + + Coverage preview + Aperçu de la couverture + + + Colored preview + Rendu en couleur + + + + Lighted sample + Echantillon éclairé + + + Surface noise Bruit de surface - + Surface noise height Hauteur du bruit - + Surface noise scaling Echelle du bruit - + Base color Couleur de base - + Light reflection Réflexion de lumière - + Light reflection shininess Concentration de la réflexion de lumière @@ -628,32 +642,32 @@ Maintenir Ctrl : Plus rapide MainWindow - + Terrain Terrain - + Textures Textures - + Water Eau - + Atmosphere Atmosphère - + Sky Ciel - + Clouds Nuages @@ -662,69 +676,95 @@ Maintenir Ctrl : Plus rapide Eclairage - + Render Rendu - + &Scene &Scène - + &New &Nouvelle - + Crtl+N Ctrl+N - + &Save &Sauvegarder - + Crtl+S Ctrl+S - + &Open &Ouvrir - + Crtl+O Ctrl+O - + &Quit &Quitter - + Crtl+Q Ctrl+Q - + &Actions &Actions - + &Explore in 3D &Explorer en 3D - + &Quick render Rendu r&apide + + + &Help + Ai&de + + + + &About + &A propos + + + + Paysages 3D + Paysages 3D + + + + A 3D landscape editing and rendering software. + +Credits : +Programming - Michael Lemaire + Un logiciel d'édition et rendu de décors naturels en 3D + +Crédits : +Développement - Michaël LEMAIRE + diff --git a/lib_paysages/textures.c b/lib_paysages/textures.c index c5f59b2..892f1e1 100644 --- a/lib_paysages/textures.c +++ b/lib_paysages/textures.c @@ -222,6 +222,15 @@ static inline Vector3 _getNormal(TextureLayerDefinition* definition, Renderer* r return v3Normalize(normal); } +double texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail) +{ + Vector3 normal; + + normal = _getNormal(definition, renderer, location, detail * 0.1); + + return zoneGetValue(definition->zone, location, normal); +} + Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail) { Color result; diff --git a/lib_paysages/textures.h b/lib_paysages/textures.h index e44995b..44b632d 100644 --- a/lib_paysages/textures.h +++ b/lib_paysages/textures.h @@ -47,6 +47,7 @@ TextureLayerDefinition* texturesGetLayer(TexturesDefinition* definition, int lay int texturesAddLayer(TexturesDefinition* definition); void texturesDeleteLayer(TexturesDefinition* definition, int layer); +double texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail); Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail); Color texturesGetColor(TexturesDefinition* definition, Renderer* renderer, Vector3 location, double detail);