2012-01-26 23:08:09 +00:00
|
|
|
#include "formatmosphere.h"
|
|
|
|
|
2012-02-12 17:26:17 +00:00
|
|
|
#include "tools.h"
|
2012-01-26 23:08:09 +00:00
|
|
|
#include "../lib_paysages/atmosphere.h"
|
|
|
|
#include "../lib_paysages/scenery.h"
|
2012-02-12 17:26:17 +00:00
|
|
|
#include "../lib_paysages/euclid.h"
|
|
|
|
#include "../lib_paysages/color.h"
|
2012-01-26 23:08:09 +00:00
|
|
|
|
|
|
|
static AtmosphereDefinition _definition;
|
|
|
|
|
|
|
|
/**************** Previews ****************/
|
2012-02-21 13:41:02 +00:00
|
|
|
class PreviewAtmosphereColor:public BasePreview
|
2012-02-12 17:26:17 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
PreviewAtmosphereColor(QWidget* parent):
|
2012-02-21 13:41:02 +00:00
|
|
|
BasePreview(parent)
|
2012-02-12 17:26:17 +00:00
|
|
|
{
|
|
|
|
_renderer = rendererCreate();
|
|
|
|
_preview_definition = atmosphereCreateDefinition();
|
2012-04-12 20:02:31 +00:00
|
|
|
|
|
|
|
configScaling(100.0, 1000.0, 20.0, 200.0);
|
2012-02-12 17:26:17 +00:00
|
|
|
}
|
|
|
|
protected:
|
2012-06-15 09:31:11 +00:00
|
|
|
QColor getColor(float x, float y)
|
2012-02-12 17:26:17 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
};
|
2012-01-26 23:08:09 +00:00
|
|
|
|
|
|
|
/**************** Form ****************/
|
|
|
|
FormAtmosphere::FormAtmosphere(QWidget *parent):
|
|
|
|
BaseForm(parent)
|
|
|
|
{
|
|
|
|
_definition = atmosphereCreateDefinition();
|
|
|
|
|
2012-02-12 17:26:17 +00:00
|
|
|
previewColor = new PreviewAtmosphereColor(this);
|
2012-02-28 13:45:11 +00:00
|
|
|
addPreview(previewColor, QString(tr("Color preview")));
|
2012-01-26 23:08:09 +00:00
|
|
|
|
2012-02-28 13:45:11 +00:00
|
|
|
addInputDouble(tr("Start distance"), &_definition.distance_near, -500.0, 500.0, 5.0, 50.0);
|
|
|
|
addInputDouble(tr("End distance"), &_definition.distance_far, -500.0, 500.0, 5.0, 50.0);
|
|
|
|
addInputDouble(tr("Masking power"), &_definition.full_mask, 0.0, 1.0, 0.01, 0.1);
|
|
|
|
addInputBoolean(tr("Lock color on haze"), &_definition.auto_lock_on_haze);
|
|
|
|
addInputColor(tr("Color"), &_definition.color);
|
2012-01-26 23:08:09 +00:00
|
|
|
|
|
|
|
revertConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormAtmosphere::revertConfig()
|
|
|
|
{
|
|
|
|
sceneryGetAtmosphere(&_definition);
|
|
|
|
BaseForm::revertConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormAtmosphere::applyConfig()
|
|
|
|
{
|
|
|
|
scenerySetAtmosphere(&_definition);
|
|
|
|
BaseForm::applyConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormAtmosphere::configChangeEvent()
|
|
|
|
{
|
|
|
|
atmosphereValidateDefinition(&_definition);
|
|
|
|
BaseForm::configChangeEvent();
|
|
|
|
}
|