paysages : ColorGradation now uses the new Curve system + started DialogColorGradation rewrite with curve editor (WIP).
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@276 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
a02d199c7b
commit
c9fd2cca95
21 changed files with 422 additions and 331 deletions
2
TODO
2
TODO
|
@ -1,5 +1,5 @@
|
|||
- Implement scaling and scrolling on previews.
|
||||
- Replace FILE* by a custom type for Save and Load.
|
||||
- Water and terrain LOD moves with the camera, fix it like in the wanderer.
|
||||
- Restore render progress.
|
||||
- Find a licence and apply it.
|
||||
- Translate UI ?
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "baseinput.h"
|
||||
#include "../lib_paysages/shared/types.h"
|
||||
#include "../lib_paysages/noise.h"
|
||||
#include "../lib_paysages/color.h"
|
||||
|
||||
class BaseForm:public QWidget
|
||||
{
|
||||
|
|
|
@ -10,117 +10,20 @@
|
|||
#include <QPushButton>
|
||||
#include "baseform.h"
|
||||
#include "tools.h"
|
||||
|
||||
/**************** Preview ****************/
|
||||
class PreviewColorGradation:public BasePreview
|
||||
{
|
||||
public:
|
||||
PreviewColorGradation(QWidget* parent, ColorGradation* gradation): BasePreview(parent)
|
||||
{
|
||||
_gradation_original = gradation;
|
||||
_gradation_preview = *gradation;
|
||||
setMinimumSize(300, 30);
|
||||
setMaximumSize(300, 30);
|
||||
resize(300, 30);
|
||||
// TODO No scrolling/scaling
|
||||
}
|
||||
|
||||
protected:
|
||||
void updateData()
|
||||
{
|
||||
_gradation_preview = *_gradation_original;
|
||||
}
|
||||
QColor getColor(double x, double y)
|
||||
{
|
||||
return colorToQColor(colorGradationGet(&_gradation_preview, x / 600 + 0.5));
|
||||
}
|
||||
private:
|
||||
ColorGradation* _gradation_original;
|
||||
ColorGradation _gradation_preview;
|
||||
};
|
||||
|
||||
/**************** Form ****************/
|
||||
class FormColorGradation:public BaseForm
|
||||
{
|
||||
public:
|
||||
FormColorGradation(QWidget* parent, ColorGradation* gradation):BaseForm(parent, true, true)
|
||||
{
|
||||
QPushButton* button;
|
||||
_gradation = gradation;
|
||||
|
||||
addPreview(new PreviewColorGradation(this, _gradation), tr("Preview"));
|
||||
|
||||
addInputDouble(tr("Position"), &_layer.start, 0.0, 1.0, 0.01, 0.1);
|
||||
addInputColor(tr("Color"), &_layer.col);
|
||||
|
||||
button = addButton(tr("Validate"));
|
||||
QObject::connect(button, SIGNAL(clicked()), parent, SLOT(accept()));
|
||||
|
||||
button = addButton(tr("Revert"));
|
||||
QObject::connect(button, SIGNAL(clicked()), parent, SLOT(revert()));
|
||||
|
||||
button = addButton(tr("Cancel"));
|
||||
QObject::connect(button, SIGNAL(clicked()), parent, SLOT(reject()));
|
||||
|
||||
revertConfig();
|
||||
}
|
||||
|
||||
void revertConfig()
|
||||
{
|
||||
setLayerCount(colorGradationGetPartCount(_gradation));
|
||||
}
|
||||
|
||||
void configChangeEvent()
|
||||
{
|
||||
colorGradationSetPart(_gradation, currentLayer(), _layer);
|
||||
|
||||
BaseForm::configChangeEvent();
|
||||
}
|
||||
|
||||
void layerAddedEvent()
|
||||
{
|
||||
if (colorGradationAddPart(_gradation) >= 0)
|
||||
{
|
||||
BaseForm::layerAddedEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void layerDeletedEvent(int layer)
|
||||
{
|
||||
colorGradationDelPart(_gradation, layer);
|
||||
|
||||
BaseForm::layerDeletedEvent(layer);
|
||||
}
|
||||
|
||||
void layerSelectedEvent(int layer)
|
||||
{
|
||||
_layer = colorGradationGetPart(_gradation, layer);
|
||||
|
||||
BaseForm::layerSelectedEvent(layer);
|
||||
}
|
||||
|
||||
private:
|
||||
ColorGradation* _gradation;
|
||||
ColorGradationPart _layer;
|
||||
};
|
||||
#include "widgetcurveeditor.h"
|
||||
|
||||
/**************** Dialog ****************/
|
||||
DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* gradation):
|
||||
QDialog(parent)
|
||||
{
|
||||
QWidget* preview;
|
||||
|
||||
_base = gradation;
|
||||
_current = colorGradationCreate();
|
||||
_current = *_base;
|
||||
colorGradationCopy(_base, _current);
|
||||
|
||||
setLayout(new QHBoxLayout());
|
||||
|
||||
preview = new QWidget(this);
|
||||
layout()->addWidget(preview);
|
||||
|
||||
_form = new FormColorGradation(this, &_current);
|
||||
layout()->addWidget(_form);
|
||||
_curve_editor = new WidgetCurveEditor(this);
|
||||
layout()->addWidget(_curve_editor);
|
||||
|
||||
/*QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
QObject::connect(button, SIGNAL(clicked()), this, SLOT(revert()));
|
||||
|
@ -133,6 +36,7 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad
|
|||
|
||||
DialogColorGradation::~DialogColorGradation()
|
||||
{
|
||||
colorGradationDelete(_current);
|
||||
}
|
||||
|
||||
bool DialogColorGradation::getGradation(QWidget* parent, ColorGradation* gradation)
|
||||
|
@ -154,18 +58,17 @@ void DialogColorGradation::closeEvent(QCloseEvent* e)
|
|||
|
||||
void DialogColorGradation::accept()
|
||||
{
|
||||
*_base = _current;
|
||||
colorGradationCopy(_current, _base);
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void DialogColorGradation::revert()
|
||||
{
|
||||
_current = *_base;
|
||||
|
||||
colorGradationCopy(_base, _current);
|
||||
revertToCurrent();
|
||||
}
|
||||
|
||||
void DialogColorGradation::revertToCurrent()
|
||||
{
|
||||
_form->revertConfig();
|
||||
// TODO
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include "baseform.h"
|
||||
#include "widgetcurveeditor.h"
|
||||
|
||||
#include "../lib_paysages/color.h"
|
||||
|
||||
|
@ -27,8 +28,8 @@ private:
|
|||
|
||||
private:
|
||||
ColorGradation* _base;
|
||||
ColorGradation _current;
|
||||
BaseForm* _form;
|
||||
ColorGradation* _current;
|
||||
WidgetCurveEditor* _curve_editor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -86,10 +86,10 @@ FormSky::FormSky(QWidget *parent):
|
|||
addPreview(previewEast, QString(tr("East preview")));
|
||||
|
||||
addInputDouble(tr("Day time"), &_definition.daytime, 0.0, 1.0, 0.01, 0.1);
|
||||
addInputColorGradation(tr("Sun color"), &_definition.sun_color);
|
||||
addInputColorGradation(tr("Sun color"), _definition.sun_color);
|
||||
addInputDouble(tr("Sun radius"), &_definition.sun_radius, 0.0, 0.3, 0.01, 0.03);
|
||||
addInputColorGradation(tr("Zenith color"), &_definition.zenith_color);
|
||||
addInputColorGradation(tr("Haze color"), &_definition.haze_color);
|
||||
addInputColorGradation(tr("Zenith color"), _definition.zenith_color);
|
||||
addInputColorGradation(tr("Haze color"), _definition.haze_color);
|
||||
addInputDouble(tr("Haze height"), &_definition.haze_height, 0.0, 1.0, 0.01, 0.1);
|
||||
addInputDouble(tr("Haze smoothing"), &_definition.haze_smoothing, 0.0, 1.0, 0.01, 0.1);
|
||||
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
class ColorGradationPreview:public QWidget
|
||||
{
|
||||
public:
|
||||
ColorGradationPreview(QWidget* parent, ColorGradation* gradation):
|
||||
QWidget(parent),
|
||||
gradation(gradation)
|
||||
ColorGradationPreview(QWidget* parent, ColorGradation* gradation) : QWidget(parent)
|
||||
{
|
||||
this->gradation = gradation;
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent* event)
|
||||
|
@ -32,10 +31,10 @@ public:
|
|||
ColorGradation* gradation;
|
||||
};
|
||||
|
||||
InputColorGradation::InputColorGradation(QWidget* form, QString label, ColorGradation* value):
|
||||
BaseInput(form, label),
|
||||
_value(value)
|
||||
InputColorGradation::InputColorGradation(QWidget* form, QString label, ColorGradation* value) : BaseInput(form, label)
|
||||
{
|
||||
_value = value;
|
||||
|
||||
_preview = new ColorGradationPreview(form, value);
|
||||
_preview->setMinimumSize(200, 20);
|
||||
|
||||
|
@ -63,12 +62,14 @@ void InputColorGradation::revert()
|
|||
|
||||
void InputColorGradation::editGradation()
|
||||
{
|
||||
ColorGradation gradation;
|
||||
ColorGradation* gradation;
|
||||
|
||||
gradation = *_value;
|
||||
if (DialogColorGradation::getGradation(_preview, &gradation))
|
||||
gradation = colorGradationCreate();
|
||||
colorGradationCopy(_value, gradation);
|
||||
if (DialogColorGradation::getGradation(_preview, gradation))
|
||||
{
|
||||
*_value = gradation;
|
||||
colorGradationCopy(gradation, _value);
|
||||
applyValue();
|
||||
}
|
||||
colorGradationDelete(gradation);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <QWidget>
|
||||
#include "baseinput.h"
|
||||
|
||||
#include "../lib_paysages/shared/types.h"
|
||||
#include "../lib_paysages/color.h"
|
||||
|
||||
class InputColorGradation:public BaseInput
|
||||
{
|
||||
|
|
|
@ -94,9 +94,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
tabs->addTab(form, tr("Clouds"));
|
||||
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
||||
|
||||
form = new FormLighting(tabs);
|
||||
/*form = new FormLighting(tabs);
|
||||
tabs->addTab(form, tr("Lighting"));
|
||||
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
||||
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));*/
|
||||
|
||||
form = new FormRender(tabs);
|
||||
tabs->addTab(form, tr("Render"));
|
||||
|
|
32
gui_qt/widgetcurveeditor.cpp
Normal file
32
gui_qt/widgetcurveeditor.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include "widgetcurveeditor.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
WidgetCurveEditor::WidgetCurveEditor(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
_curve = curveCreate();
|
||||
|
||||
setMinimumSize(500, 500);
|
||||
setMaximumSize(500, 500);
|
||||
}
|
||||
|
||||
WidgetCurveEditor::~WidgetCurveEditor()
|
||||
{
|
||||
curveDelete(_curve);
|
||||
}
|
||||
|
||||
void WidgetCurveEditor::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
double position, value;
|
||||
|
||||
QPainter painter(this);
|
||||
painter.fillRect(0, 0, 500, 500, QColor(255, 255, 255));
|
||||
painter.setPen(QColor(255, 0, 0));
|
||||
|
||||
for (int x = 0; x < 500; x++)
|
||||
{
|
||||
position = ((double)x) / 499.0;
|
||||
value = curveGetValue(_curve, position);
|
||||
painter.drawPoint(x, 499 - (int)(value * 499.0));
|
||||
}
|
||||
}
|
22
gui_qt/widgetcurveeditor.h
Normal file
22
gui_qt/widgetcurveeditor.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef _PAYSAGES_QT_WIDGETCURVEEDITOR_H_
|
||||
#define _PAYSAGES_QT_WIDGETCURVEEDITOR_H_
|
||||
|
||||
#include <QWidget>
|
||||
#include "../lib_paysages/curve.h"
|
||||
|
||||
class WidgetCurveEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WidgetCurveEditor(QWidget* parent);
|
||||
~WidgetCurveEditor();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event);
|
||||
|
||||
private:
|
||||
Curve* _curve;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -4,40 +4,34 @@
|
|||
<context>
|
||||
<name>BaseForm</name>
|
||||
<message>
|
||||
<location filename="../gui_qt/baseform.cpp" line="33"/>
|
||||
<source>Layers : </source>
|
||||
<translation>Niveaux :</translation>
|
||||
<translation type="obsolete">Niveaux :</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/baseform.cpp" line="39"/>
|
||||
<source>Add layer</source>
|
||||
<translation>Ajouter un niveau</translation>
|
||||
<translation type="obsolete">Ajouter un niveau</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/baseform.cpp" line="43"/>
|
||||
<source>Delete layer</source>
|
||||
<translation>Supprimer un niveau</translation>
|
||||
<translation type="obsolete">Supprimer un niveau</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/baseform.cpp" line="73"/>
|
||||
<source>Apply</source>
|
||||
<translation>Appliquer</translation>
|
||||
<translation type="obsolete">Appliquer</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/baseform.cpp" line="76"/>
|
||||
<source>Revert</source>
|
||||
<translation>Annuler les modifications</translation>
|
||||
<translation type="obsolete">Annuler les modifications</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/baseform.cpp" line="239"/>
|
||||
<source>Layer %1</source>
|
||||
<translation>Niveau %1</translation>
|
||||
<translation type="obsolete">Niveau %1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DialogColorGradation</name>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcolorgradation.cpp" line="129"/>
|
||||
<location filename="../gui_qt/dialogcolorgradation.cpp" line="34"/>
|
||||
<source>Paysages 3D - Color gradation editor</source>
|
||||
<translation>Paysages 3D - Editeur de gradients de couleur</translation>
|
||||
</message>
|
||||
|
@ -245,34 +239,28 @@
|
|||
<context>
|
||||
<name>FormColorGradation</name>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcolorgradation.cpp" line="51"/>
|
||||
<source>Preview</source>
|
||||
<translation>Aperçu</translation>
|
||||
<translation type="obsolete">Aperçu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcolorgradation.cpp" line="53"/>
|
||||
<source>Position</source>
|
||||
<translation>Position</translation>
|
||||
<translation type="obsolete">Position</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcolorgradation.cpp" line="54"/>
|
||||
<source>Color</source>
|
||||
<translation>Couleur</translation>
|
||||
<translation type="obsolete">Couleur</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcolorgradation.cpp" line="56"/>
|
||||
<source>Validate</source>
|
||||
<translation>Valider</translation>
|
||||
<translation type="obsolete">Valider</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcolorgradation.cpp" line="59"/>
|
||||
<source>Revert</source>
|
||||
<translation>Recommencer</translation>
|
||||
<translation type="obsolete">Recommencer</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcolorgradation.cpp" line="62"/>
|
||||
<source>Cancel</source>
|
||||
<translation>Annuler</translation>
|
||||
<translation type="obsolete">Annuler</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -504,7 +492,7 @@
|
|||
<context>
|
||||
<name>InputColorGradation</name>
|
||||
<message>
|
||||
<location filename="../gui_qt/inputcolorgradation.cpp" line="42"/>
|
||||
<location filename="../gui_qt/inputcolorgradation.cpp" line="41"/>
|
||||
<source>Edit</source>
|
||||
<translation>Editer</translation>
|
||||
</message>
|
||||
|
@ -550,9 +538,8 @@
|
|||
<translation>Nuages</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="98"/>
|
||||
<source>Lighting</source>
|
||||
<translation>Eclairage</translation>
|
||||
<translation type="obsolete">Eclairage</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/mainwindow.cpp" line="102"/>
|
||||
|
|
|
@ -78,7 +78,7 @@ void atmosphereValidateDefinition(AtmosphereDefinition* definition)
|
|||
{
|
||||
sky = skyCreateDefinition();
|
||||
sceneryGetSky(&sky);
|
||||
definition->color = colorGradationGet(&sky.haze_color, sky.daytime);
|
||||
definition->color = colorGradationGet(sky.haze_color, sky.daytime);
|
||||
skyDeleteDefinition(&sky);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,23 +108,23 @@ void autoGenRealisticLandscape(int seed)
|
|||
|
||||
/* Sky */
|
||||
sky = skyCreateDefinition();
|
||||
colorGradationQuickAddRgba(&sky.sun_color, 0.3, 1.0, 0.91, 0.8, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.sun_color, 0.5, 1.0, 0.95, 0.9, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.sun_color, 0.7, 1.0, 0.91, 0.8, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.zenith_color, 0.2, 0.03, 0.03, 0.05, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.zenith_color, 0.25, 0.25, 0.33, 0.37, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.zenith_color, 0.35, 0.52, 0.63, 0.8, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.zenith_color, 0.65, 0.52, 0.63, 0.8, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.zenith_color, 0.75, 0.25, 0.33, 0.37, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.zenith_color, 0.8, 0.03, 0.03, 0.05, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.haze_color, 0.2, 0.05, 0.05, 0.08, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.haze_color, 0.25, 0.55, 0.42, 0.42, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.haze_color, 0.3, 0.6, 0.6, 0.6, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.haze_color, 0.4, 0.92, 0.93, 1.0, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.haze_color, 0.6, 0.92, 0.93, 1.0, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.haze_color, 0.7, 0.6, 0.6, 0.8, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.haze_color, 0.75, 0.62, 0.50, 0.42, 1.0);
|
||||
colorGradationQuickAddRgba(&sky.haze_color, 0.8, 0.05, 0.05, 0.08, 1.0);
|
||||
colorGradationQuickAddRgb(sky.sun_color, 0.3, 1.0, 0.91, 0.8);
|
||||
colorGradationQuickAddRgb(sky.sun_color, 0.5, 1.0, 0.95, 0.9);
|
||||
colorGradationQuickAddRgb(sky.sun_color, 0.7, 1.0, 0.91, 0.8);
|
||||
colorGradationQuickAddRgb(sky.zenith_color, 0.2, 0.03, 0.03, 0.05);
|
||||
colorGradationQuickAddRgb(sky.zenith_color, 0.25, 0.25, 0.33, 0.37);
|
||||
colorGradationQuickAddRgb(sky.zenith_color, 0.35, 0.52, 0.63, 0.8);
|
||||
colorGradationQuickAddRgb(sky.zenith_color, 0.65, 0.52, 0.63, 0.8);
|
||||
colorGradationQuickAddRgb(sky.zenith_color, 0.75, 0.25, 0.33, 0.37);
|
||||
colorGradationQuickAddRgb(sky.zenith_color, 0.8, 0.03, 0.03, 0.05);
|
||||
colorGradationQuickAddRgb(sky.haze_color, 0.2, 0.05, 0.05, 0.08);
|
||||
colorGradationQuickAddRgb(sky.haze_color, 0.25, 0.55, 0.42, 0.42);
|
||||
colorGradationQuickAddRgb(sky.haze_color, 0.3, 0.6, 0.6, 0.6);
|
||||
colorGradationQuickAddRgb(sky.haze_color, 0.4, 0.92, 0.93, 1.0);
|
||||
colorGradationQuickAddRgb(sky.haze_color, 0.6, 0.92, 0.93, 1.0);
|
||||
colorGradationQuickAddRgb(sky.haze_color, 0.7, 0.6, 0.6, 0.8);
|
||||
colorGradationQuickAddRgb(sky.haze_color, 0.75, 0.62, 0.50, 0.42);
|
||||
colorGradationQuickAddRgb(sky.haze_color, 0.8, 0.05, 0.05, 0.08);
|
||||
sky.daytime = 0.0;
|
||||
sky.haze_height = 0.75;
|
||||
sky.haze_smoothing = 0.3;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <string.h>
|
||||
#include "shared/constants.h"
|
||||
#include "tools.h"
|
||||
#include "curve.h"
|
||||
|
||||
Color COLOR_TRANSPARENT = {0.0, 0.0, 0.0, 0.0};
|
||||
Color COLOR_BLACK = {0.0, 0.0, 0.0, 1.0};
|
||||
|
@ -14,13 +15,12 @@ Color COLOR_BLUE = {0.0, 0.0, 1.0, 1.0};
|
|||
Color COLOR_WHITE = {1.0, 1.0, 1.0, 1.0};
|
||||
Color COLOR_GREY = {0.5, 0.5, 0.5, 1.0};
|
||||
|
||||
ColorGradationPart COLORGRADATIONPART_NULL;
|
||||
|
||||
void colorInit()
|
||||
struct ColorGradation
|
||||
{
|
||||
COLORGRADATIONPART_NULL.col = COLOR_TRANSPARENT;
|
||||
COLORGRADATIONPART_NULL.start = 0.0;
|
||||
}
|
||||
Curve* red;
|
||||
Curve* green;
|
||||
Curve* blue;
|
||||
};
|
||||
|
||||
void colorSave(FILE* f, Color* col)
|
||||
{
|
||||
|
@ -110,158 +110,106 @@ double colorGetValue(Color* col)
|
|||
return max;
|
||||
}
|
||||
|
||||
ColorGradation colorGradationCreate()
|
||||
ColorGradation* colorGradationCreate()
|
||||
{
|
||||
ColorGradation result;
|
||||
ColorGradation* result;
|
||||
|
||||
result.nbparts = 0;
|
||||
result = malloc(sizeof(ColorGradation));
|
||||
result->red = curveCreate();
|
||||
result->green = curveCreate();
|
||||
result->blue = curveCreate();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int _part_compare(const void* part1, const void* part2)
|
||||
void colorGradationDelete(ColorGradation* gradation)
|
||||
{
|
||||
if (((ColorGradationPart*)part1)->start > ((ColorGradationPart*)part2)->start)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
curveDelete(gradation->red);
|
||||
curveDelete(gradation->green);
|
||||
curveDelete(gradation->blue);
|
||||
free(gradation);
|
||||
}
|
||||
|
||||
void colorGradationCopy(ColorGradation* source, ColorGradation* destination)
|
||||
{
|
||||
curveCopy(source->red, destination->red);
|
||||
curveCopy(source->green, destination->green);
|
||||
curveCopy(source->blue, destination->blue);
|
||||
}
|
||||
|
||||
void colorGradationSave(FILE* f, ColorGradation* gradation)
|
||||
{
|
||||
int i;
|
||||
|
||||
toolsSaveInt(f, &gradation->nbparts);
|
||||
for (i = 0; i < gradation->nbparts; i++)
|
||||
{
|
||||
toolsSaveDouble(f, &gradation->parts[i].start);
|
||||
colorSave(f, &gradation->parts[i].col);
|
||||
}
|
||||
curveSave(f, gradation->red);
|
||||
curveSave(f, gradation->green);
|
||||
curveSave(f, gradation->blue);
|
||||
}
|
||||
|
||||
void colorGradationLoad(FILE* f, ColorGradation* gradation)
|
||||
{
|
||||
int i;
|
||||
|
||||
toolsLoadInt(f, &gradation->nbparts);
|
||||
for (i = 0; i < gradation->nbparts; i++)
|
||||
{
|
||||
toolsLoadDouble(f, &gradation->parts[i].start);
|
||||
colorLoad(f, &gradation->parts[i].col);
|
||||
}
|
||||
curveLoad(f, gradation->red);
|
||||
curveLoad(f, gradation->green);
|
||||
curveLoad(f, gradation->blue);
|
||||
}
|
||||
|
||||
int colorGradationGetPartCount(ColorGradation* gradation)
|
||||
void colorGradationGetRedCurve(ColorGradation* gradation, Curve* curve)
|
||||
{
|
||||
return gradation->nbparts;
|
||||
curveCopy(gradation->red, curve);
|
||||
}
|
||||
|
||||
int colorGradationAddPart(ColorGradation* gradation)
|
||||
void colorGradationGetGreenCurve(ColorGradation* gradation, Curve* curve)
|
||||
{
|
||||
if (gradation->nbparts == MAX_COLORGRADATION_PARTS)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return gradation->nbparts++;
|
||||
}
|
||||
curveCopy(gradation->green, curve);
|
||||
}
|
||||
|
||||
void colorGradationDelPart(ColorGradation* gradation, int part)
|
||||
void colorGradationGetBlueCurve(ColorGradation* gradation, Curve* curve)
|
||||
{
|
||||
if (part >= 0 && part < gradation->nbparts)
|
||||
{
|
||||
memmove(gradation->parts + part, gradation->parts + part + 1, sizeof(ColorGradationPart) * (gradation->nbparts - part - 1));
|
||||
gradation->nbparts--;
|
||||
}
|
||||
curveCopy(gradation->blue, curve);
|
||||
}
|
||||
|
||||
ColorGradationPart colorGradationGetPart(ColorGradation* gradation, int part)
|
||||
void colorGradationSetRedCurve(ColorGradation* gradation, Curve* curve)
|
||||
{
|
||||
if (part >= 0 && part < gradation->nbparts)
|
||||
{
|
||||
return gradation->parts[part];
|
||||
}
|
||||
else
|
||||
{
|
||||
return COLORGRADATIONPART_NULL;
|
||||
}
|
||||
curveCopy(curve, gradation->red);
|
||||
curveValidate(gradation->red);
|
||||
}
|
||||
|
||||
void colorGradationSetPart(ColorGradation* gradation, int part, ColorGradationPart value)
|
||||
void colorGradationSetGreenCurve(ColorGradation* gradation, Curve* curve)
|
||||
{
|
||||
if (part >= 0 && part < gradation->nbparts)
|
||||
{
|
||||
gradation->parts[part] = value;
|
||||
}
|
||||
curveCopy(curve, gradation->green);
|
||||
curveValidate(gradation->green);
|
||||
}
|
||||
|
||||
void colorGradationSetBlueCurve(ColorGradation* gradation, Curve* curve)
|
||||
{
|
||||
curveCopy(curve, gradation->blue);
|
||||
curveValidate(gradation->blue);
|
||||
}
|
||||
|
||||
void colorGradationQuickAdd(ColorGradation* gradation, double value, Color* col)
|
||||
{
|
||||
if (gradation->nbparts == MAX_COLORGRADATION_PARTS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
gradation->parts[gradation->nbparts].start = value;
|
||||
gradation->parts[gradation->nbparts].col = *col;
|
||||
|
||||
if (gradation->nbparts++ > 1)
|
||||
{
|
||||
qsort(gradation->parts, gradation->nbparts, sizeof(ColorGradationPart), _part_compare);
|
||||
}
|
||||
}
|
||||
colorGradationQuickAddRgb(gradation, value, col->r, col->g, col->b);
|
||||
}
|
||||
|
||||
void colorGradationQuickAddRgba(ColorGradation* gradation, double value, double r, double g, double b, double a)
|
||||
void colorGradationQuickAddRgb(ColorGradation* gradation, double value, double r, double g, double b)
|
||||
{
|
||||
Color col;
|
||||
col.r = r;
|
||||
col.g = g;
|
||||
col.b = b;
|
||||
col.a = a;
|
||||
colorGradationQuickAdd(gradation, value, &col);
|
||||
curveQuickAddPoint(gradation->red, value, r);
|
||||
curveValidate(gradation->red);
|
||||
|
||||
curveQuickAddPoint(gradation->green, value, g);
|
||||
curveValidate(gradation->green);
|
||||
|
||||
curveQuickAddPoint(gradation->blue, value, b);
|
||||
curveValidate(gradation->blue);
|
||||
}
|
||||
|
||||
Color colorGradationGet(ColorGradation* gradation, double value)
|
||||
{
|
||||
Color result;
|
||||
int i;
|
||||
double fact;
|
||||
|
||||
if (gradation->nbparts == 0)
|
||||
{
|
||||
return COLOR_TRANSPARENT;
|
||||
}
|
||||
else if (gradation->nbparts == 1 || value <= gradation->parts[0].start)
|
||||
{
|
||||
return gradation->parts[0].col;
|
||||
}
|
||||
else if (value >= gradation->parts[gradation->nbparts - 1].start)
|
||||
{
|
||||
return gradation->parts[gradation->nbparts - 1].col;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 1; i < gradation->nbparts; i++)
|
||||
{
|
||||
if (value < gradation->parts[i].start)
|
||||
{
|
||||
fact = (value - gradation->parts[i - 1].start) / (gradation->parts[i].start - gradation->parts[i - 1].start);
|
||||
result.r = gradation->parts[i - 1].col.r + (gradation->parts[i].col.r - gradation->parts[i - 1].col.r) * fact;
|
||||
result.g = gradation->parts[i - 1].col.g + (gradation->parts[i].col.g - gradation->parts[i - 1].col.g) * fact;
|
||||
result.b = gradation->parts[i - 1].col.b + (gradation->parts[i].col.b - gradation->parts[i - 1].col.b) * fact;
|
||||
result.a = gradation->parts[i - 1].col.a + (gradation->parts[i].col.a - gradation->parts[i - 1].col.a) * fact;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return gradation->parts[gradation->nbparts - 1].col;
|
||||
}
|
||||
result.r = curveGetValue(gradation->red, value);
|
||||
result.g = curveGetValue(gradation->green, value);
|
||||
result.b = curveGetValue(gradation->blue, value);
|
||||
result.a = 1.0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,33 +3,46 @@
|
|||
|
||||
#include "shared/types.h"
|
||||
#include "shared/constants.h"
|
||||
#include "curve.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void colorInit();
|
||||
|
||||
/* Color */
|
||||
void colorSave(FILE* f, Color* col);
|
||||
void colorLoad(FILE* f, Color* col);
|
||||
|
||||
unsigned int colorTo32BitRGBA(Color* col);
|
||||
unsigned int colorTo32BitBGRA(Color* col);
|
||||
unsigned int colorTo32BitARGB(Color* col);
|
||||
unsigned int colorTo32BitABGR(Color* col);
|
||||
|
||||
void colorMask(Color* base, Color* mask);
|
||||
double colorNormalize(Color* col);
|
||||
double colorGetValue(Color* col);
|
||||
|
||||
ColorGradation colorGradationCreate();
|
||||
/* ColorGradation */
|
||||
typedef struct ColorGradation ColorGradation;
|
||||
|
||||
ColorGradation* colorGradationCreate();
|
||||
void colorGradationDelete(ColorGradation* gradation);
|
||||
void colorGradationCopy(ColorGradation* source, ColorGradation* destination);
|
||||
|
||||
void colorGradationSave(FILE* f, ColorGradation* gradation);
|
||||
void colorGradationLoad(FILE* f, ColorGradation* gradation);
|
||||
int colorGradationGetPartCount(ColorGradation* gradation);
|
||||
int colorGradationAddPart(ColorGradation* gradation);
|
||||
void colorGradationDelPart(ColorGradation* gradation, int part);
|
||||
ColorGradationPart colorGradationGetPart(ColorGradation* gradation, int part);
|
||||
void colorGradationSetPart(ColorGradation* gradation, int part, ColorGradationPart value);
|
||||
|
||||
void colorGradationGetRedCurve(ColorGradation* gradation, Curve* curve);
|
||||
void colorGradationGetGreenCurve(ColorGradation* gradation, Curve* curve);
|
||||
void colorGradationGetBlueCurve(ColorGradation* gradation, Curve* curve);
|
||||
|
||||
void colorGradationSetRedCurve(ColorGradation* gradation, Curve* curve);
|
||||
void colorGradationSetGreenCurve(ColorGradation* gradation, Curve* curve);
|
||||
void colorGradationSetBlueCurve(ColorGradation* gradation, Curve* curve);
|
||||
|
||||
void colorGradationQuickAdd(ColorGradation* gradation, double value, Color* col);
|
||||
void colorGradationQuickAddRgba(ColorGradation* gradation, double value, double r, double g, double b, double a);
|
||||
void colorGradationQuickAddRgb(ColorGradation* gradation, double value, double r, double g, double b);
|
||||
|
||||
Color colorGradationGet(ColorGradation* gradation, double value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
148
lib_paysages/curve.c
Normal file
148
lib_paysages/curve.c
Normal file
|
@ -0,0 +1,148 @@
|
|||
#include "curve.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "tools.h"
|
||||
|
||||
#define MAX_NB_POINTS 40
|
||||
|
||||
struct Curve
|
||||
{
|
||||
int nbpoints;
|
||||
CurvePoint points[MAX_NB_POINTS];
|
||||
};
|
||||
|
||||
Curve* curveCreate()
|
||||
{
|
||||
Curve* result;
|
||||
|
||||
result = malloc(sizeof(Curve));
|
||||
result->nbpoints = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void curveDelete(Curve* curve)
|
||||
{
|
||||
free(curve);
|
||||
}
|
||||
|
||||
void curveCopy(Curve* source, Curve* destination)
|
||||
{
|
||||
*destination = *source;
|
||||
}
|
||||
|
||||
void curveSave(FILE* f, Curve* curve)
|
||||
{
|
||||
int i;
|
||||
|
||||
toolsSaveInt(f, &curve->nbpoints);
|
||||
for (i = 0; i < curve->nbpoints; i++)
|
||||
{
|
||||
toolsSaveDouble(f, &curve->points[i].position);
|
||||
toolsSaveDouble(f, &curve->points[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
void curveLoad(FILE* f, Curve* curve)
|
||||
{
|
||||
int i;
|
||||
|
||||
toolsLoadInt(f, &curve->nbpoints);
|
||||
for (i = 0; i < curve->nbpoints; i++)
|
||||
{
|
||||
toolsLoadDouble(f, &curve->points[i].position);
|
||||
toolsLoadDouble(f, &curve->points[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
void curveClear(Curve* curve)
|
||||
{
|
||||
curve->nbpoints = 0;
|
||||
}
|
||||
|
||||
int curveAddPoint(Curve* curve, CurvePoint* point)
|
||||
{
|
||||
if (curve->nbpoints < MAX_NB_POINTS)
|
||||
{
|
||||
curve->points[curve->nbpoints] = *point;
|
||||
return curve->nbpoints++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int curveQuickAddPoint(Curve* curve, double position, double value)
|
||||
{
|
||||
CurvePoint point;
|
||||
|
||||
point.position = position;
|
||||
point.value = value;
|
||||
|
||||
return curveAddPoint(curve, &point);
|
||||
}
|
||||
|
||||
int curveGetPointCount(Curve* curve)
|
||||
{
|
||||
return curve->nbpoints;
|
||||
}
|
||||
|
||||
void curveGetPoint(Curve* curve, int number, CurvePoint* point)
|
||||
{
|
||||
if (number >= 0 && number < curve->nbpoints)
|
||||
{
|
||||
*point = curve->points[number];
|
||||
}
|
||||
}
|
||||
|
||||
int _point_compare(const void* part1, const void* part2)
|
||||
{
|
||||
if (((CurvePoint*)part1)->position > ((CurvePoint*)part2)->position)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void curveValidate(Curve* curve)
|
||||
{
|
||||
if (curve->nbpoints > 1)
|
||||
{
|
||||
qsort(curve->points, curve->nbpoints, sizeof(CurvePoint), _point_compare);
|
||||
}
|
||||
}
|
||||
|
||||
double curveGetValue(Curve* curve, double position)
|
||||
{
|
||||
int i;
|
||||
double fact;
|
||||
|
||||
if (curve->nbpoints == 0)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
else if (curve->nbpoints == 1 || position <= curve->points[0].position)
|
||||
{
|
||||
return curve->points[0].value;
|
||||
}
|
||||
else if (position >= curve->points[curve->nbpoints - 1].position)
|
||||
{
|
||||
return curve->points[curve->nbpoints - 1].value;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 1; i < curve->nbpoints; i++)
|
||||
{
|
||||
if (position < curve->points[i].position)
|
||||
{
|
||||
fact = (position - curve->points[i - 1].position) / (curve->points[i].position - curve->points[i - 1].position);
|
||||
return curve->points[i - 1].value + (curve->points[i].value - curve->points[i - 1].value) * fact;
|
||||
}
|
||||
}
|
||||
return curve->points[curve->nbpoints - 1].value;
|
||||
}
|
||||
}
|
36
lib_paysages/curve.h
Normal file
36
lib_paysages/curve.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef _PAYSAGES_CURVE_H_
|
||||
#define _PAYSAGES_CURVE_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
double position;
|
||||
double value;
|
||||
} CurvePoint;
|
||||
typedef struct Curve Curve;
|
||||
|
||||
Curve* curveCreate();
|
||||
void curveDelete(Curve* curve);
|
||||
void curveCopy(Curve* source, Curve* destination);
|
||||
|
||||
void curveSave(FILE* f, Curve* curve);
|
||||
void curveLoad(FILE* f, Curve* curve);
|
||||
|
||||
void curveClear(Curve* curve);
|
||||
int curveAddPoint(Curve* curve, CurvePoint* point);
|
||||
int curveQuickAddPoint(Curve* curve, double position, double value);
|
||||
int curveGetPointCount(Curve* curve);
|
||||
void curveGetPoint(Curve* curve, int number, CurvePoint* point);
|
||||
void curveValidate(Curve* curve);
|
||||
|
||||
double curveGetValue(Curve* curve, double position);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -22,7 +22,6 @@ void paysagesInit()
|
|||
ilInit();
|
||||
iluInit();
|
||||
|
||||
colorInit();
|
||||
sceneryInit();
|
||||
renderInit();
|
||||
|
||||
|
|
|
@ -42,18 +42,6 @@ typedef struct
|
|||
double a;
|
||||
} Color;
|
||||
|
||||
#define MAX_COLORGRADATION_PARTS 10
|
||||
typedef struct
|
||||
{
|
||||
double start;
|
||||
Color col;
|
||||
} ColorGradationPart;
|
||||
typedef struct
|
||||
{
|
||||
int nbparts;
|
||||
ColorGradationPart parts[MAX_COLORGRADATION_PARTS];
|
||||
} ColorGradation;
|
||||
|
||||
struct RenderFragment;
|
||||
struct Renderer;
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ void skyQuit()
|
|||
void skySave(FILE* f, SkyDefinition* definition)
|
||||
{
|
||||
toolsSaveDouble(f, &definition->daytime);
|
||||
colorGradationSave(f, &definition->sun_color);
|
||||
colorGradationSave(f, definition->sun_color);
|
||||
toolsSaveDouble(f, &definition->sun_radius);
|
||||
colorGradationSave(f, &definition->zenith_color);
|
||||
colorGradationSave(f, &definition->haze_color);
|
||||
colorGradationSave(f, definition->zenith_color);
|
||||
colorGradationSave(f, definition->haze_color);
|
||||
toolsSaveDouble(f, &definition->haze_height);
|
||||
toolsSaveDouble(f, &definition->haze_smoothing);
|
||||
}
|
||||
|
@ -36,10 +36,10 @@ void skySave(FILE* f, SkyDefinition* definition)
|
|||
void skyLoad(FILE* f, SkyDefinition* definition)
|
||||
{
|
||||
toolsLoadDouble(f, &definition->daytime);
|
||||
colorGradationLoad(f, &definition->sun_color);
|
||||
colorGradationLoad(f, definition->sun_color);
|
||||
toolsLoadDouble(f, &definition->sun_radius);
|
||||
colorGradationLoad(f, &definition->zenith_color);
|
||||
colorGradationLoad(f, &definition->haze_color);
|
||||
colorGradationLoad(f, definition->zenith_color);
|
||||
colorGradationLoad(f, definition->haze_color);
|
||||
toolsLoadDouble(f, &definition->haze_height);
|
||||
toolsLoadDouble(f, &definition->haze_smoothing);
|
||||
|
||||
|
@ -65,25 +65,36 @@ SkyDefinition skyCreateDefinition()
|
|||
|
||||
void skyDeleteDefinition(SkyDefinition* definition)
|
||||
{
|
||||
colorGradationDelete(definition->sun_color);
|
||||
colorGradationDelete(definition->zenith_color);
|
||||
colorGradationDelete(definition->haze_color);
|
||||
}
|
||||
|
||||
void skyCopyDefinition(SkyDefinition* source, SkyDefinition* destination)
|
||||
{
|
||||
*destination = *source;
|
||||
destination->daytime = source->daytime;
|
||||
destination->sun_radius = source->sun_radius;
|
||||
destination->haze_height = source->haze_height;
|
||||
destination->haze_smoothing = source->haze_smoothing;
|
||||
|
||||
colorGradationCopy(source->sun_color, destination->sun_color);
|
||||
colorGradationCopy(source->zenith_color, destination->zenith_color);
|
||||
colorGradationCopy(source->haze_color, destination->haze_color);
|
||||
colorGradationCopy(source->_sky_gradation, destination->_sky_gradation);
|
||||
}
|
||||
|
||||
void skyValidateDefinition(SkyDefinition* definition)
|
||||
{
|
||||
Color zenith, haze;
|
||||
|
||||
zenith = colorGradationGet(&definition->zenith_color, definition->daytime);
|
||||
haze = colorGradationGet(&definition->haze_color, definition->daytime);
|
||||
zenith = colorGradationGet(definition->zenith_color, definition->daytime);
|
||||
haze = colorGradationGet(definition->haze_color, definition->daytime);
|
||||
|
||||
definition->_sky_gradation = colorGradationCreate();
|
||||
colorGradationQuickAdd(&definition->_sky_gradation, 0.0, &haze);
|
||||
colorGradationQuickAdd(&definition->_sky_gradation, definition->haze_height - definition->haze_smoothing, &haze);
|
||||
colorGradationQuickAdd(&definition->_sky_gradation, definition->haze_height, &zenith);
|
||||
colorGradationQuickAdd(&definition->_sky_gradation, 1.0, &zenith);
|
||||
colorGradationQuickAdd(definition->_sky_gradation, 0.0, &haze);
|
||||
colorGradationQuickAdd(definition->_sky_gradation, definition->haze_height - definition->haze_smoothing, &haze);
|
||||
colorGradationQuickAdd(definition->_sky_gradation, definition->haze_height, &zenith);
|
||||
colorGradationQuickAdd(definition->_sky_gradation, 1.0, &zenith);
|
||||
}
|
||||
|
||||
int skyGetLights(SkyDefinition* sky, LightDefinition* lights, int max_lights)
|
||||
|
@ -103,7 +114,7 @@ int skyGetLights(SkyDefinition* sky, LightDefinition* lights, int max_lights)
|
|||
{
|
||||
/* Light from the sun */
|
||||
lights[0].direction = v3Scale(sun_direction, -1.0);
|
||||
lights[0].color = colorGradationGet(&sky->sun_color, sky->daytime);
|
||||
lights[0].color = colorGradationGet(sky->sun_color, sky->daytime);
|
||||
lights[0].reflection = 1.0;
|
||||
lights[0].filtered = 1;
|
||||
lights[0].masked = 1;
|
||||
|
@ -115,7 +126,7 @@ int skyGetLights(SkyDefinition* sky, LightDefinition* lights, int max_lights)
|
|||
lights[1].direction.x = 0.0;
|
||||
lights[1].direction.y = -1.0;
|
||||
lights[1].direction.z = 0.0;
|
||||
lights[1].color = colorGradationGet(&sky->zenith_color, sky->daytime);
|
||||
lights[1].color = colorGradationGet(sky->zenith_color, sky->daytime);
|
||||
lights[1].color.r *= 0.6;
|
||||
lights[1].color.g *= 0.6;
|
||||
lights[1].color.b *= 0.6;
|
||||
|
@ -144,11 +155,11 @@ Color skyGetColor(SkyDefinition* definition, Renderer* renderer, Vector3 eye, Ve
|
|||
look = v3Normalize(look);
|
||||
dist = v3Norm(v3Sub(look, sun_position));
|
||||
|
||||
sky_color = colorGradationGet(&definition->_sky_gradation, look.y * 0.5 + 0.5);
|
||||
sky_color = colorGradationGet(definition->_sky_gradation, look.y * 0.5 + 0.5);
|
||||
if (dist < definition->sun_radius)
|
||||
{
|
||||
dist = dist / definition->sun_radius;
|
||||
sun_color = colorGradationGet(&definition->sun_color, definition->daytime);
|
||||
sun_color = colorGradationGet(definition->sun_color, definition->daytime);
|
||||
if (dist < 0.9)
|
||||
{
|
||||
return sun_color;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _PAYSAGES_SKY_H_
|
||||
|
||||
#include "shared/types.h"
|
||||
#include "color.h"
|
||||
#include "lighting.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -12,13 +13,13 @@ extern "C" {
|
|||
typedef struct
|
||||
{
|
||||
double daytime;
|
||||
ColorGradation sun_color;
|
||||
ColorGradation* sun_color;
|
||||
double sun_radius;
|
||||
ColorGradation zenith_color;
|
||||
ColorGradation haze_color;
|
||||
ColorGradation* zenith_color;
|
||||
ColorGradation* haze_color;
|
||||
double haze_height;
|
||||
double haze_smoothing;
|
||||
ColorGradation _sky_gradation;
|
||||
ColorGradation* _sky_gradation;
|
||||
} SkyDefinition;
|
||||
|
||||
void skyInit();
|
||||
|
|
Loading…
Reference in a new issue