Refactored atmosphere previews

This commit is contained in:
Michaël Lemaire 2013-11-20 11:27:21 +01:00 committed by Michael Lemaire
parent ee78af05d5
commit ee094d9b18
3 changed files with 21 additions and 27 deletions

View file

@ -14,27 +14,6 @@
static AtmosphereDefinition* _definition;
/**************** Previews ****************/
class PreviewSkyRenderer:public AtmosphereColorPreviewRenderer
{
public:
PreviewSkyRenderer(double heading):
AtmosphereColorPreviewRenderer(heading)
{
}
void bindEvent(BasePreview* preview) override
{
preview->configHdrToneMapping(true);
preview->configScaling(0.5, 5.0, 0.5, 2.5);
}
void updateEvent() override
{
getScenery()->setAtmosphere(_definition);
prepare();
}
};
/**************** Form ****************/
FormAtmosphere::FormAtmosphere(QWidget *parent):
BaseForm(parent)
@ -48,12 +27,12 @@ FormAtmosphere::FormAtmosphere(QWidget *parent):
_definition = new AtmosphereDefinition(NULL);
previewWest = new BasePreview(this);
previewWestRenderer = new PreviewSkyRenderer(M_PI / 2.0);
previewWestRenderer = new AtmosphereColorPreviewRenderer(_definition, M_PI / 2.0);
previewWest->setRenderer(previewWestRenderer);
addPreview(previewWest, QString(tr("West preview")));
previewEast = new BasePreview(this);
previewEastRenderer = new PreviewSkyRenderer(-M_PI / 2.0);
previewEastRenderer = new AtmosphereColorPreviewRenderer(_definition, -M_PI / 2.0);
previewEast->setRenderer(previewEastRenderer);
addPreview(previewEast, QString(tr("East preview")));

View file

@ -6,6 +6,7 @@
#include "tools/lighting.h"
#include "SurfaceMaterial.h"
#include "Scenery.h"
#include "BasePreview.h"
/*
* Atmosphere previews.
@ -146,12 +147,23 @@ static inline int _checkHit(Vector3 eye, Vector3 direction, Vector3* hit, Vector
return _checkHitGround(eye, direction, hit);
}
AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer(double heading):
heading(heading)
AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer(AtmosphereDefinition* definition, double heading):
definition(definition), heading(heading)
{
getScenery()->getCamera()->setLocation(Vector3(0.0, 7.0, 0.0));
}
void AtmosphereColorPreviewRenderer::bindEvent(BasePreview* preview)
{
preview->configHdrToneMapping(true);
preview->configScaling(0.5, 5.0, 0.5, 2.5);
}
void AtmosphereColorPreviewRenderer::updateEvent()
{
getScenery()->setAtmosphere(definition);
prepare();
}
Color AtmosphereColorPreviewRenderer::getColor2D(double x, double y, double)
{
Vector3 eye = {0.0, 7.0, 0.0};

View file

@ -9,11 +9,14 @@ namespace preview {
class AtmosphereColorPreviewRenderer:public Base2dPreviewRenderer
{
public:
AtmosphereColorPreviewRenderer(double heading);
AtmosphereColorPreviewRenderer(AtmosphereDefinition* definition, double heading);
void bindEvent(BasePreview* preview) override;
void updateEvent() override;
virtual Color getColor2D(double x, double y, double scaling) override;
protected:
private:
AtmosphereDefinition* definition;
double heading;
};