paysages3d/src/editing/formatmosphere.cpp

99 lines
2.8 KiB
C++
Raw Normal View History

#include "formatmosphere.h"
#include "tools.h"
#include <QColor>
#include <QSlider>
#include <cmath>
#include "atmosphere/public.h"
#include "AtmosphereColorPreviewRenderer.h"
#include "Scenery.h"
2013-11-12 22:15:35 +00:00
#include "BasePreview.h"
#include "renderer.h"
static AtmosphereDefinition* _definition;
/**************** Previews ****************/
2013-11-12 22:15:35 +00:00
class PreviewSkyEast:public AtmosphereColorPreviewRenderer
{
public:
void bindEvent(BasePreview* preview) override
{
preview->configHdrToneMapping(true);
preview->configScaling(0.5, 5.0, 0.5, 2.5);
}
2013-11-12 22:15:35 +00:00
void updateEvent() override
{
2013-11-12 22:15:35 +00:00
/*AtmosphereRendererClass.bind(renderer, _definition);
renderer->prepare();*/
}
};
2013-11-12 22:15:35 +00:00
class PreviewSkyWest:public AtmosphereColorPreviewRenderer
{
public:
void bindEvent(BasePreview* preview) override
{
preview->configHdrToneMapping(true);
preview->configScaling(0.5, 5.0, 0.5, 2.5);
}
2013-11-12 22:15:35 +00:00
void updateEvent() override
{
2013-11-12 22:15:35 +00:00
/*AtmosphereRendererClass.bind(renderer, _definition);
renderer->prepare();*/
}
};
/**************** Form ****************/
FormAtmosphere::FormAtmosphere(QWidget *parent):
BaseForm(parent)
{
addAutoPreset(tr("Clear day"));
addAutoPreset(tr("Clear sunset"));
addAutoPreset(tr("Hazy morning"));
addAutoPreset(tr("Foggy"));
addAutoPreset(tr("Stormy"));
_definition = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
previewWest = new BasePreview(this);
addPreview(previewWest, QString(tr("West preview")));
previewEast = new BasePreview(this);
addPreview(previewEast, QString(tr("East preview")));
//addInputEnum(tr("Color model"), (int*)&_definition->model, QStringList(tr("Simplified model (with weather)")) << tr("Complex model"));
addInputInt(tr("Day time (hour)"), &_definition->hour, 0, 23, 1, 10);
addInputInt(tr("Day time (minute)"), &_definition->minute, 0, 59, 1, 10);
//addInputColor(tr("Sun color"), &_definition->sun_color);
addInputDouble(tr("Sun radius"), &_definition->sun_radius, 0.0, 5.0, 0.05, 0.5);
//addInputDouble(tr("Influence of skydome on lighting"), &_definition->dome_lighting, 0.0, 2.0, 0.01, 0.1);
addInputDouble(tr("Humidity"), &_definition->humidity, 0.0, 1.0, 0.01, 0.1);
revertConfig();
}
void FormAtmosphere::revertConfig()
{
sceneryGetAtmosphere(_definition);
BaseForm::revertConfig();
}
void FormAtmosphere::applyConfig()
{
scenerySetAtmosphere(_definition);
BaseForm::applyConfig();
}
void FormAtmosphere::configChangeEvent()
{
AtmosphereDefinitionClass.validate(_definition);
BaseForm::configChangeEvent();
}
void FormAtmosphere::autoPresetSelected(int preset)
{
atmosphereAutoPreset(_definition, (AtmospherePreset)preset);
BaseForm::autoPresetSelected(preset);
}