paysages : Adding OSD to previews (WIP).

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@361 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-06-25 20:11:15 +00:00 committed by ThunderK
parent b6555f822c
commit ba24057b97
10 changed files with 171 additions and 35 deletions

View file

@ -14,6 +14,7 @@ Scenery :
* Added sun halo control.
* New cloud model with 2 noises : one for the global shape and one for edges.
* Terrain shadows have been improved and are now configurable.
* New sky model (based on Preetham's work).
Rendering :
* New texture model (perpendicular displacement and thickness).

7
TODO
View file

@ -7,7 +7,6 @@ Technology Preview 2 :
- Keep skydome lights in cache for a render.
- Disable form fields when no layer is selected.
- Add buttons to restore "auto" default values in tabs and dialogs.
- Remove color gradations (replace with automatic boolean and simple colors).
- Replace zone ranges with curves (with curve input and curve dialog).
- Interface for textures thickness, slope_range and thickness_transparency (and correct slider ranges).
- Add "hardness to light" and shadow control ("minimum lighting") to material.
@ -35,16 +34,16 @@ Technology Preview 2 :
Technology Preview 3 :
- Restore render progress.
- Implement High Dynamic Range.
- Implement Sub Surface Scattering for water.
- Use bicubic interpolation for antialiasing.
- Improve large render/antialias memory consumption.
- Allow for larger renders/antialias (will need several two-pass chunks).
- Add basic vegetation system ?
- Texture shadowing and self-shadowing ?
- Improve sky rendering (colors and light halo).
- Add a progress indicator on previews.
- Multi threaded first pass.
- Mark modified tabs and ask for losing modifications (idem for layers).
- Fix potential holes in land rendering.
- Progressive final render.
- Progressive final render (increasing resolution, for second pass only).
- Propose several backgrounds for water preview (grid, sinus...).
- Water and terrain LOD moves with the camera, fix it like in the wanderer.
- Improve 3d explorer

View file

@ -297,6 +297,11 @@ BasePreview::~BasePreview()
delete lock_drawing;
}
void BasePreview::addOsd(QString name)
{
_osd.append(PreviewOsd::getInstance(name));
}
void BasePreview::initDrawers()
{
_drawing_manager = new PreviewDrawingManager();
@ -442,6 +447,14 @@ void BasePreview::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
painter.drawImage(0, 0, *this->pixbuf);
QImage osd(pixbuf->size(), pixbuf->format());
osd.fill(0x00000000);
for (int i = 0; i < _osd.size(); i++)
{
_osd[i]->apply(&osd, xoffset, yoffset, scaling);
}
painter.drawImage(0, 0, osd);
}
void BasePreview::updateScaling()

View file

@ -7,6 +7,7 @@
#include <QThread>
#include <QVector>
#include <QList>
#include "previewosd.h"
class BasePreview : public QWidget {
Q_OBJECT
@ -15,6 +16,8 @@ public:
BasePreview(QWidget* parent);
~BasePreview();
void addOsd(QString name);
static void initDrawers();
static void stopDrawers();
static void reviveAll();
@ -52,6 +55,7 @@ private:
QMutex* lock_drawing;
QImage* pixbuf;
QVector<PreviewOsd*> _osd;
int _width;
int _height;

View file

@ -107,7 +107,7 @@ FormSky::FormSky(QWidget *parent):
addPreview(previewEast, QString(tr("East preview")));
addInputEnum(tr("Color model"), (int*)&_definition.model, QStringList(tr("Custom model")) << tr("Rayleigh/Mie scattering") << tr("Preetham/Shirley analytic model"));
addInputDouble(tr("Day time"), &_definition.daytime, 0.0, 1.0, 0.002, 0.1);
addInputDouble(tr("Day time"), &_definition.daytime, 0.14, 0.86, 0.002, 0.1);
addInputColor(tr("Sun color"), &_definition.sun_color);
addInputDouble(tr("Sun radius"), &_definition.sun_radius, 0.0, 0.4, 0.004, 0.04);
addInputDouble(tr("Sun halo radius"), &_definition.sun_halo_size, 0.0, 0.4, 0.004, 0.04);

View file

@ -1,9 +1,9 @@
#include "formterrain.h"
#include "tools.h"
#include <math.h>
#include <QColor>
#include <QSlider>
#include <math.h>
#include "tools.h"
#include "../lib_paysages/terrain.h"
#include "../lib_paysages/scenery.h"
@ -19,6 +19,8 @@ public:
{
_preview_definition = terrainCreateDefinition();
addOsd(QString("geolocation"));
configScaling(0.5, 200.0, 3.0, 50.0);
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
}
@ -94,6 +96,8 @@ public:
_renderer.customData[1] = &_textures;
_renderer.customData[2] = &_lighting;
addOsd(QString("geolocation"));
configScaling(0.5, 200.0, 3.0, 50.0);
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
}

View file

@ -143,11 +143,15 @@ bool MainWindow::event(QEvent* event)
void MainWindow::refreshAll()
{
// Refresh all tabs
QList<BaseForm*> list_forms = this->findChildren<BaseForm*>("_base_form_");
for (int i = 0; i < list_forms.size(); i++)
{
list_forms[i]->revertConfig();
}
// Refresh preview OSD
//PreviewOsd* osd = PreviewOsd::getInstance(QString("geolocation"));
}
void MainWindow::fileNew()

75
gui_qt/previewosd.cpp Normal file
View file

@ -0,0 +1,75 @@
#include "previewosd.h"
#include <QHash>
#include <QPainter>
static QHash<QString, PreviewOsd*> _instances;
/*************** PreviewOsdItem ***************/
PreviewOsdItem::PreviewOsdItem(int width, int height) : QImage(width, height, QImage::Format_ARGB32)
{
_xlocation = 0.0;
_ylocation = 0.0;
}
void PreviewOsdItem::setLocation(double x, double y)
{
_xlocation = x;
_ylocation = y;
}
/*************** PreviewOsd ***************/
PreviewOsd::PreviewOsd()
{
newItem(50, 50)->fill(0x88888888);
}
PreviewOsd::~PreviewOsd()
{
for (int i = 0; i < _items.size(); i++)
{
delete _items[i];
}
}
PreviewOsd* PreviewOsd::getInstance(QString name)
{
if (_instances.contains(name))
{
return _instances[name];
}
else
{
PreviewOsd* instance = new PreviewOsd();
_instances.insert(name, instance);
return instance;
}
}
PreviewOsdItem* PreviewOsd::newItem(int width, int height)
{
PreviewOsdItem* item = new PreviewOsdItem(width, height);
_items.append(item);
return item;
}
PreviewOsdItem* PreviewOsd::newItem(QImage image)
{
PreviewOsdItem* item = newItem(image.width(), image.height());
QPainter painter(item);
painter.drawImage(0, 0, image);
return item;
}
void PreviewOsd::apply(QImage* mask, double xoffset, double yoffset, double scaling)
{
QPainter painter(mask);
for (int i = 0; i < _items.size(); i++)
{
PreviewOsdItem* item = _items[i];
int x = (int)(mask->width() / 2 - (xoffset - item->xlocation()) / scaling - item->width() / 2);
int y = (int)(mask->height() / 2 - (yoffset - item->ylocation()) / scaling - item->height() / 2);
painter.drawImage(x, y, *item);
}
}

36
gui_qt/previewosd.h Normal file
View file

@ -0,0 +1,36 @@
#ifndef _PAYSAGES_QT_PREVIEWOSD_H_
#define _PAYSAGES_QT_PREVIEWOSD_H_
#include <QImage>
class PreviewOsdItem:public QImage
{
public:
PreviewOsdItem(int width, int height);
void setLocation(double x, double y);
inline double xlocation() {return _xlocation;};
inline double ylocation() {return _ylocation;};
private:
double _xlocation;
double _ylocation;
};
class PreviewOsd
{
public:
PreviewOsd();
~PreviewOsd();
static PreviewOsd* getInstance(QString name);
PreviewOsdItem* newItem(int width, int height);
PreviewOsdItem* newItem(QImage image);
void apply(QImage* mask, double xoffset, double yoffset, double scaling);
private:
QVector<PreviewOsdItem*> _items;
};
#endif

View file

@ -689,7 +689,7 @@ Maintenir Ctrl : Plus rapide</translation>
<context>
<name>FormTerrain</name>
<message>
<location filename="../gui_qt/formterrain.cpp" line="146"/>
<location filename="../gui_qt/formterrain.cpp" line="150"/>
<source>Height preview (normalized)</source>
<translation>Aperçu de la hauteur (normalisée)</translation>
</message>
@ -698,27 +698,27 @@ Maintenir Ctrl : Plus rapide</translation>
<translation type="obsolete">Aperçu du rendu (sans ombres)</translation>
</message>
<message>
<location filename="../gui_qt/formterrain.cpp" line="147"/>
<location filename="../gui_qt/formterrain.cpp" line="151"/>
<source>Lighted preview (no texture)</source>
<translation>Aperçu éclairé (sans texture)</translation>
</message>
<message>
<location filename="../gui_qt/formterrain.cpp" line="149"/>
<location filename="../gui_qt/formterrain.cpp" line="153"/>
<source>Noise</source>
<translation>Bruit</translation>
</message>
<message>
<location filename="../gui_qt/formterrain.cpp" line="150"/>
<location filename="../gui_qt/formterrain.cpp" line="154"/>
<source>Height</source>
<translation>Hauteur</translation>
</message>
<message>
<location filename="../gui_qt/formterrain.cpp" line="151"/>
<location filename="../gui_qt/formterrain.cpp" line="155"/>
<source>Scaling</source>
<translation>Echelle</translation>
</message>
<message>
<location filename="../gui_qt/formterrain.cpp" line="152"/>
<location filename="../gui_qt/formterrain.cpp" line="156"/>
<source>Shadow smoothing</source>
<translation type="unfinished"></translation>
</message>
@ -1007,87 +1007,87 @@ rapide (F5)</translation>
<translation>F5</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="155"/>
<location filename="../gui_qt/mainwindow.cpp" line="159"/>
<source>Do you want to start a new scenery ? Any unsaved changes will be lost.</source>
<translation>Voulez-vous commencer un nouveau paysage ? Les modifications non sauvegardées seront perdues.</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="155"/>
<location filename="../gui_qt/mainwindow.cpp" line="159"/>
<source>Paysages 3D - New scenery</source>
<translation>Paysages 3D - Nouvelle scène</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="165"/>
<location filename="../gui_qt/mainwindow.cpp" line="169"/>
<source>Paysages 3D - Choose a file to save the scenery</source>
<translation>Paysages 3D - Choisissez un fichier pour enregistrer la scène</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="165"/>
<location filename="../gui_qt/mainwindow.cpp" line="191"/>
<location filename="../gui_qt/mainwindow.cpp" line="169"/>
<location filename="../gui_qt/mainwindow.cpp" line="195"/>
<source>Paysages 3D Scenery (*.p3d)</source>
<translation>Scène Paysages 3D (*.p3d)</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="179"/>
<location filename="../gui_qt/mainwindow.cpp" line="182"/>
<location filename="../gui_qt/mainwindow.cpp" line="183"/>
<location filename="../gui_qt/mainwindow.cpp" line="186"/>
<source>Paysages 3D - File saving error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="179"/>
<location filename="../gui_qt/mainwindow.cpp" line="183"/>
<source>Can&apos;t write specified file : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="182"/>
<location filename="../gui_qt/mainwindow.cpp" line="186"/>
<source>Unexpected error while saving file : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="189"/>
<location filename="../gui_qt/mainwindow.cpp" line="193"/>
<source>Do you want to load a scenery from file ? Any unsaved changes will be lost.</source>
<translation>Voulez-vous charger une scène ? Les modifications non sauvegardées seront perdues.</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="189"/>
<location filename="../gui_qt/mainwindow.cpp" line="193"/>
<source>Paysages 3D - Load scenery</source>
<translation>Paysages 3D - Charger une scène</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="191"/>
<location filename="../gui_qt/mainwindow.cpp" line="195"/>
<source>Paysages 3D - Choose a scenery file to load</source>
<translation>Paysages 3D - Choisissez un fichier de scène à charger</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="201"/>
<location filename="../gui_qt/mainwindow.cpp" line="204"/>
<location filename="../gui_qt/mainwindow.cpp" line="207"/>
<location filename="../gui_qt/mainwindow.cpp" line="210"/>
<location filename="../gui_qt/mainwindow.cpp" line="205"/>
<location filename="../gui_qt/mainwindow.cpp" line="208"/>
<location filename="../gui_qt/mainwindow.cpp" line="211"/>
<location filename="../gui_qt/mainwindow.cpp" line="214"/>
<source>Paysages 3D - File loading error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="201"/>
<location filename="../gui_qt/mainwindow.cpp" line="205"/>
<source>Can&apos;t read specified file : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="204"/>
<location filename="../gui_qt/mainwindow.cpp" line="208"/>
<source>This file doesn&apos;t look like a Paysages 3D file : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="207"/>
<location filename="../gui_qt/mainwindow.cpp" line="211"/>
<source>This file was created with an incompatible Paysages 3D version : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="210"/>
<location filename="../gui_qt/mainwindow.cpp" line="214"/>
<source>Unexpected error while loading file : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="218"/>
<location filename="../gui_qt/mainwindow.cpp" line="222"/>
<source>A 3D landscape editing and rendering software.
Authors :
@ -1197,7 +1197,7 @@ GLib - http://www.gtk.org/
<translation type="obsolete">Voulez-vous charger un paysage ? Les modifications nons sauvegardées seront perdues.</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="218"/>
<location filename="../gui_qt/mainwindow.cpp" line="222"/>
<source>Paysages 3D</source>
<translation>Paysages 3D</translation>
</message>