paysages: Atmosphere form.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@266 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
8100fefad8
commit
2001e534d4
8 changed files with 150 additions and 13 deletions
1
TODO
1
TODO
|
@ -1,3 +1,4 @@
|
|||
- ColorGradation dialog.
|
||||
- All noises should use the same entropy pool (saved separately), and avoid reallocs.
|
||||
- Implement light multi-sampling (mainly for skydome).
|
||||
- Implement scaling and scrolling on previews.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "inputdouble.h"
|
||||
#include "inputint.h"
|
||||
#include "inputboolean.h"
|
||||
#include "inputcolor.h"
|
||||
#include "inputcolorgradation.h"
|
||||
#include "inputnoise.h"
|
||||
|
@ -192,6 +193,11 @@ void BaseForm::addInputDouble(QString label, double* value, double min, double m
|
|||
addInput(new InputDouble(form, label, value, min, max, small_step, large_step));
|
||||
}
|
||||
|
||||
void BaseForm::addInputBoolean(QString label, int* value)
|
||||
{
|
||||
addInput(new InputBoolean(form, label, value));
|
||||
}
|
||||
|
||||
void BaseForm::addInputColor(QString label, Color* value)
|
||||
{
|
||||
addInput(new InputColor(form, label, value));
|
||||
|
|
|
@ -37,6 +37,7 @@ protected:
|
|||
void addInput(BaseInput* input);
|
||||
void addInputInt(QString label, int* value, int min, int max, int small_step, int large_step);
|
||||
void addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step);
|
||||
void addInputBoolean(QString label, int* value);
|
||||
void addInputColor(QString label, Color* value);
|
||||
void addInputColorGradation(QString label, ColorGradation* value);
|
||||
void addInputNoise(QString label, NoiseGenerator* value);
|
||||
|
|
|
@ -1,11 +1,56 @@
|
|||
#include "formatmosphere.h"
|
||||
|
||||
#include "tools.h"
|
||||
#include "../lib_paysages/atmosphere.h"
|
||||
#include "../lib_paysages/scenery.h"
|
||||
#include "../lib_paysages/euclid.h"
|
||||
#include "../lib_paysages/color.h"
|
||||
|
||||
static AtmosphereDefinition _definition;
|
||||
|
||||
/**************** Previews ****************/
|
||||
class PreviewAtmosphereColor:public Preview
|
||||
{
|
||||
public:
|
||||
PreviewAtmosphereColor(QWidget* parent):
|
||||
Preview(parent)
|
||||
{
|
||||
_renderer = rendererCreate();
|
||||
_preview_definition = atmosphereCreateDefinition();
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
{
|
||||
Vector3 eye, look, location;
|
||||
|
||||
eye.x = 0.0;
|
||||
eye.y = scaling * 5.0;
|
||||
eye.z = -10.0 * scaling;
|
||||
_renderer.camera_location = eye;
|
||||
look.x = x * 0.01 / scaling;
|
||||
look.y = -y * 0.01 / scaling - 0.3;
|
||||
look.z = 1.0;
|
||||
look = v3Normalize(look);
|
||||
|
||||
if (look.y > -0.0001)
|
||||
{
|
||||
return colorToQColor(COLOR_BLUE);
|
||||
}
|
||||
|
||||
location.x = eye.x - look.x * eye.y / look.y;
|
||||
location.y = 0.0;
|
||||
location.z = eye.z - look.z * eye.y / look.y;
|
||||
|
||||
return colorToQColor(atmosphereApply(&_preview_definition, &_renderer, location, COLOR_BLACK));
|
||||
}
|
||||
void updateData()
|
||||
{
|
||||
atmosphereCopyDefinition(&_definition, &_preview_definition);
|
||||
}
|
||||
private:
|
||||
Renderer _renderer;
|
||||
AtmosphereDefinition _preview_definition;
|
||||
};
|
||||
|
||||
/**************** Form ****************/
|
||||
FormAtmosphere::FormAtmosphere(QWidget *parent):
|
||||
|
@ -13,14 +58,14 @@ FormAtmosphere::FormAtmosphere(QWidget *parent):
|
|||
{
|
||||
_definition = atmosphereCreateDefinition();
|
||||
|
||||
/*previewHeight = new PreviewTerrainHeight(this);
|
||||
previewColor = new PreviewTerrainColor(this);
|
||||
addPreview(previewHeight, QString("Height preview (normalized)"));
|
||||
addPreview(previewColor, QString("Textured preview (no shadow)"));*/
|
||||
previewColor = new PreviewAtmosphereColor(this);
|
||||
addPreview(previewColor, QString("Color preview"));
|
||||
|
||||
/*addInputNoise("Noise", _definition.height_noise);
|
||||
addInputDouble("Height", &_definition.height_factor, 0.0, 20.0, 0.1, 1.0);
|
||||
addInputDouble("Scaling", &_definition.scaling, 1.0, 20.0, 0.1, 1.0);*/
|
||||
addInputDouble("Start distance", &_definition.distance_near, -500.0, 500.0, 5.0, 50.0);
|
||||
addInputDouble("End distance", &_definition.distance_far, -500.0, 500.0, 5.0, 50.0);
|
||||
addInputDouble("Masking power", &_definition.full_mask, 0.0, 1.0, 0.01, 0.1);
|
||||
addInputBoolean("Lock color on haze", &_definition.auto_lock_on_haze);
|
||||
addInputColor("Color", &_definition.color);
|
||||
|
||||
revertConfig();
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
static SkyDefinition _definition;
|
||||
|
||||
/**************** Previews ****************/
|
||||
class PreviewEast:public Preview
|
||||
class PreviewSkyEast:public Preview
|
||||
{
|
||||
public:
|
||||
PreviewEast(QWidget* parent):
|
||||
PreviewSkyEast(QWidget* parent):
|
||||
Preview(parent)
|
||||
{
|
||||
_renderer = rendererCreate();
|
||||
|
@ -44,10 +44,10 @@ private:
|
|||
SkyDefinition _preview_definition;
|
||||
};
|
||||
|
||||
class PreviewWest:public Preview
|
||||
class PreviewSkyWest:public Preview
|
||||
{
|
||||
public:
|
||||
PreviewWest(QWidget* parent):
|
||||
PreviewSkyWest(QWidget* parent):
|
||||
Preview(parent)
|
||||
{
|
||||
_renderer = rendererCreate();
|
||||
|
@ -80,9 +80,9 @@ FormSky::FormSky(QWidget *parent):
|
|||
{
|
||||
_definition = skyCreateDefinition();
|
||||
|
||||
previewWest = new PreviewWest(this);
|
||||
previewWest = new PreviewSkyWest(this);
|
||||
addPreview(previewWest, QString("West preview"));
|
||||
previewEast = new PreviewEast(this);
|
||||
previewEast = new PreviewSkyEast(this);
|
||||
addPreview(previewEast, QString("East preview"));
|
||||
|
||||
addInputDouble("Day time", &_definition.daytime, 0.0, 1.0, 0.01, 0.1);
|
||||
|
|
58
gui_qt/inputboolean.cpp
Normal file
58
gui_qt/inputboolean.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "inputboolean.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include "math.h"
|
||||
|
||||
InputBoolean::InputBoolean(QWidget* form, QString label, int* value) : BaseInput(form, label)
|
||||
{
|
||||
this->value = value;
|
||||
|
||||
checkbox = new QCheckBox(form);
|
||||
|
||||
connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(applyValue()));
|
||||
|
||||
_preview = new QLabel(form);
|
||||
_control = checkbox;
|
||||
}
|
||||
|
||||
void InputBoolean::updatePreview()
|
||||
{
|
||||
if (checkbox->checkState() == Qt::Checked)
|
||||
{
|
||||
((QLabel*)_preview)->setText("Yes");
|
||||
}
|
||||
else
|
||||
{
|
||||
((QLabel*)_preview)->setText("No");
|
||||
}
|
||||
|
||||
BaseInput::updatePreview();
|
||||
}
|
||||
|
||||
void InputBoolean::applyValue()
|
||||
{
|
||||
if (checkbox->checkState() == Qt::Checked)
|
||||
{
|
||||
*value = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = 0;
|
||||
}
|
||||
|
||||
BaseInput::applyValue();
|
||||
}
|
||||
|
||||
void InputBoolean::revert()
|
||||
{
|
||||
if (*value)
|
||||
{
|
||||
checkbox->setCheckState(Qt::Checked);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkbox->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
|
||||
BaseInput::revert();
|
||||
}
|
25
gui_qt/inputboolean.h
Normal file
25
gui_qt/inputboolean.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef _PAYSAGES_QT_INPUTBOOLEAN_H_
|
||||
#define _PAYSAGES_QT_INPUTBOOLEAN_H_
|
||||
|
||||
#include <QWidget>
|
||||
#include <QCheckBox>
|
||||
#include "baseinput.h"
|
||||
|
||||
class InputBoolean:public BaseInput
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputBoolean(QWidget* form, QString label, int* value);
|
||||
|
||||
public slots:
|
||||
virtual void updatePreview();
|
||||
virtual void applyValue();
|
||||
virtual void revert();
|
||||
|
||||
private:
|
||||
QCheckBox* checkbox;
|
||||
int* value;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -2,6 +2,7 @@
|
|||
#define _PAYSAGES_COLOR_H_
|
||||
|
||||
#include "shared/types.h"
|
||||
#include "shared/constants.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
Loading…
Reference in a new issue