paysages : New curve input and dialog for cloud density profile + get rid of constants.h

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@330 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-05-29 13:32:23 +00:00 committed by ThunderK
parent 182ccf7e96
commit a338872c82
35 changed files with 460 additions and 179 deletions

View file

@ -6,6 +6,7 @@
#include "inputcolor.h"
#include "inputcolorgradation.h"
#include "inputnoise.h"
#include "inputcurve.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
@ -236,6 +237,11 @@ void BaseForm::addInputNoise(QString label, NoiseGenerator* value)
addInput(new InputNoise(form, label, value));
}
void BaseForm::addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax)
{
addInput(new InputCurve(form, label, value, xmin, xmax, ymin, ymax));
}
int BaseForm::currentLayer()
{
if (with_layers)

View file

@ -8,6 +8,7 @@
#include "baseinput.h"
#include "../lib_paysages/shared/types.h"
#include "../lib_paysages/noise.h"
#include "../lib_paysages/curve.h"
#include "../lib_paysages/color.h"
class BaseForm:public QWidget
@ -42,6 +43,7 @@ protected:
void addInputColor(QString label, Color* value);
void addInputColorGradation(QString label, ColorGradation* value);
void addInputNoise(QString label, NoiseGenerator* value);
void addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax);
int currentLayer();
void setLayerCount(int layer_count);

View file

@ -10,7 +10,6 @@
#include <QSlider>
#include <QScrollArea>
#include <QPushButton>
#include "baseform.h"
#include "tools.h"
#include "widgetcurveeditor.h"
@ -40,7 +39,7 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad
label->setMaximumWidth(200);
label->setWordWrap(true);
form_layout->addWidget(label, 0, 1);
_curve_editor = new WidgetCurveEditor(form);
_curve_editor = new WidgetCurveEditor(form, 0.0, 1.0, 0.0, 1.0);
_curve_editor->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
form_layout->addWidget(_curve_editor, 0, 0);
connect(_curve_editor, SIGNAL(liveChanged()), this, SLOT(updateColors()));

View file

@ -3,7 +3,6 @@
#include <QDialog>
#include <QPushButton>
#include "baseform.h"
#include "widgetcurveeditor.h"
#include "previewcolorgradation.h"

106
gui_qt/dialogcurve.cpp Normal file
View file

@ -0,0 +1,106 @@
#include "dialogcurve.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QImage>
#include <QLabel>
#include <QColor>
#include <QPainter>
#include <QSlider>
#include <QScrollArea>
#include <QPushButton>
#include "baseform.h"
#include "tools.h"
#include "widgetcurveeditor.h"
/**************** Dialog ****************/
DialogCurve::DialogCurve(QWidget *parent, Curve* curve, double xmin, double xmax, double ymin, double ymax) : QDialog(parent)
{
QWidget* buttons;
QWidget* form;
QGridLayout* form_layout;
QLabel* label;
_base = curve;
_current = curveCreate();
curveCopy(_base, _current);
setLayout(new QVBoxLayout());
form = new QWidget(this);
form_layout = new QGridLayout();
form->setLayout(form_layout);
layout()->addWidget(form);
label = new QLabel(tr("This is the curve editor.\nClick on points and drag them to move them.\nDouble click to add a new point.\nRight click on a point to delete it."), form);
label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
label->setMinimumWidth(150);
label->setMaximumWidth(200);
label->setWordWrap(true);
form_layout->addWidget(label, 0, 1);
_curve_editor = new WidgetCurveEditor(form, xmin, xmax, ymin, ymax);
_curve_editor->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
form_layout->addWidget(_curve_editor, 0, 0);
buttons = new QWidget(this);
layout()->addWidget(buttons);
buttons->setLayout(new QHBoxLayout());
_button_accept = new QPushButton(tr("Validate"), buttons);
buttons->layout()->addWidget(_button_accept);
QObject::connect(_button_accept, SIGNAL(clicked()), this, SLOT(accept()));
_button_revert = new QPushButton(tr("Revert"), buttons);
buttons->layout()->addWidget(_button_revert);
QObject::connect(_button_revert, SIGNAL(clicked()), this, SLOT(revert()));
_button_cancel = new QPushButton(tr("Cancel"), buttons);
buttons->layout()->addWidget(_button_cancel);
QObject::connect(_button_cancel, SIGNAL(clicked()), this, SLOT(reject()));
setWindowTitle(tr("Paysages 3D - Curve editor"));
resize(900, 600);
revert();
}
DialogCurve::~DialogCurve()
{
curveDelete(_current);
}
bool DialogCurve::getCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax)
{
int result;
DialogCurve* dialog = new DialogCurve(parent, curve, xmin, xmax, ymin, ymax);
result = dialog->exec();
delete dialog;
return (result != 0) ? true : false;
}
void DialogCurve::closeEvent(QCloseEvent* e)
{
reject();
}
void DialogCurve::accept()
{
_curve_editor->getCurve(_current);
curveCopy(_current, _base);
QDialog::accept();
}
void DialogCurve::revert()
{
curveCopy(_base, _current);
revertToCurrent();
}
void DialogCurve::revertToCurrent()
{
_curve_editor->setCurve(_current);
}

38
gui_qt/dialogcurve.h Normal file
View file

@ -0,0 +1,38 @@
#ifndef _PAYSAGES_QT_DIALOGCURVE_H_
#define _PAYSAGES_QT_DIALOGCURVE_H_
#include <QDialog>
#include <QPushButton>
#include "widgetcurveeditor.h"
#include "../lib_paysages/curve.h"
class DialogCurve : public QDialog
{
Q_OBJECT
public:
explicit DialogCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax);
~DialogCurve();
static bool getCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax);
public slots:
virtual void accept();
void revert();
protected:
virtual void closeEvent(QCloseEvent* e);
private:
void revertToCurrent();
private:
Curve* _base;
Curve* _current;
WidgetCurveEditor* _curve_editor;
QPushButton* _button_accept;
QPushButton* _button_revert;
QPushButton* _button_cancel;
};
#endif

View file

@ -4,7 +4,6 @@
#include "../lib_paysages/color.h"
#include "../lib_paysages/euclid.h"
#include "../lib_paysages/scenery.h"
#include "../lib_paysages/shared/constants.h"
#include "tools.h"
@ -107,8 +106,8 @@ protected:
{
cloudsLayerCopyDefinition(&_layer, &_preview_layer);
_preview_layer.ymax = (_preview_layer.ymax - _preview_layer.ymin) / 2.0;
_preview_layer.ycenter = 0.0;
_preview_layer.ymin = -_preview_layer.ymin;
curveClear(_preview_layer.density_altitude);
_preview_layer.customcoverage = _coverageFunc;
}
private:
@ -149,9 +148,9 @@ FormClouds::FormClouds(QWidget *parent):
addPreview(new PreviewCloudsCoverage(parent), tr("Layer coverage (no lighting)"));
addPreview(new PreviewCloudsColor(parent), tr("Color and lighting"));
addInputDouble(tr("Start altitude"), &_layer.ymin, -10.0, 250.0, 0.5, 5.0);
addInputDouble(tr("Max density altitude"), &_layer.ycenter, -10.0, 250.0, 0.5, 5.0);
addInputDouble(tr("End altitude"), &_layer.ymax, -10.0, 250.0, 0.5, 5.0);
addInputDouble(tr("Lower altitude"), &_layer.ymin, -10.0, 250.0, 0.5, 5.0);
addInputDouble(tr("Upper altitude"), &_layer.ymax, -10.0, 250.0, 0.5, 5.0);
addInputCurve(tr("Density / Altitude"), _layer.density_altitude, 0.0, 1.0, 0.0, 1.0);
addInputNoise(tr("Noise"), _layer.noise);
addInputDouble(tr("Coverage"), &_layer.coverage, 0.0, 1.0, 0.01, 0.1);
addInputDouble(tr("Scaling"), &_layer.scaling, 1.0, 100.0, 0.5, 5.0);

View file

@ -9,7 +9,6 @@
#include "../lib_paysages/sky.h"
#include "../lib_paysages/scenery.h"
#include "../lib_paysages/renderer.h"
#include "../lib_paysages/shared/constants.h"
static SkyDefinition _definition;

View file

@ -8,7 +8,6 @@
#include "../lib_paysages/terrain.h"
#include "../lib_paysages/scenery.h"
#include "../lib_paysages/euclid.h"
#include "../lib_paysages/shared/constants.h"
static TerrainDefinition _definition;

View file

@ -5,7 +5,6 @@
#include <QSlider>
#include <math.h>
#include "../lib_paysages/shared/constants.h"
#include "../lib_paysages/euclid.h"
#include "../lib_paysages/lighting.h"
#include "../lib_paysages/renderer.h"

87
gui_qt/inputcurve.cpp Normal file
View file

@ -0,0 +1,87 @@
#include "inputcurve.h"
#include <QLabel>
#include <QPushButton>
#include <QPainter>
#include "dialogcurve.h"
class CurveSmallPreview:public QWidget
{
public:
CurveSmallPreview(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax) : QWidget(parent)
{
_curve = curve;
_xmin = xmin;
_xmax = xmax;
_ymin = ymin;
_ymax = ymax;
}
void paintEvent(QPaintEvent* event)
{
if (!_curve)
{
return;
}
QPainter painter(this);
int width = this->width();
int height = this->height();
double position, value;
painter.fillRect(rect(), QColor(255, 255, 255));
for (int x = 0; x < width; x++)
{
painter.setPen(QColor(0, 0, 0));
position = _xmin + (_xmax - _xmin) * (double)x / (double)(width - 1);
value = (curveGetValue(_curve, position) - _ymin) * (_ymax - _ymin);
painter.drawPoint(x, height - 1 - (int)(value * (double)(height - 1)));
}
}
Curve* _curve;
double _xmin;
double _xmax;
double _ymin;
double _ymax;
};
InputCurve::InputCurve(QWidget* form, QString label, Curve* value, double xmin, double xmax, double ymin, double ymax) : BaseInput(form, label)
{
_value = value;
_xmin = xmin;
_xmax = xmax;
_ymin = ymin;
_ymax = ymax;
_preview = new CurveSmallPreview(form, value, xmin, xmax, ymin, ymax);
_preview->setMinimumSize(100, 40);
_control = new QPushButton(tr("Edit"), form);
_control->setMaximumWidth(150);
connect((QPushButton*)_control, SIGNAL(clicked()), this, SLOT(editCurve()));
}
void InputCurve::updatePreview()
{
_preview->update();
BaseInput::updatePreview();
}
void InputCurve::applyValue()
{
BaseInput::applyValue();
}
void InputCurve::revert()
{
BaseInput::revert();
}
void InputCurve::editCurve()
{
if (DialogCurve::getCurve(_control, _value, _xmin, _xmax, _ymin, _ymax))
{
applyValue();
}
}

32
gui_qt/inputcurve.h Normal file
View file

@ -0,0 +1,32 @@
#ifndef _PAYSAGES_QT_INPUTCURVE_H_
#define _PAYSAGES_QT_INPUTCURVE_H_
#include <QWidget>
#include "baseinput.h"
#include "../lib_paysages/curve.h"
class InputCurve:public BaseInput
{
Q_OBJECT
public:
InputCurve(QWidget* form, QString label, Curve* value, double xmin, double xmax, double ymin, double ymax);
public slots:
virtual void updatePreview();
virtual void applyValue();
virtual void revert();
private slots:
void editCurve();
private:
Curve* _value;
double _xmin;
double _xmax;
double _ymin;
double _ymax;
};
#endif

View file

@ -4,7 +4,7 @@
#include <QMouseEvent>
#include "../lib_paysages/tools.h"
WidgetCurveEditor::WidgetCurveEditor(QWidget *parent) : QWidget(parent)
WidgetCurveEditor::WidgetCurveEditor(QWidget *parent, double xmin, double xmax, double ymin, double ymax) : QWidget(parent)
{
_curve = curveCreate();
_dragged = -1;

View file

@ -10,7 +10,7 @@ class WidgetCurveEditor : public QWidget
Q_OBJECT
public:
WidgetCurveEditor(QWidget* parent);
WidgetCurveEditor(QWidget* parent, double xmin, double xmax, double ymin, double ymax);
~WidgetCurveEditor();
void setCurve(Curve* curve);

View file

@ -4,32 +4,32 @@
<context>
<name>BaseForm</name>
<message>
<location filename="../gui_qt/baseform.cpp" line="37"/>
<location filename="../gui_qt/baseform.cpp" line="38"/>
<source>Layers : </source>
<translation>Niveaux :</translation>
</message>
<message>
<location filename="../gui_qt/baseform.cpp" line="45"/>
<location filename="../gui_qt/baseform.cpp" line="46"/>
<source>Add layer</source>
<translation>Ajouter un niveau</translation>
</message>
<message>
<location filename="../gui_qt/baseform.cpp" line="49"/>
<location filename="../gui_qt/baseform.cpp" line="50"/>
<source>Delete layer</source>
<translation>Supprimer un niveau</translation>
</message>
<message>
<location filename="../gui_qt/baseform.cpp" line="85"/>
<location filename="../gui_qt/baseform.cpp" line="86"/>
<source>Apply</source>
<translation>Appliquer</translation>
</message>
<message>
<location filename="../gui_qt/baseform.cpp" line="88"/>
<location filename="../gui_qt/baseform.cpp" line="89"/>
<source>Revert</source>
<translation>Annuler les modifications</translation>
</message>
<message>
<location filename="../gui_qt/baseform.cpp" line="262"/>
<location filename="../gui_qt/baseform.cpp" line="268"/>
<source>Layer %1</source>
<translation>Niveau %1</translation>
</message>
@ -37,7 +37,7 @@
<context>
<name>DialogColorGradation</name>
<message>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="37"/>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="36"/>
<source>This is the curve editor for color components.
Click on a component preview below to edit it.
Click on points and drag them to move them.
@ -50,46 +50,77 @@ Double cliquez sur le fond pour ajouter un point.
Cliquez avec le bouton droit sur un point pour le supprimer.</translation>
</message>
<message>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="48"/>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="47"/>
<source>Red preview, click to edit</source>
<translation>Aperçu du rouge, cliquer pour éditer</translation>
</message>
<message>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="61"/>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="60"/>
<source>Green preview, click to edit</source>
<translation>Aperçu du vert, cliquer pour éditer</translation>
</message>
<message>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="74"/>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="73"/>
<source>Blue preview, click to edit</source>
<translation>Aperçu du bleu, cliquez pour éditer</translation>
</message>
<message>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="87"/>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="86"/>
<source>Final preview</source>
<translation>Aperçu du gradient final</translation>
</message>
<message>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="103"/>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="102"/>
<source>Validate</source>
<translation>Valider</translation>
</message>
<message>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="107"/>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="106"/>
<source>Revert</source>
<translation>Recommencer</translation>
</message>
<message>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="111"/>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="110"/>
<source>Cancel</source>
<translation>Annuler</translation>
</message>
<message>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="117"/>
<location filename="../gui_qt/dialogcolorgradation.cpp" line="116"/>
<source>Paysages 3D - Color gradation editor</source>
<translation>Paysages 3D - Editeur de gradients de couleur</translation>
</message>
</context>
<context>
<name>DialogCurve</name>
<message>
<location filename="../gui_qt/dialogcurve.cpp" line="36"/>
<source>This is the curve editor.
Click on points and drag them to move them.
Double click to add a new point.
Right click on a point to delete it.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/dialogcurve.cpp" line="50"/>
<source>Validate</source>
<translation type="unfinished">Valider</translation>
</message>
<message>
<location filename="../gui_qt/dialogcurve.cpp" line="54"/>
<source>Revert</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/dialogcurve.cpp" line="58"/>
<source>Cancel</source>
<translation type="unfinished">Annuler</translation>
</message>
<message>
<location filename="../gui_qt/dialogcurve.cpp" line="62"/>
<source>Paysages 3D - Curve editor</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DialogNoise</name>
<message>
@ -253,77 +284,89 @@ Maintenir Ctrl : Plus rapide</translation>
<context>
<name>FormClouds</name>
<message>
<location filename="../gui_qt/formclouds.cpp" line="149"/>
<location filename="../gui_qt/formclouds.cpp" line="148"/>
<source>Layer coverage (no lighting)</source>
<translation>Couverture de la couche (sans éclairage)</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="150"/>
<location filename="../gui_qt/formclouds.cpp" line="149"/>
<source>Color and lighting</source>
<translation>Echantillon éclairé</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="152"/>
<source>Start altitude</source>
<translation>Altitude de début</translation>
<translation type="obsolete">Altitude de début</translation>
</message>
<message>
<source>Max density altitude</source>
<translation type="obsolete">Altitude de densité maximale</translation>
</message>
<message>
<source>End altitude</source>
<translation type="obsolete">Altitude de fin</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="151"/>
<source>Lower altitude</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="152"/>
<source>Upper altitude</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="153"/>
<source>Max density altitude</source>
<translation>Altitude de densité maximale</translation>
<source>Density / Altitude</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="154"/>
<source>End altitude</source>
<translation>Altitude de fin</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="155"/>
<source>Noise</source>
<translation>Bruit</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="156"/>
<location filename="../gui_qt/formclouds.cpp" line="155"/>
<source>Coverage</source>
<translation>Couverture</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="157"/>
<location filename="../gui_qt/formclouds.cpp" line="156"/>
<source>Scaling</source>
<translation>Echelle</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="158"/>
<location filename="../gui_qt/formclouds.cpp" line="157"/>
<source>Base color</source>
<translation>Couleur de base</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="159"/>
<location filename="../gui_qt/formclouds.cpp" line="158"/>
<source>Light reflection</source>
<translation>Facteur de réflexion de la lumière</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="160"/>
<location filename="../gui_qt/formclouds.cpp" line="159"/>
<source>Light reflection shininess</source>
<translation>Concentration de la réflexion de lumière</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="161"/>
<location filename="../gui_qt/formclouds.cpp" line="160"/>
<source>Hardness to light</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="162"/>
<location filename="../gui_qt/formclouds.cpp" line="161"/>
<source>Transparency depth</source>
<translation>Distance de transparence</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="163"/>
<location filename="../gui_qt/formclouds.cpp" line="162"/>
<source>Light traversal depth</source>
<translation>Distance de traversée de la lumière</translation>
</message>
<message>
<location filename="../gui_qt/formclouds.cpp" line="164"/>
<location filename="../gui_qt/formclouds.cpp" line="163"/>
<source>Minimum lighting</source>
<translation>Eclairage minimal</translation>
</message>
@ -429,47 +472,47 @@ Maintenir Ctrl : Plus rapide</translation>
<context>
<name>FormSky</name>
<message>
<location filename="../gui_qt/formsky.cpp" line="88"/>
<location filename="../gui_qt/formsky.cpp" line="87"/>
<source>West preview</source>
<translation>Aperçu de l&apos;ouest</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="90"/>
<location filename="../gui_qt/formsky.cpp" line="89"/>
<source>East preview</source>
<translation>Aperçu de l&apos;est</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="92"/>
<location filename="../gui_qt/formsky.cpp" line="91"/>
<source>Day time</source>
<translation>Heure du jour</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="93"/>
<location filename="../gui_qt/formsky.cpp" line="92"/>
<source>Sun color</source>
<translation>Couleur du soleil</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="94"/>
<location filename="../gui_qt/formsky.cpp" line="93"/>
<source>Sun radius</source>
<translation>Diamètre apparent du soleil</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="95"/>
<location filename="../gui_qt/formsky.cpp" line="94"/>
<source>Zenith color</source>
<translation>Couleur du ciel au zénith</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="96"/>
<location filename="../gui_qt/formsky.cpp" line="95"/>
<source>Haze color</source>
<translation>Couleur de la brume</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="97"/>
<location filename="../gui_qt/formsky.cpp" line="96"/>
<source>Haze height</source>
<translation>Hauteur apparente de la brume</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="98"/>
<location filename="../gui_qt/formsky.cpp" line="97"/>
<source>Haze smoothing</source>
<translation>Facteur de lissage de la brume</translation>
</message>
@ -477,7 +520,7 @@ Maintenir Ctrl : Plus rapide</translation>
<context>
<name>FormTerrain</name>
<message>
<location filename="../gui_qt/formterrain.cpp" line="147"/>
<location filename="../gui_qt/formterrain.cpp" line="146"/>
<source>Height preview (normalized)</source>
<translation>Aperçu de la hauteur (normalisée)</translation>
</message>
@ -486,22 +529,22 @@ Maintenir Ctrl : Plus rapide</translation>
<translation type="obsolete">Aperçu du rendu (sans ombres)</translation>
</message>
<message>
<location filename="../gui_qt/formterrain.cpp" line="148"/>
<location filename="../gui_qt/formterrain.cpp" line="147"/>
<source>Lighted preview (no texture)</source>
<translation>Aperçu éclairé (sans texture)</translation>
</message>
<message>
<location filename="../gui_qt/formterrain.cpp" line="150"/>
<location filename="../gui_qt/formterrain.cpp" line="149"/>
<source>Noise</source>
<translation>Bruit</translation>
</message>
<message>
<location filename="../gui_qt/formterrain.cpp" line="151"/>
<location filename="../gui_qt/formterrain.cpp" line="150"/>
<source>Height</source>
<translation>Hauteur</translation>
</message>
<message>
<location filename="../gui_qt/formterrain.cpp" line="152"/>
<location filename="../gui_qt/formterrain.cpp" line="151"/>
<source>Scaling</source>
<translation>Echelle</translation>
</message>
@ -596,72 +639,72 @@ Maintenir Ctrl : Plus rapide</translation>
<context>
<name>FormWater</name>
<message>
<location filename="../gui_qt/formwater.cpp" line="178"/>
<location filename="../gui_qt/formwater.cpp" line="177"/>
<source>Coverage preview</source>
<translation>Aperçu de la couverture</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="179"/>
<location filename="../gui_qt/formwater.cpp" line="178"/>
<source>Rendered preview (without/with lighting)</source>
<translation>Aperçu du rendu (sans/avec éclairage)</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="181"/>
<location filename="../gui_qt/formwater.cpp" line="180"/>
<source>Height</source>
<translation>Hauteur</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="182"/>
<location filename="../gui_qt/formwater.cpp" line="181"/>
<source>Surface color</source>
<translation>Couleur de la surface</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="183"/>
<location filename="../gui_qt/formwater.cpp" line="182"/>
<source>Light reflection</source>
<translation>Réflection de la lumière</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="184"/>
<location filename="../gui_qt/formwater.cpp" line="183"/>
<source>Shininess to light</source>
<translation>Concentration de la lumière réfléchie</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="185"/>
<location filename="../gui_qt/formwater.cpp" line="184"/>
<source>Transparency</source>
<translation>Transparence</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="186"/>
<location filename="../gui_qt/formwater.cpp" line="185"/>
<source>Reflection</source>
<translation>Reflets</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="187"/>
<location filename="../gui_qt/formwater.cpp" line="186"/>
<source>Transparency distance</source>
<translation>Distance maximale de transparence</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="188"/>
<location filename="../gui_qt/formwater.cpp" line="187"/>
<source>Depth color</source>
<translation>Couleur en profondeur</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="189"/>
<location filename="../gui_qt/formwater.cpp" line="188"/>
<source>Light-through distance</source>
<translation>Distance de filtrage de la lumière</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="190"/>
<location filename="../gui_qt/formwater.cpp" line="189"/>
<source>Waves noise</source>
<translation>Bruit des vagues</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="191"/>
<location filename="../gui_qt/formwater.cpp" line="190"/>
<source>Waves height</source>
<translation>Hauteur des vagues</translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="192"/>
<location filename="../gui_qt/formwater.cpp" line="191"/>
<source>Waves scaling</source>
<translation>Echelle des vagues</translation>
</message>
@ -703,6 +746,14 @@ Maintenir Ctrl : Plus rapide</translation>
<translation>Editer</translation>
</message>
</context>
<context>
<name>InputCurve</name>
<message>
<location filename="../gui_qt/inputcurve.cpp" line="58"/>
<source>Edit</source>
<translation type="unfinished">Editer</translation>
</message>
</context>
<context>
<name>InputNoise</name>
<message>

View file

@ -1,6 +1,5 @@
#include "atmosphere.h"
#include "shared/constants.h"
#include "scenery.h"
#include "euclid.h"
#include "color.h"

View file

@ -5,7 +5,6 @@
#include <time.h>
#include "shared/types.h"
#include "shared/constants.h"
#include "clouds.h"
#include "color.h"
#include "lighting.h"

View file

@ -6,7 +6,6 @@
#include "euclid.h"
#include "render.h"
#include "shared/types.h"
#include "shared/constants.h"
#include "scenery.h"
#include "tools.h"

View file

@ -8,7 +8,6 @@
#include "lighting.h"
#include "tools.h"
#include "shared/types.h"
#include "shared/constants.h"
typedef struct
{
@ -21,9 +20,7 @@ static CloudsLayerDefinition NULL_LAYER;
void cloudsInit()
{
NULL_LAYER.noise = noiseCreateGenerator();
NULL_LAYER.coverage = 0.0;
NULL_LAYER.customcoverage = NULL;
NULL_LAYER = cloudsLayerCreateDefinition();;
cloudsLayerValidateDefinition(&NULL_LAYER);
}
@ -42,9 +39,9 @@ void cloudsSave(PackStream* stream, CloudsDefinition* definition)
{
layer = definition->layers + i;
packWriteDouble(stream, &layer->ycenter);
packWriteDouble(stream, &layer->ymin);
packWriteDouble(stream, &layer->ymax);
curveSave(stream, layer->density_altitude);
noiseSaveGenerator(stream, layer->noise);
materialSave(stream, &layer->material);
packWriteDouble(stream, &layer->hardness);
@ -71,9 +68,9 @@ void cloudsLoad(PackStream* stream, CloudsDefinition* definition)
{
layer = definition->layers + cloudsAddLayer(definition);
packReadDouble(stream, &layer->ycenter);
packReadDouble(stream, &layer->ymin);
packReadDouble(stream, &layer->ymax);
curveLoad(stream, layer->density_altitude);
noiseLoadGenerator(stream, layer->noise);
materialLoad(stream, &layer->material);
packReadDouble(stream, &layer->hardness);
@ -129,24 +126,13 @@ void cloudsValidateDefinition(CloudsDefinition* definition)
static double _standardCoverageFunc(CloudsLayerDefinition* layer, Vector3 position)
{
double inside;
if (position.y > layer->ycenter)
{
inside = 1.0 - (position.y - layer->ycenter) / (layer->ymax - layer->ycenter);
}
else
{
inside = 1.0 - (layer->ycenter - position.y) / (layer->ycenter - layer->ymin);
}
if (inside <= 0.0)
if (position.y > layer->ymax || position.y < layer->ymin)
{
return 0.0;
}
else
{
return layer->coverage * inside;
return layer->coverage * curveGetValue(layer->density_altitude, (position.y - layer->ymin) / (layer->ymax - layer->ymin));
}
}
@ -155,8 +141,12 @@ CloudsLayerDefinition cloudsLayerCreateDefinition()
CloudsLayerDefinition result;
result.ymin = 4.0;
result.ycenter = 6.0;
result.ymax = 10.0;
result.density_altitude = curveCreate();
curveQuickAddPoint(result.density_altitude, 0.0, 0.0);
curveQuickAddPoint(result.density_altitude, 0.3, 1.0);
curveQuickAddPoint(result.density_altitude, 0.5, 1.0);
curveQuickAddPoint(result.density_altitude, 1.0, 0.0);
result.material.base.r = 0.7;
result.material.base.g = 0.7;
result.material.base.b = 0.7;
@ -197,17 +187,21 @@ void cloudsLayerDeleteDefinition(CloudsLayerDefinition* definition)
void cloudsLayerCopyDefinition(CloudsLayerDefinition* source, CloudsLayerDefinition* destination)
{
NoiseGenerator* noise;
CloudsLayerDefinition temp;
if (destination == &NULL_LAYER)
{
return;
}
noise = destination->noise;
temp = *destination;
*destination = *source;
destination->noise = noise;
destination->noise = temp.noise;
noiseCopy(source->noise, destination->noise);
destination->density_altitude = temp.density_altitude;
curveCopy(source->density_altitude, destination->density_altitude);
}
void cloudsLayerValidateDefinition(CloudsLayerDefinition* definition)

View file

@ -18,9 +18,9 @@ typedef double (*CloudCoverageFunc)(CloudsLayerDefinition* definition, Vector3 p
struct CloudsLayerDefinition
{
double ycenter;
double ymin;
double ymax;
Curve* density_altitude;
NoiseGenerator* noise;
SurfaceMaterial material;
double hardness;

View file

@ -3,7 +3,6 @@
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "shared/constants.h"
#include "tools.h"
#include "curve.h"

View file

@ -1,14 +1,28 @@
#ifndef _PAYSAGES_COLOR_H_
#define _PAYSAGES_COLOR_H_
#include "shared/types.h"
#include "shared/constants.h"
#include "curve.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
double r;
double g;
double b;
double a;
} Color;
extern Color COLOR_TRANSPARENT;
extern Color COLOR_BLACK;
extern Color COLOR_RED;
extern Color COLOR_GREEN;
extern Color COLOR_BLUE;
extern Color COLOR_WHITE;
extern Color COLOR_GREY;
/* Color */
void colorSave(PackStream* stream, Color* col);
void colorLoad(PackStream* stream, Color* col);

View file

@ -1,13 +1,41 @@
#ifndef _PAYSAGES_EUCLID_H_
#define _PAYSAGES_EUCLID_H_
#include "shared/types.h"
#include "pack.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
double x;
double y;
double z;
} Vector3;
typedef struct
{
double a;
double b;
double c;
double d;
double e;
double f;
double g;
double h;
double i;
double j;
double k;
double l;
double m;
double n;
double o;
double p;
} Matrix4;
extern Vector3 VECTOR_ZERO;
void v3Save(PackStream* stream, Vector3* v);
void v3Load(PackStream* stream, Vector3* v);
Vector3 v3Translate(Vector3 v1, double x, double y, double z);

View file

@ -6,7 +6,6 @@
#include <string.h>
#include "shared/types.h"
#include "shared/constants.h"
#include "color.h"
#include "euclid.h"
#include "renderer.h"

View file

@ -5,7 +5,6 @@
#include "IL/ilu.h"
#include "shared/types.h"
#include "shared/constants.h"
#include "auto.h"
#include "color.h"

View file

@ -1,6 +1,7 @@
#include "pack.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <math.h>

View file

@ -1,9 +1,6 @@
#ifndef _PAYSAGES_PACK_H_
#define _PAYSAGES_PACK_H_
#include <stdio.h>
#include "shared/types.h"
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -7,7 +7,6 @@
#include "IL/ilu.h"
#include "shared/types.h"
#include "shared/constants.h"
#include "array.h"
#include "color.h"
#include "system.h"

View file

@ -1,5 +1,5 @@
#include "renderer.h"
#include "shared/constants.h"
#include "lighting.h"
#include "system.h"
#include "render.h"

View file

@ -1,24 +0,0 @@
#ifndef _PAYSAGES_CONSTANTS_H_
#define _PAYSAGES_CONSTANTS_H_
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
extern Color COLOR_TRANSPARENT;
extern Color COLOR_BLACK;
extern Color COLOR_RED;
extern Color COLOR_GREEN;
extern Color COLOR_BLUE;
extern Color COLOR_WHITE;
extern Color COLOR_GREY;
extern Vector3 VECTOR_ZERO;
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,47 +1,13 @@
#ifndef _PAYSAGES_TYPES_H_
#define _PAYSAGES_TYPES_H_
#include <stdio.h>
#include "../euclid.h"
#include "../color.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
double x;
double y;
double z;
} Vector3;
typedef struct
{
double a;
double b;
double c;
double d;
double e;
double f;
double g;
double h;
double i;
double j;
double k;
double l;
double m;
double n;
double o;
double p;
} Matrix4;
typedef struct
{
double r;
double g;
double b;
double a;
} Color;
struct RenderFragment;
struct Renderer;

View file

@ -4,7 +4,6 @@
#include <math.h>
#include "shared/types.h"
#include "shared/constants.h"
#include "color.h"
#include "clouds.h"
#include "euclid.h"

View file

@ -6,7 +6,6 @@
#include <assert.h>
#include "shared/types.h"
#include "shared/constants.h"
#include "euclid.h"
#include "render.h"
#include "textures.h"

View file

@ -6,7 +6,6 @@
#include <assert.h>
#include "shared/types.h"
#include "shared/constants.h"
#include "color.h"
#include "euclid.h"
#include "lighting.h"

View file

@ -1,7 +1,6 @@
#include "water.h"
#include "shared/types.h"
#include "shared/constants.h"
#include "color.h"
#include "euclid.h"
#include "render.h"