paysages : ColorGradation dialog.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@271 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-02-21 13:41:02 +00:00 committed by ThunderK
parent 22726e02e6
commit fabcec1cfd
25 changed files with 236 additions and 110 deletions

View file

@ -96,7 +96,7 @@ void BaseForm::configChangeEvent()
button_revert->setEnabled(true);
}
QList<Preview*> list_previews = previews->findChildren<Preview*>("_form_preview_");
QList<BasePreview*> list_previews = previews->findChildren<BasePreview*>("_form_preview_");
for (int i = 0; i < list_previews.size(); i++)
{
list_previews[i]->redraw();
@ -148,7 +148,7 @@ void BaseForm::layerListChanged()
layerSelectedEvent(layer_list->currentIndex());
}
void BaseForm::addPreview(Preview* preview, QString label)
void BaseForm::addPreview(BasePreview* preview, QString label)
{
previews->layout()->addWidget(new QLabel(label, previews));
previews->layout()->addWidget(preview);
@ -238,9 +238,19 @@ void BaseForm::setLayerCount(int layer_count)
{
layer_list->addItem(QString("Layer %1").arg(i + 1));
}
if (selected >= 0)
{
if (selected > layer_count)
{
layer_list->setCurrentIndex(layer_count - 1);
}
else
{
layer_list->setCurrentIndex(selected);
}
}
}
}
void BaseForm::layerAddedEvent()
{
@ -261,7 +271,7 @@ void BaseForm::layerSelectedEvent(int layer)
inputs[i]->revert();
}
QList<Preview*> list_previews = previews->findChildren<Preview*>("_form_preview_");
QList<BasePreview*> list_previews = previews->findChildren<BasePreview*>("_form_preview_");
for (int i = 0; i < list_previews.size(); i++)
{
list_previews[i]->redraw();

View file

@ -4,7 +4,7 @@
#include <QWidget>
#include <QPushButton>
#include <QComboBox>
#include "preview.h"
#include "basepreview.h"
#include "baseinput.h"
#include "../lib_paysages/shared/types.h"
#include "../lib_paysages/noise.h"
@ -32,7 +32,7 @@ private slots:
void layerListChanged();
protected:
void addPreview(Preview* preview, QString label);
void addPreview(BasePreview* preview, QString label);
QPushButton* addButton(QString label);
void addInput(BaseInput* input);
void addInputInt(QString label, int* value, int min, int max, int small_step, int large_step);

View file

@ -1,4 +1,4 @@
#include "preview.h"
#include "basepreview.h"
#include <QVector>
#include <QPainter>
@ -8,7 +8,7 @@
class PreviewDrawer:public QThread
{
public:
PreviewDrawer(Preview* preview):
PreviewDrawer(BasePreview* preview):
QThread(),
_preview(preview)
{
@ -29,11 +29,11 @@ protected:
}
}
private:
Preview* _preview;
BasePreview* _preview;
bool _running;
};
Preview::Preview(QWidget* parent) :
BasePreview::BasePreview(QWidget* parent) :
QWidget(parent)
{
this->lock_drawing = new QMutex();
@ -65,7 +65,7 @@ Preview::Preview(QWidget* parent) :
this->updater = new PreviewDrawer(this);
}
Preview::~Preview()
BasePreview::~BasePreview()
{
alive = false;
@ -77,21 +77,21 @@ Preview::~Preview()
delete lock_drawing;
}
void Preview::updateData()
void BasePreview::updateData()
{
}
QColor Preview::getColor(double x, double y)
QColor BasePreview::getColor(double x, double y)
{
return QColor(0, 0, 0);
}
void Preview::start()
void BasePreview::start()
{
this->updater->start();
}
void Preview::doRender()
void BasePreview::doRender()
{
if (this->alive)
{
@ -107,12 +107,12 @@ void Preview::doRender()
}
}
void Preview::redraw()
void BasePreview::redraw()
{
emit(redrawRequested());
}
void Preview::handleRedraw()
void BasePreview::handleRedraw()
{
need_rerender = true;
lock_drawing->lock();
@ -121,14 +121,14 @@ void Preview::handleRedraw()
lock_drawing->unlock();
}
void Preview::setScaling(double scaling)
void BasePreview::setScaling(double scaling)
{
// TODO Follow conf_scale
this->scaling = scaling;
redraw();
}
void Preview::resizeEvent(QResizeEvent* event)
void BasePreview::resizeEvent(QResizeEvent* event)
{
QImage* image;
@ -147,13 +147,13 @@ void Preview::resizeEvent(QResizeEvent* event)
this->lock_drawing->unlock();
}
void Preview::paintEvent(QPaintEvent* event)
void BasePreview::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
painter.drawImage(0, 0, *this->pixbuf);
}
void Preview::forceRender()
void BasePreview::forceRender()
{
this->lock_drawing->lock();
this->pixbuf->fill(0x00000000);
@ -162,7 +162,7 @@ void Preview::forceRender()
this->lock_drawing->unlock();
}
void Preview::renderPixbuf()
void BasePreview::renderPixbuf()
{
QColor col;
bool done;
@ -205,7 +205,7 @@ void Preview::renderPixbuf()
}
}
void Preview::wheelEvent(QWheelEvent* event)
void BasePreview::wheelEvent(QWheelEvent* event)
{
if (event->orientation() == Qt::Vertical)
{

View file

@ -1,18 +1,18 @@
#ifndef _PAYSAGES_QT_PREVIEW_H_
#define _PAYSAGES_QT_PREVIEW_H_
#ifndef _PAYSAGES_QT_BASEPREVIEW_H_
#define _PAYSAGES_QT_BASEPREVIEW_H_
#include <QMutex>
#include <QImage>
#include <QWidget>
#include <QThread>
class Preview:public QWidget
class BasePreview:public QWidget
{
Q_OBJECT
public:
Preview(QWidget* parent);
~Preview();
BasePreview(QWidget* parent);
~BasePreview();
void start();
void doRender();

View file

@ -9,43 +9,92 @@
#include <QScrollArea>
#include <QPushButton>
#include "baseform.h"
#include "tools.h"
/**************** Dialog form ****************/
/**************** 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), "Preview");
addInputDouble("Position", &_layer.start, 0.0, 1.0, 0.01, 0.1);
addInputColor("Color", &_layer.col);
setLayerCount(gradation->nbparts);
button = addButton("Validate");
QObject::connect(button, SIGNAL(clicked()), parent, SLOT(accept()));
button = addButton("Revert");
QObject::connect(button, SIGNAL(clicked()), parent, SLOT(revert()));
button = addButton("Cancel");
QObject::connect(button, SIGNAL(clicked()), parent, SLOT(reject()));
revertConfig();
}
~FormColorGradation()
void revertConfig()
{
setLayerCount(colorGradationGetPartCount(_gradation));
}
void configChangeEvent()
{
colorGradationSetPart(_gradation, currentLayer(), _layer);
BaseForm::configChangeEvent();
}
void layerAddedEvent()
{
/*if (cloudsAddLayer(&_definition) >= 0)
if (colorGradationAddPart(_gradation) >= 0)
{
BaseForm::layerAddedEvent();
}*/
}
}
void layerDeletedEvent(int layer)
{
/*cloudsDeleteLayer(&_definition, layer);
colorGradationDelPart(_gradation, layer);
BaseForm::layerDeletedEvent(layer);*/
BaseForm::layerDeletedEvent(layer);
}
void layerSelectedEvent(int layer)
{
_layer = _gradation->parts[layer];
_layer = colorGradationGetPart(_gradation, layer);
BaseForm::layerSelectedEvent(layer);
}
@ -60,18 +109,18 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad
QDialog(parent)
{
QWidget* preview;
BaseForm* form;
_base = gradation;
_current = colorGradationCreate();
_current = *_base;
setLayout(new QHBoxLayout());
preview = new QWidget(this);
layout()->addWidget(preview);
form = new FormColorGradation(this, &_current);
layout()->addWidget(form);
_form = new FormColorGradation(this, &_current);
layout()->addWidget(_form);
/*QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept()));
QObject::connect(button, SIGNAL(clicked()), this, SLOT(revert()));
@ -118,4 +167,5 @@ void DialogColorGradation::revert()
void DialogColorGradation::revertToCurrent()
{
_form->revertConfig();
}

View file

@ -2,6 +2,7 @@
#define _PAYSAGES_QT_DIALOGCOLORGRADATION_H_
#include <QDialog>
#include "baseform.h"
#include "../lib_paysages/color.h"
@ -27,6 +28,7 @@ private:
private:
ColorGradation* _base;
ColorGradation _current;
BaseForm* _form;
};
#endif

View file

@ -10,10 +10,10 @@
#include <QPushButton>
/**************** Previews ****************/
class PreviewLevel:public Preview
class PreviewLevel:public BasePreview
{
public:
PreviewLevel(QWidget* parent, NoiseGenerator* noise): Preview(parent)
PreviewLevel(QWidget* parent, NoiseGenerator* noise): BasePreview(parent)
{
_noise_original = noise;
_noise_preview = noiseCreateGenerator();
@ -47,10 +47,10 @@ private:
int _level;
};
class PreviewTotal:public Preview
class PreviewTotal:public BasePreview
{
public:
PreviewTotal(QWidget* parent, NoiseGenerator* noise): Preview(parent)
PreviewTotal(QWidget* parent, NoiseGenerator* noise): BasePreview(parent)
{
_noise_original = noise;
_noise_preview = noiseCreateGenerator();

View file

@ -3,7 +3,7 @@
#include <QDialog>
#include <QListWidget>
#include "preview.h"
#include "basepreview.h"
#include "../lib_paysages/noise.h"
@ -38,8 +38,8 @@ private:
NoiseGenerator* _current;
int _current_level;
NoiseLevel _current_level_params;
Preview* previewLevel;
Preview* previewTotal;
BasePreview* previewLevel;
BasePreview* previewTotal;
QListWidget* levels;
QSlider* slider_height;
QSlider* slider_scaling;

View file

@ -9,11 +9,11 @@
static AtmosphereDefinition _definition;
/**************** Previews ****************/
class PreviewAtmosphereColor:public Preview
class PreviewAtmosphereColor:public BasePreview
{
public:
PreviewAtmosphereColor(QWidget* parent):
Preview(parent)
BasePreview(parent)
{
_renderer = rendererCreate();
_preview_definition = atmosphereCreateDefinition();

View file

@ -2,7 +2,7 @@
#define _PAYSAGES_QT_FORMATMOSPHERE_H_
#include <QWidget>
#include "preview.h"
#include "basepreview.h"
#include "baseform.h"
class FormAtmosphere : public BaseForm
@ -20,7 +20,7 @@ protected slots:
virtual void configChangeEvent();
private:
Preview* previewColor;
BasePreview* previewColor;
};
#endif

View file

@ -12,10 +12,10 @@ static CloudsDefinition _definition;
static CloudsLayerDefinition _layer;
/**************** Previews ****************/
class PreviewCloudsCoverage:public Preview
class PreviewCloudsCoverage:public BasePreview
{
public:
PreviewCloudsCoverage(QWidget* parent):Preview(parent)
PreviewCloudsCoverage(QWidget* parent):BasePreview(parent)
{
_renderer = rendererCreate();
_renderer.render_quality = 3;
@ -51,10 +51,10 @@ private:
CloudsLayerDefinition _preview_layer;
};
class PreviewCloudsColor:public Preview
class PreviewCloudsColor:public BasePreview
{
public:
PreviewCloudsColor(QWidget* parent):Preview(parent)
PreviewCloudsColor(QWidget* parent):BasePreview(parent)
{
LightDefinition light;

View file

@ -2,7 +2,7 @@
#define _PAYSAGES_QT_FORMCLOUDS_H_
#include <QWidget>
#include "preview.h"
#include "basepreview.h"
#include "baseform.h"
class FormClouds : public BaseForm
@ -25,8 +25,8 @@ protected:
virtual void layerSelectedEvent(int layer);
private:
Preview* previewCoverage;
Preview* previewColor;
BasePreview* previewCoverage;
BasePreview* previewColor;
};
#endif

View file

@ -2,7 +2,7 @@
#define _PAYSAGES_QT_FORMLIGHTING_H_
#include <QWidget>
#include "preview.h"
#include "basepreview.h"
#include "baseform.h"
class FormLighting : public BaseForm
@ -20,7 +20,7 @@ protected slots:
virtual void configChangeEvent();
private:
Preview* previewColor;
BasePreview* previewColor;
};
#endif

View file

@ -14,11 +14,11 @@
static SkyDefinition _definition;
/**************** Previews ****************/
class PreviewSkyEast:public Preview
class PreviewSkyEast:public BasePreview
{
public:
PreviewSkyEast(QWidget* parent):
Preview(parent)
BasePreview(parent)
{
_renderer = rendererCreate();
_preview_definition = skyCreateDefinition();
@ -44,11 +44,11 @@ private:
SkyDefinition _preview_definition;
};
class PreviewSkyWest:public Preview
class PreviewSkyWest:public BasePreview
{
public:
PreviewSkyWest(QWidget* parent):
Preview(parent)
BasePreview(parent)
{
_renderer = rendererCreate();
_preview_definition = skyCreateDefinition();

View file

@ -2,7 +2,7 @@
#define _PAYSAGES_QT_FORMSKY_H_
#include <QWidget>
#include "preview.h"
#include "basepreview.h"
#include "baseform.h"
class FormSky : public BaseForm
@ -20,8 +20,8 @@ protected slots:
virtual void configChangeEvent();
private:
Preview* previewEast;
Preview* previewWest;
BasePreview* previewEast;
BasePreview* previewWest;
};
#endif // _PAYSAGES_QT_FORMSKY_H_

View file

@ -12,10 +12,10 @@
static TerrainDefinition _definition;
/**************** Previews ****************/
class PreviewTerrainHeight:public Preview
class PreviewTerrainHeight:public BasePreview
{
public:
PreviewTerrainHeight(QWidget* parent):Preview(parent)
PreviewTerrainHeight(QWidget* parent):BasePreview(parent)
{
_preview_definition = terrainCreateDefinition();
}
@ -35,10 +35,10 @@ private:
TerrainDefinition _preview_definition;
};
class PreviewTerrainColor:public Preview
class PreviewTerrainColor:public BasePreview
{
public:
PreviewTerrainColor(QWidget* parent):Preview(parent)
PreviewTerrainColor(QWidget* parent):BasePreview(parent)
{
_renderer = rendererCreate();
_renderer.applyTextures = _applyTextures;

View file

@ -2,7 +2,7 @@
#define _PAYSAGES_QT_FORMTERRAIN_H_
#include <QWidget>
#include "preview.h"
#include "basepreview.h"
#include "baseform.h"
class FormTerrain : public BaseForm
@ -20,8 +20,8 @@ protected slots:
virtual void configChangeEvent();
private:
Preview* previewHeight;
Preview* previewColor;
BasePreview* previewHeight;
BasePreview* previewColor;
};
#endif

View file

@ -2,7 +2,7 @@
#define _PAYSAGES_QT_FORMTEXTURES_H_
#include <QWidget>
#include "preview.h"
#include "basepreview.h"
#include "baseform.h"
class FormTextures : public BaseForm
@ -20,8 +20,8 @@ protected slots:
virtual void configChangeEvent();
private:
Preview* previewCoverage;
Preview* previewColor;
BasePreview* previewCoverage;
BasePreview* previewColor;
};
#endif

View file

@ -1,4 +1,4 @@
#include "preview.h"
#include "basepreview.h"
#include "formwater.h"
#include <QColor>
@ -17,10 +17,10 @@
static WaterDefinition _definition;
/**************** Previews ****************/
class PreviewWaterCoverage:public Preview
class PreviewWaterCoverage:public BasePreview
{
public:
PreviewWaterCoverage(QWidget* parent):Preview(parent)
PreviewWaterCoverage(QWidget* parent):BasePreview(parent)
{
_water = waterCreateDefinition();
_terrain = terrainCreateDefinition();
@ -51,10 +51,10 @@ private:
TerrainDefinition _terrain;
};
class PreviewWaterColor:public Preview
class PreviewWaterColor:public BasePreview
{
public:
PreviewWaterColor(QWidget* parent):Preview(parent)
PreviewWaterColor(QWidget* parent):BasePreview(parent)
{
LightDefinition light;

View file

@ -2,7 +2,7 @@
#define _PAYSAGES_QT_FORMWATER_H_
#include <QWidget>
#include "preview.h"
#include "basepreview.h"
#include "baseform.h"
class FormWater : public BaseForm
@ -17,8 +17,8 @@ public slots:
virtual void applyConfig();
private:
Preview* previewCoverage;
Preview* previewColor;
BasePreview* previewCoverage;
BasePreview* previewColor;
};
#endif // _PAYSAGES_QT_FORMWATER_H_

View file

@ -108,23 +108,23 @@ void autoGenRealisticLandscape(int seed)
/* Sky */
sky = skyCreateDefinition();
colorGradationAddRgba(&sky.sun_color, 0.3, 1.0, 0.91, 0.8, 1.0);
colorGradationAddRgba(&sky.sun_color, 0.5, 1.0, 0.95, 0.9, 1.0);
colorGradationAddRgba(&sky.sun_color, 0.7, 1.0, 0.91, 0.8, 1.0);
colorGradationAddRgba(&sky.zenith_color, 0.2, 0.03, 0.03, 0.05, 1.0);
colorGradationAddRgba(&sky.zenith_color, 0.25, 0.25, 0.33, 0.37, 1.0);
colorGradationAddRgba(&sky.zenith_color, 0.35, 0.52, 0.63, 0.8, 1.0);
colorGradationAddRgba(&sky.zenith_color, 0.65, 0.52, 0.63, 0.8, 1.0);
colorGradationAddRgba(&sky.zenith_color, 0.75, 0.25, 0.33, 0.37, 1.0);
colorGradationAddRgba(&sky.zenith_color, 0.8, 0.03, 0.03, 0.05, 1.0);
colorGradationAddRgba(&sky.haze_color, 0.2, 0.05, 0.05, 0.08, 1.0);
colorGradationAddRgba(&sky.haze_color, 0.25, 0.55, 0.42, 0.42, 1.0);
colorGradationAddRgba(&sky.haze_color, 0.3, 0.6, 0.6, 0.6, 1.0);
colorGradationAddRgba(&sky.haze_color, 0.4, 0.92, 0.93, 1.0, 1.0);
colorGradationAddRgba(&sky.haze_color, 0.6, 0.92, 0.93, 1.0, 1.0);
colorGradationAddRgba(&sky.haze_color, 0.7, 0.6, 0.6, 0.8, 1.0);
colorGradationAddRgba(&sky.haze_color, 0.75, 0.62, 0.50, 0.42, 1.0);
colorGradationAddRgba(&sky.haze_color, 0.8, 0.05, 0.05, 0.08, 1.0);
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);
sky.daytime = 0.0;
sky.haze_height = 0.75;
sky.haze_smoothing = 0.3;

View file

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "shared/constants.h"
#include "tools.h"
@ -13,6 +14,14 @@ 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()
{
COLORGRADATIONPART_NULL.col = COLOR_TRANSPARENT;
COLORGRADATIONPART_NULL.start = 0.0;
}
void colorSave(FILE* f, Color* col)
{
toolsSaveDouble(f, &col->r);
@ -146,7 +155,53 @@ void colorGradationLoad(FILE* f, ColorGradation* gradation)
}
}
void colorGradationAdd(ColorGradation* gradation, double value, Color* col)
int colorGradationGetPartCount(ColorGradation* gradation)
{
return gradation->nbparts;
}
int colorGradationAddPart(ColorGradation* gradation)
{
if (gradation->nbparts == MAX_COLORGRADATION_PARTS)
{
return -1;
}
else
{
return gradation->nbparts++;
}
}
void colorGradationDelPart(ColorGradation* gradation, int part)
{
if (part >= 0 && part < gradation->nbparts)
{
memmove(gradation->parts + part, gradation->parts + part + 1, sizeof(ColorGradationPart) * (gradation->nbparts - part - 1));
gradation->nbparts--;
}
}
ColorGradationPart colorGradationGetPart(ColorGradation* gradation, int part)
{
if (part >= 0 && part < gradation->nbparts)
{
return gradation->parts[part];
}
else
{
return COLORGRADATIONPART_NULL;
}
}
void colorGradationSetPart(ColorGradation* gradation, int part, ColorGradationPart value)
{
if (part >= 0 && part < gradation->nbparts)
{
gradation->parts[part] = value;
}
}
void colorGradationQuickAdd(ColorGradation* gradation, double value, Color* col)
{
if (gradation->nbparts == MAX_COLORGRADATION_PARTS)
{
@ -164,14 +219,14 @@ void colorGradationAdd(ColorGradation* gradation, double value, Color* col)
}
}
void colorGradationAddRgba(ColorGradation* gradation, double value, double r, double g, double b, double a)
void colorGradationQuickAddRgba(ColorGradation* gradation, double value, double r, double g, double b, double a)
{
Color col;
col.r = r;
col.g = g;
col.b = b;
col.a = a;
colorGradationAdd(gradation, value, &col);
colorGradationQuickAdd(gradation, value, &col);
}
Color colorGradationGet(ColorGradation* gradation, double value)

View file

@ -8,6 +8,8 @@
extern "C" {
#endif
void colorInit();
void colorSave(FILE* f, Color* col);
void colorLoad(FILE* f, Color* col);
unsigned int colorTo32BitRGBA(Color* col);
@ -21,8 +23,13 @@ double colorGetValue(Color* col);
ColorGradation colorGradationCreate();
void colorGradationSave(FILE* f, ColorGradation* gradation);
void colorGradationLoad(FILE* f, ColorGradation* gradation);
void colorGradationAdd(ColorGradation* gradation, double value, Color* col);
void colorGradationAddRgba(ColorGradation* gradation, double value, double r, double g, double b, double a);
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 colorGradationQuickAdd(ColorGradation* gradation, double value, Color* col);
void colorGradationQuickAddRgba(ColorGradation* gradation, double value, double r, double g, double b, double a);
Color colorGradationGet(ColorGradation* gradation, double value);
#ifdef __cplusplus

View file

@ -8,6 +8,7 @@
#include "shared/constants.h"
#include "auto.h"
#include "color.h"
#include "system.h"
#include "camera.h"
#include "scenery.h"
@ -21,6 +22,7 @@ void paysagesInit()
ilInit();
iluInit();
colorInit();
sceneryInit();
renderInit();

View file

@ -80,10 +80,10 @@ void skyValidateDefinition(SkyDefinition* definition)
haze = colorGradationGet(&definition->haze_color, definition->daytime);
definition->_sky_gradation = colorGradationCreate();
colorGradationAdd(&definition->_sky_gradation, 0.0, &haze);
colorGradationAdd(&definition->_sky_gradation, definition->haze_height - definition->haze_smoothing, &haze);
colorGradationAdd(&definition->_sky_gradation, definition->haze_height, &zenith);
colorGradationAdd(&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)