paysages: Textures form (WIP) + about dialog.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@287 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-04-05 17:47:43 +00:00 committed by ThunderK
parent c51e9b676a
commit d71c09e0d2
7 changed files with 107 additions and 29 deletions

2
TODO
View file

@ -2,6 +2,6 @@
- Add a material editor dialog. - Add a material editor dialog.
- Replace FILE* by a custom type for Save and Load. - Replace FILE* by a custom type for Save and Load.
- Water and terrain LOD moves with the camera, fix it like in the wanderer. - 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. - Restore render progress.
- Find a licence and apply it. - Find a licence and apply it.

View file

@ -13,24 +13,41 @@ class PreviewTexturesCoverage:public BasePreview
public: public:
PreviewTexturesCoverage(QWidget* parent):BasePreview(parent) PreviewTexturesCoverage(QWidget* parent):BasePreview(parent)
{ {
_terrain = terrainCreateDefinition();
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.render_quality = 3; _renderer.render_quality = 3;
_renderer.getTerrainHeight = _getTerrainHeight;
_renderer.customData[0] = &_terrain;
_preview_layer = texturesLayerCreateDefinition(); _preview_layer = texturesLayerCreateDefinition();
} }
protected: protected:
QColor getColor(double x, double y) 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() void updateData()
{ {
sceneryGetTerrain(&_terrain);
texturesLayerCopyDefinition(&_layer, &_preview_layer); texturesLayerCopyDefinition(&_layer, &_preview_layer);
} }
private: private:
static double _getTerrainHeight(Renderer* renderer, double x, double z)
{
return terrainGetHeight((TerrainDefinition*)(renderer->customData[0]), x, z);
}
Renderer _renderer; Renderer _renderer;
TextureLayerDefinition _preview_layer; TextureLayerDefinition _preview_layer;
TerrainDefinition _terrain;
}; };
class PreviewTexturesColor:public BasePreview class PreviewTexturesColor:public BasePreview
@ -92,8 +109,8 @@ FormTextures::FormTextures(QWidget *parent):
previewCoverage = new PreviewTexturesCoverage(this); previewCoverage = new PreviewTexturesCoverage(this);
previewColor = new PreviewTexturesColor(this); previewColor = new PreviewTexturesColor(this);
addPreview(previewCoverage, QString("Coverage preview")); addPreview(previewCoverage, tr("Coverage preview"));
addPreview(previewColor, QString("Colored preview")); addPreview(previewColor, tr("Lighted sample"));
addInputNoise(tr("Surface noise"), _layer.bump_noise); addInputNoise(tr("Surface noise"), _layer.bump_noise);
addInputDouble(tr("Surface noise height"), &_layer.bump_height, 0.0, 0.5, 0.001, 0.05); addInputDouble(tr("Surface noise height"), &_layer.bump_height, 0.0, 0.5, 0.001, 0.05);

View file

@ -8,6 +8,7 @@
#include <QTabWidget> #include <QTabWidget>
#include <QTranslator> #include <QTranslator>
#include <QLocale> #include <QLocale>
#include <qt4/QtGui/qmessagebox.h>
#include "formatmosphere.h" #include "formatmosphere.h"
#include "formclouds.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("&Explore in 3D"), this, SLOT(explore3D()), QKeySequence("F2"));
menu->addAction(tr("&Quick render"), this, SLOT(quickPreview()), QKeySequence("F5")); menu->addAction(tr("&Quick render"), this, SLOT(quickPreview()), QKeySequence("F5"));
menu = menuBar()->addMenu(tr("&Help"));
menu->addAction(tr("&About"), this, SLOT(showAboutDialog()));
setCentralWidget(tabs); setCentralWidget(tabs);
setWindowTitle("Paysages 3D"); 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() void MainWindow::quickPreview()
{ {
_form_render->startQuickRender(); _form_render->startQuickRender();

View file

@ -17,6 +17,8 @@ public slots:
void fileNew(); void fileNew();
void fileSave(); void fileSave();
void fileLoad(); void fileLoad();
void showAboutDialog();
void quickPreview(); void quickPreview();
void explore3D(); void explore3D();

View file

@ -477,32 +477,46 @@ Maintenir Ctrl : Plus rapide</translation>
<context> <context>
<name>FormTextures</name> <name>FormTextures</name>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="98"/> <location filename="../gui_qt/formtextures.cpp" line="112"/>
<source>Coverage preview</source>
<translation>Aperçu de la couverture</translation>
</message>
<message>
<source>Colored preview</source>
<translation type="obsolete">Rendu en couleur</translation>
</message>
<message>
<location filename="../gui_qt/formtextures.cpp" line="113"/>
<source>Lighted sample</source>
<translation>Echantillon éclairé</translation>
</message>
<message>
<location filename="../gui_qt/formtextures.cpp" line="115"/>
<source>Surface noise</source> <source>Surface noise</source>
<translation>Bruit de surface</translation> <translation>Bruit de surface</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="99"/> <location filename="../gui_qt/formtextures.cpp" line="116"/>
<source>Surface noise height</source> <source>Surface noise height</source>
<translation>Hauteur du bruit</translation> <translation>Hauteur du bruit</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="100"/> <location filename="../gui_qt/formtextures.cpp" line="117"/>
<source>Surface noise scaling</source> <source>Surface noise scaling</source>
<translation>Echelle du bruit</translation> <translation>Echelle du bruit</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="101"/> <location filename="../gui_qt/formtextures.cpp" line="118"/>
<source>Base color</source> <source>Base color</source>
<translation>Couleur de base</translation> <translation>Couleur de base</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="102"/> <location filename="../gui_qt/formtextures.cpp" line="119"/>
<source>Light reflection</source> <source>Light reflection</source>
<translation>Réflexion de lumière</translation> <translation>Réflexion de lumière</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formtextures.cpp" line="103"/> <location filename="../gui_qt/formtextures.cpp" line="120"/>
<source>Light reflection shininess</source> <source>Light reflection shininess</source>
<translation>Concentration de la réflexion de lumière</translation> <translation>Concentration de la réflexion de lumière</translation>
</message> </message>
@ -628,32 +642,32 @@ Maintenir Ctrl : Plus rapide</translation>
<context> <context>
<name>MainWindow</name> <name>MainWindow</name>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="74"/> <location filename="../gui_qt/mainwindow.cpp" line="75"/>
<source>Terrain</source> <source>Terrain</source>
<translation>Terrain</translation> <translation>Terrain</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="78"/> <location filename="../gui_qt/mainwindow.cpp" line="79"/>
<source>Textures</source> <source>Textures</source>
<translation>Textures</translation> <translation>Textures</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="82"/> <location filename="../gui_qt/mainwindow.cpp" line="83"/>
<source>Water</source> <source>Water</source>
<translation>Eau</translation> <translation>Eau</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="90"/> <location filename="../gui_qt/mainwindow.cpp" line="91"/>
<source>Atmosphere</source> <source>Atmosphere</source>
<translation>Atmosphère</translation> <translation>Atmosphère</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="86"/> <location filename="../gui_qt/mainwindow.cpp" line="87"/>
<source>Sky</source> <source>Sky</source>
<translation>Ciel</translation> <translation>Ciel</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="94"/> <location filename="../gui_qt/mainwindow.cpp" line="95"/>
<source>Clouds</source> <source>Clouds</source>
<translation>Nuages</translation> <translation>Nuages</translation>
</message> </message>
@ -662,69 +676,95 @@ Maintenir Ctrl : Plus rapide</translation>
<translation type="obsolete">Eclairage</translation> <translation type="obsolete">Eclairage</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="102"/> <location filename="../gui_qt/mainwindow.cpp" line="103"/>
<source>Render</source> <source>Render</source>
<translation>Rendu</translation> <translation>Rendu</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="104"/> <location filename="../gui_qt/mainwindow.cpp" line="105"/>
<source>&amp;Scene</source> <source>&amp;Scene</source>
<translation>&amp;Scène</translation> <translation>&amp;Scène</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="105"/> <location filename="../gui_qt/mainwindow.cpp" line="106"/>
<source>&amp;New</source> <source>&amp;New</source>
<translation>&amp;Nouvelle</translation> <translation>&amp;Nouvelle</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="105"/> <location filename="../gui_qt/mainwindow.cpp" line="106"/>
<source>Crtl+N</source> <source>Crtl+N</source>
<translation>Ctrl+N</translation> <translation>Ctrl+N</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="107"/> <location filename="../gui_qt/mainwindow.cpp" line="108"/>
<source>&amp;Save</source> <source>&amp;Save</source>
<translation>&amp;Sauvegarder</translation> <translation>&amp;Sauvegarder</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="107"/> <location filename="../gui_qt/mainwindow.cpp" line="108"/>
<source>Crtl+S</source> <source>Crtl+S</source>
<translation>Ctrl+S</translation> <translation>Ctrl+S</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="108"/> <location filename="../gui_qt/mainwindow.cpp" line="109"/>
<source>&amp;Open</source> <source>&amp;Open</source>
<translation>&amp;Ouvrir</translation> <translation>&amp;Ouvrir</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="108"/> <location filename="../gui_qt/mainwindow.cpp" line="109"/>
<source>Crtl+O</source> <source>Crtl+O</source>
<translation>Ctrl+O</translation> <translation>Ctrl+O</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="110"/> <location filename="../gui_qt/mainwindow.cpp" line="111"/>
<source>&amp;Quit</source> <source>&amp;Quit</source>
<translation>&amp;Quitter</translation> <translation>&amp;Quitter</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="110"/> <location filename="../gui_qt/mainwindow.cpp" line="111"/>
<source>Crtl+Q</source> <source>Crtl+Q</source>
<translation>Ctrl+Q</translation> <translation>Ctrl+Q</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="112"/> <location filename="../gui_qt/mainwindow.cpp" line="113"/>
<source>&amp;Actions</source> <source>&amp;Actions</source>
<translation>&amp;Actions</translation> <translation>&amp;Actions</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="113"/> <location filename="../gui_qt/mainwindow.cpp" line="114"/>
<source>&amp;Explore in 3D</source> <source>&amp;Explore in 3D</source>
<translation>&amp;Explorer en 3D</translation> <translation>&amp;Explorer en 3D</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="114"/> <location filename="../gui_qt/mainwindow.cpp" line="115"/>
<source>&amp;Quick render</source> <source>&amp;Quick render</source>
<translation>Rendu r&amp;apide</translation> <translation>Rendu r&amp;apide</translation>
</message> </message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="117"/>
<source>&amp;Help</source>
<translation>Ai&amp;de</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="118"/>
<source>&amp;About</source>
<translation>&amp;A propos</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="163"/>
<source>Paysages 3D</source>
<translation>Paysages 3D</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="163"/>
<source>A 3D landscape editing and rendering software.
Credits :
Programming - Michael Lemaire</source>
<translation type="unfinished">Un logiciel d&apos;édition et rendu de décors naturels en 3D
Crédits :
Développement - Michaël LEMAIRE</translation>
</message>
</context> </context>
</TS> </TS>

View file

@ -222,6 +222,15 @@ static inline Vector3 _getNormal(TextureLayerDefinition* definition, Renderer* r
return v3Normalize(normal); 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 texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail)
{ {
Color result; Color result;

View file

@ -47,6 +47,7 @@ TextureLayerDefinition* texturesGetLayer(TexturesDefinition* definition, int lay
int texturesAddLayer(TexturesDefinition* definition); int texturesAddLayer(TexturesDefinition* definition);
void texturesDeleteLayer(TexturesDefinition* definition, int layer); 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 texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail);
Color texturesGetColor(TexturesDefinition* definition, Renderer* renderer, Vector3 location, double detail); Color texturesGetColor(TexturesDefinition* definition, Renderer* renderer, Vector3 location, double detail);