Refactored AtmosphereDefinition
This commit is contained in:
parent
1cccae90be
commit
4f9e24b87d
20 changed files with 231 additions and 243 deletions
122
src/definition/AtmosphereDefinition.cpp
Normal file
122
src/definition/AtmosphereDefinition.cpp
Normal file
|
@ -0,0 +1,122 @@
|
|||
#include "AtmosphereDefinition.h"
|
||||
|
||||
#include "PackStream.h"
|
||||
|
||||
AtmosphereDefinition::AtmosphereDefinition(BaseDefinition* parent):
|
||||
BaseDefinition(parent)
|
||||
{
|
||||
}
|
||||
|
||||
AtmosphereDefinition::~AtmosphereDefinition()
|
||||
{
|
||||
}
|
||||
|
||||
void AtmosphereDefinition::save(PackStream* stream) const
|
||||
{
|
||||
stream->write((int*)&model);
|
||||
stream->write(&hour);
|
||||
stream->write(&minute);
|
||||
sun_color.save(stream);
|
||||
stream->write(&sun_radius);
|
||||
stream->write(&dome_lighting);
|
||||
stream->write(&humidity);
|
||||
}
|
||||
|
||||
void AtmosphereDefinition::load(PackStream* stream)
|
||||
{
|
||||
stream->read((int*)&model);
|
||||
stream->read(&hour);
|
||||
stream->read(&minute);
|
||||
sun_color.load(stream);
|
||||
stream->read(&sun_radius);
|
||||
stream->read(&dome_lighting);
|
||||
stream->read(&humidity);
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
void AtmosphereDefinition::copy(BaseDefinition* _destination) const
|
||||
{
|
||||
AtmosphereDefinition* destination = (AtmosphereDefinition*)_destination;
|
||||
|
||||
destination->model = model;
|
||||
destination->hour = hour;
|
||||
destination->minute = minute;
|
||||
destination->sun_color = sun_color;
|
||||
destination->sun_radius = sun_radius;
|
||||
destination->dome_lighting = dome_lighting;
|
||||
destination->humidity = humidity;
|
||||
|
||||
destination->validate();
|
||||
}
|
||||
|
||||
void AtmosphereDefinition::validate()
|
||||
{
|
||||
if (hour < 0)
|
||||
{
|
||||
hour = 0;
|
||||
}
|
||||
if (hour > 23)
|
||||
{
|
||||
hour = 23;
|
||||
}
|
||||
if (minute < 0)
|
||||
{
|
||||
minute = 0;
|
||||
}
|
||||
if (minute > 59)
|
||||
{
|
||||
minute = 59;
|
||||
}
|
||||
|
||||
_daytime = (double)hour / 24.0 + (double)minute / 1440.0;
|
||||
}
|
||||
|
||||
void AtmosphereDefinition::applyPreset(AtmospherePreset preset)
|
||||
{
|
||||
sun_color.r = 1.0;
|
||||
sun_color.g = 0.95;
|
||||
sun_color.b = 0.9;
|
||||
sun_color.a = 1.0;
|
||||
sun_radius = 1.0;
|
||||
humidity = 0.1;
|
||||
|
||||
model = ATMOSPHERE_MODEL_BRUNETON;
|
||||
|
||||
switch (preset)
|
||||
{
|
||||
case ATMOSPHERE_PRESET_CLEAR_DAY:
|
||||
hour = 15;
|
||||
minute = 0;
|
||||
dome_lighting = 0.2;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_CLEAR_SUNSET:
|
||||
hour = 17;
|
||||
minute = 45;
|
||||
dome_lighting = 0.3;
|
||||
sun_radius = 0.03;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_HAZY_MORNING:
|
||||
hour = 8;
|
||||
minute = 30;
|
||||
dome_lighting = 0.25;
|
||||
humidity = 0.4;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_FOGGY:
|
||||
hour = 15;
|
||||
minute = 0;
|
||||
dome_lighting = 0.1;
|
||||
humidity = 0.7;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_STORMY:
|
||||
hour = 15;
|
||||
minute = 0;
|
||||
dome_lighting = 0.05;
|
||||
humidity = 0.9;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
validate();
|
||||
}
|
56
src/definition/AtmosphereDefinition.h
Normal file
56
src/definition/AtmosphereDefinition.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
#ifndef ATMOSPHEREDEFINITION_H
|
||||
#define ATMOSPHEREDEFINITION_H
|
||||
|
||||
#include "definition_global.h"
|
||||
|
||||
#include "BaseDefinition.h"
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace definition {
|
||||
|
||||
class AtmosphereDefinition : public BaseDefinition
|
||||
{
|
||||
public:
|
||||
typedef enum
|
||||
{
|
||||
ATMOSPHERE_MODEL_BRUNETON = 0
|
||||
} AtmosphereModel;
|
||||
typedef enum
|
||||
{
|
||||
ATMOSPHERE_PRESET_CLEAR_DAY = 0,
|
||||
ATMOSPHERE_PRESET_CLEAR_SUNSET = 1,
|
||||
ATMOSPHERE_PRESET_HAZY_MORNING = 2,
|
||||
ATMOSPHERE_PRESET_FOGGY = 3,
|
||||
ATMOSPHERE_PRESET_STORMY = 4
|
||||
} AtmospherePreset;
|
||||
|
||||
public:
|
||||
AtmosphereDefinition(BaseDefinition* parent);
|
||||
virtual ~AtmosphereDefinition();
|
||||
|
||||
virtual void save(PackStream* stream) const override;
|
||||
virtual void load(PackStream* stream) override;
|
||||
|
||||
virtual void copy(BaseDefinition* destination) const override;
|
||||
virtual void validate() override;
|
||||
|
||||
void applyPreset(AtmospherePreset preset);
|
||||
|
||||
public:
|
||||
AtmosphereModel model;
|
||||
int hour;
|
||||
int minute;
|
||||
double humidity;
|
||||
Color sun_color;
|
||||
double sun_radius;
|
||||
double dome_lighting;
|
||||
|
||||
double _daytime;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ATMOSPHEREDEFINITION_H
|
|
@ -29,23 +29,23 @@ void BaseDefinition::setName(QString name)
|
|||
this->name = name;
|
||||
}
|
||||
|
||||
void BaseDefinition::save(PackStream* pack) const
|
||||
void BaseDefinition::save(PackStream* stream) const
|
||||
{
|
||||
pack->write(name);
|
||||
stream->write(name);
|
||||
QListIterator<BaseDefinition*> it(children);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next()->save(pack);
|
||||
it.next()->save(stream);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseDefinition::load(PackStream* pack)
|
||||
void BaseDefinition::load(PackStream* stream)
|
||||
{
|
||||
name = pack->readString();
|
||||
name = stream->readString();
|
||||
QListIterator<BaseDefinition*> it(children);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next()->load(pack);
|
||||
it.next()->load(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ public:
|
|||
BaseDefinition(BaseDefinition* parent);
|
||||
virtual ~BaseDefinition();
|
||||
|
||||
virtual void save(PackStream* pack) const;
|
||||
virtual void load(PackStream* pack);
|
||||
virtual void save(PackStream* stream) const;
|
||||
virtual void load(PackStream* stream);
|
||||
|
||||
virtual void copy(BaseDefinition* destination) const;
|
||||
virtual void validate();
|
||||
|
|
|
@ -21,7 +21,8 @@ SOURCES += \
|
|||
SurfaceMaterial.cpp \
|
||||
CameraDefinition.cpp \
|
||||
CloudsDefinition.cpp \
|
||||
CloudLayerDefinition.cpp
|
||||
CloudLayerDefinition.cpp \
|
||||
AtmosphereDefinition.cpp
|
||||
|
||||
HEADERS +=\
|
||||
definition_global.h \
|
||||
|
@ -32,7 +33,8 @@ HEADERS +=\
|
|||
SurfaceMaterial.h \
|
||||
CameraDefinition.h \
|
||||
CloudsDefinition.h \
|
||||
CloudLayerDefinition.h
|
||||
CloudLayerDefinition.h \
|
||||
AtmosphereDefinition.h
|
||||
|
||||
unix:!symbian {
|
||||
maemo5 {
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace definition {
|
|||
class Layers;
|
||||
class CloudsDefinition;
|
||||
class CloudLayerDefinition;
|
||||
class AtmosphereDefinition;
|
||||
}
|
||||
}
|
||||
using namespace paysages::definition;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#include "main.h"
|
||||
#include "render.h"
|
||||
#include "renderer.h"
|
||||
#include "atmosphere/public.h"
|
||||
#include "CameraDefinition.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
#include "SoftwareRenderer.h"
|
||||
#include "Scenery.h"
|
||||
|
||||
|
@ -170,7 +170,7 @@ int main(int argc, char** argv)
|
|||
AtmosphereDefinition* atmo = Scenery::getCurrent()->getAtmosphere();
|
||||
atmo->hour = (int)floor(conf_daytime_start * 24.0);
|
||||
atmo->minute = (int)floor(fmod(conf_daytime_start, 1.0 / 24.0) * 24.0 * 60.0);
|
||||
AtmosphereDefinitionClass.validate(atmo);
|
||||
atmo->validate();
|
||||
|
||||
CameraDefinition* camera = Scenery::getCurrent()->getCamera();
|
||||
Vector3 step = {conf_camera_step_x, conf_camera_step_y, conf_camera_step_z};
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
#include <QSlider>
|
||||
#include <cmath>
|
||||
|
||||
#include "atmosphere/public.h"
|
||||
#include "AtmosphereColorPreviewRenderer.h"
|
||||
#include "Scenery.h"
|
||||
#include "BasePreview.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
#include "renderer.h"
|
||||
|
||||
static AtmosphereDefinition* _definition;
|
||||
|
@ -45,7 +45,7 @@ FormAtmosphere::FormAtmosphere(QWidget *parent):
|
|||
addAutoPreset(tr("Foggy"));
|
||||
addAutoPreset(tr("Stormy"));
|
||||
|
||||
_definition = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
|
||||
_definition = new AtmosphereDefinition(NULL);
|
||||
|
||||
previewWest = new BasePreview(this);
|
||||
previewWestRenderer = new PreviewSkyRenderer(M_PI / 2.0);
|
||||
|
@ -90,12 +90,12 @@ void FormAtmosphere::applyConfig()
|
|||
|
||||
void FormAtmosphere::configChangeEvent()
|
||||
{
|
||||
AtmosphereDefinitionClass.validate(_definition);
|
||||
_definition->validate();
|
||||
BaseForm::configChangeEvent();
|
||||
}
|
||||
|
||||
void FormAtmosphere::autoPresetSelected(int preset)
|
||||
{
|
||||
atmosphereAutoPreset(_definition, (AtmospherePreset)preset);
|
||||
_definition->applyPreset((AtmosphereDefinition::AtmospherePreset)preset);
|
||||
BaseForm::autoPresetSelected(preset);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <cmath>
|
||||
#include "SoftwareRenderer.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
#include "Scenery.h"
|
||||
|
||||
// TEMP
|
||||
|
@ -130,7 +131,7 @@ AtmosphereResult SoftwareBrunetonAtmosphereRenderer::applyAerialPerspective(Vect
|
|||
/* Get base perspective */
|
||||
switch (definition->model)
|
||||
{
|
||||
case ATMOSPHERE_MODEL_BRUNETON:
|
||||
case AtmosphereDefinition::ATMOSPHERE_MODEL_BRUNETON:
|
||||
result = brunetonApplyAerialPerspective(renderer, location, base);
|
||||
break;
|
||||
default:
|
||||
|
@ -189,7 +190,7 @@ AtmosphereResult SoftwareBrunetonAtmosphereRenderer::getSkyColor(Vector3 directi
|
|||
Vector3 location = v3Add(camera_location, v3Scale(direction, 6421.0));
|
||||
switch (definition->model)
|
||||
{
|
||||
case ATMOSPHERE_MODEL_BRUNETON:
|
||||
case AtmosphereDefinition::ATMOSPHERE_MODEL_BRUNETON:
|
||||
result = brunetonGetSkyColor(renderer, camera_location, direction, sun_position, base);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "Scenery.h"
|
||||
#include "FluidMediumManager.h"
|
||||
#include "AtmosphereRenderer.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
|
||||
|
||||
// Legacy compatibility
|
||||
|
@ -63,7 +64,7 @@ void SoftwareRenderer::prepare()
|
|||
atmosphere_renderer = new SoftwareBrunetonAtmosphereRenderer(this);
|
||||
|
||||
// Setup transitional renderers (for C-legacy subsystems)
|
||||
AtmosphereDefinitionClass.copy(scenery->getAtmosphere(), atmosphere->definition);
|
||||
scenery->getAtmosphere()->copy(atmosphere->definition);
|
||||
atmosphere->applyAerialPerspective = _legacyApplyAerialPerspective;
|
||||
atmosphere->getSkyColor = _legacyGetSkyColor;
|
||||
atmosphere->getLightingStatus = _legacyGetLightingStatus;
|
||||
|
|
|
@ -9,17 +9,17 @@
|
|||
#include "CloudsDefinition.h"
|
||||
#include "terrain/public.h"
|
||||
#include "textures/public.h"
|
||||
#include "water/public.h"
|
||||
#include "renderer.h"
|
||||
#include "terrain/ter_raster.h"
|
||||
#include "WaterDefinition.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
|
||||
static Scenery _main_scenery;
|
||||
|
||||
Scenery::Scenery():
|
||||
BaseDefinition(NULL)
|
||||
{
|
||||
atmosphere = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
|
||||
atmosphere = new AtmosphereDefinition(this);
|
||||
camera = new CameraDefinition;
|
||||
clouds = new CloudsDefinition(this);
|
||||
terrain = (TerrainDefinition*)TerrainDefinitionClass.create();
|
||||
|
@ -27,6 +27,7 @@ Scenery::Scenery():
|
|||
water = new WaterDefinition(this);
|
||||
|
||||
addChild(camera);
|
||||
addChild(atmosphere);
|
||||
addChild(water);
|
||||
addChild(clouds);
|
||||
|
||||
|
@ -37,7 +38,6 @@ Scenery::Scenery():
|
|||
|
||||
Scenery::~Scenery()
|
||||
{
|
||||
AtmosphereDefinitionClass.destroy(atmosphere);
|
||||
TerrainDefinitionClass.destroy(terrain);
|
||||
TexturesDefinitionClass.destroy(textures);
|
||||
}
|
||||
|
@ -60,7 +60,6 @@ void Scenery::save(PackStream* stream) const
|
|||
|
||||
noiseSave(stream);
|
||||
|
||||
AtmosphereDefinitionClass.save(stream, atmosphere);
|
||||
TerrainDefinitionClass.save(stream, terrain);
|
||||
TexturesDefinitionClass.save(stream, textures);
|
||||
|
||||
|
@ -76,7 +75,6 @@ void Scenery::load(PackStream* stream)
|
|||
|
||||
noiseLoad(stream);
|
||||
|
||||
AtmosphereDefinitionClass.load(stream, atmosphere);
|
||||
TerrainDefinitionClass.load(stream, terrain);
|
||||
TexturesDefinitionClass.load(stream, textures);
|
||||
|
||||
|
@ -105,7 +103,7 @@ void Scenery::autoPreset(int seed)
|
|||
|
||||
terrainAutoPreset(terrain, TERRAIN_PRESET_STANDARD);
|
||||
texturesAutoPreset(textures, TEXTURES_PRESET_FULL);
|
||||
atmosphereAutoPreset(atmosphere, ATMOSPHERE_PRESET_CLEAR_DAY);
|
||||
atmosphere->applyPreset(AtmosphereDefinition::ATMOSPHERE_PRESET_CLEAR_DAY);
|
||||
water->applyPreset(WATER_PRESET_LAKE);
|
||||
clouds->applyPreset(CloudsDefinition::CLOUDS_PRESET_PARTLY_CLOUDY);
|
||||
|
||||
|
@ -117,12 +115,12 @@ void Scenery::autoPreset(int seed)
|
|||
|
||||
void Scenery::setAtmosphere(AtmosphereDefinition* atmosphere)
|
||||
{
|
||||
AtmosphereDefinitionClass.copy(atmosphere, this->atmosphere);
|
||||
atmosphere->copy(this->atmosphere);
|
||||
}
|
||||
|
||||
void Scenery::getAtmosphere(AtmosphereDefinition* atmosphere)
|
||||
{
|
||||
AtmosphereDefinitionClass.copy(this->atmosphere, atmosphere);
|
||||
this->atmosphere->copy(atmosphere);
|
||||
}
|
||||
|
||||
void Scenery::setCamera(CameraDefinition* camera)
|
||||
|
@ -180,6 +178,7 @@ void Scenery::getWater(WaterDefinition* water)
|
|||
|
||||
|
||||
#include "clouds/public.h"
|
||||
#include "water/public.h"
|
||||
|
||||
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int, int, int, int)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "BaseDefinition.h"
|
||||
|
||||
class AtmosphereDefinition;
|
||||
class TerrainDefinition;
|
||||
class TexturesDefinition;
|
||||
class Renderer;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <cstdlib>
|
||||
#include "System.h"
|
||||
#include "PackStream.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
#include "tools.h"
|
||||
#include "tools/cache.h"
|
||||
#include "tools/texture.h"
|
||||
|
@ -1043,7 +1044,7 @@ static void _saveDebug4D(Texture4D* tex, const char* tag, int order)
|
|||
}
|
||||
|
||||
/*********************** Public methods ***********************/
|
||||
void brunetonInit()
|
||||
int brunetonInit()
|
||||
{
|
||||
int x, y, z, w, order;
|
||||
ParallelWork* work;
|
||||
|
@ -1060,7 +1061,7 @@ void brunetonInit()
|
|||
&& _tryLoadCache2D(_irradianceTexture, "irradiance", 0)
|
||||
&& _tryLoadCache4D(_inscatterTexture, "inscatter", 0))
|
||||
{
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Texture2D* _deltaETexture = texture2DCreate(SKY_W, SKY_H);
|
||||
|
@ -1149,8 +1150,12 @@ void brunetonInit()
|
|||
texture4DDelete(_deltaSMTexture);
|
||||
texture4DDelete(_deltaSRTexture);
|
||||
texture4DDelete(_deltaJTexture);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const int _init = brunetonInit();
|
||||
|
||||
AtmosphereResult brunetonGetSkyColor(Renderer* renderer, Vector3 eye, Vector3 direction, Vector3 sun_position, Color base)
|
||||
{
|
||||
UNUSED(base);
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
#include "private.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include "PackStream.h"
|
||||
#include "../tools.h"
|
||||
#include "../renderer.h"
|
||||
|
||||
static int _inited = 0;
|
||||
|
||||
/******************** Definition ********************/
|
||||
static void _validateDefinition(AtmosphereDefinition* definition)
|
||||
{
|
||||
if (definition->hour < 0)
|
||||
{
|
||||
definition->hour = 0;
|
||||
}
|
||||
if (definition->hour > 23)
|
||||
{
|
||||
definition->hour = 23;
|
||||
}
|
||||
if (definition->minute < 0)
|
||||
{
|
||||
definition->minute = 0;
|
||||
}
|
||||
if (definition->minute > 59)
|
||||
{
|
||||
definition->minute = 59;
|
||||
}
|
||||
|
||||
definition->_daytime = (double)definition->hour / 24.0 + (double)definition->minute / 1440.0;
|
||||
}
|
||||
|
||||
static AtmosphereDefinition* _createDefinition()
|
||||
{
|
||||
AtmosphereDefinition* result;
|
||||
|
||||
/* TODO Find a better place for this */
|
||||
if (!_inited)
|
||||
{
|
||||
_inited = 1;
|
||||
brunetonInit();
|
||||
}
|
||||
|
||||
result = new AtmosphereDefinition;
|
||||
|
||||
atmosphereAutoPreset(result, ATMOSPHERE_PRESET_CLEAR_DAY);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void _deleteDefinition(AtmosphereDefinition* definition)
|
||||
{
|
||||
delete definition;
|
||||
}
|
||||
|
||||
static void _copyDefinition(AtmosphereDefinition* source, AtmosphereDefinition* destination)
|
||||
{
|
||||
destination->model = source->model;
|
||||
destination->hour = source->hour;
|
||||
destination->minute = source->minute;
|
||||
destination->sun_color = source->sun_color;
|
||||
destination->sun_radius = source->sun_radius;
|
||||
destination->dome_lighting = source->dome_lighting;
|
||||
destination->humidity = source->humidity;
|
||||
|
||||
_validateDefinition(destination);
|
||||
}
|
||||
|
||||
static void _saveDefinition(PackStream* stream, AtmosphereDefinition* definition)
|
||||
{
|
||||
stream->write((int*)&definition->model);
|
||||
stream->write(&definition->hour);
|
||||
stream->write(&definition->minute);
|
||||
colorSave(stream, &definition->sun_color);
|
||||
stream->write(&definition->sun_radius);
|
||||
stream->write(&definition->dome_lighting);
|
||||
stream->write(&definition->humidity);
|
||||
}
|
||||
|
||||
static void _loadDefinition(PackStream* stream, AtmosphereDefinition* definition)
|
||||
{
|
||||
stream->read((int*)&definition->model);
|
||||
stream->read(&definition->hour);
|
||||
stream->read(&definition->minute);
|
||||
colorLoad(stream, &definition->sun_color);
|
||||
stream->read(&definition->sun_radius);
|
||||
stream->read(&definition->dome_lighting);
|
||||
stream->read(&definition->humidity);
|
||||
|
||||
_validateDefinition(definition);
|
||||
}
|
||||
|
||||
StandardDefinition AtmosphereDefinitionClass = {
|
||||
(FuncObjectCreate)_createDefinition,
|
||||
(FuncObjectDelete)_deleteDefinition,
|
||||
(FuncObjectCopy)_copyDefinition,
|
||||
(FuncObjectValidate)_validateDefinition,
|
||||
(FuncObjectSave)_saveDefinition,
|
||||
(FuncObjectLoad)_loadDefinition
|
||||
};
|
|
@ -1,54 +0,0 @@
|
|||
#include "private.h"
|
||||
|
||||
/*
|
||||
* Atmosphere presets.
|
||||
*/
|
||||
|
||||
void atmosphereAutoPreset(AtmosphereDefinition* definition, AtmospherePreset preset)
|
||||
{
|
||||
definition->sun_color.r = 1.0;
|
||||
definition->sun_color.g = 0.95;
|
||||
definition->sun_color.b = 0.9;
|
||||
definition->sun_color.a = 1.0;
|
||||
definition->sun_radius = 1.0;
|
||||
definition->humidity = 0.1;
|
||||
|
||||
definition->model = ATMOSPHERE_MODEL_BRUNETON;
|
||||
|
||||
switch (preset)
|
||||
{
|
||||
case ATMOSPHERE_PRESET_CLEAR_DAY:
|
||||
definition->hour = 15;
|
||||
definition->minute = 0;
|
||||
definition->dome_lighting = 0.2;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_CLEAR_SUNSET:
|
||||
definition->hour = 17;
|
||||
definition->minute = 45;
|
||||
definition->dome_lighting = 0.3;
|
||||
definition->sun_radius = 0.03;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_HAZY_MORNING:
|
||||
definition->hour = 8;
|
||||
definition->minute = 30;
|
||||
definition->dome_lighting = 0.25;
|
||||
definition->humidity = 0.4;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_FOGGY:
|
||||
definition->hour = 15;
|
||||
definition->minute = 0;
|
||||
definition->dome_lighting = 0.1;
|
||||
definition->humidity = 0.7;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_STORMY:
|
||||
definition->hour = 15;
|
||||
definition->minute = 0;
|
||||
definition->dome_lighting = 0.05;
|
||||
definition->humidity = 0.9;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
AtmosphereDefinitionClass.validate(definition);
|
||||
}
|
|
@ -1,40 +1,32 @@
|
|||
#include "private.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "../tools.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "AtmosphereDefinition.h"
|
||||
#include "../renderer.h"
|
||||
|
||||
/******************** Fake ********************/
|
||||
static AtmosphereResult _fakeApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
|
||||
static AtmosphereResult _fakeApplyAerialPerspective(Renderer*, Vector3, Color base)
|
||||
{
|
||||
AtmosphereResult result;
|
||||
UNUSED(renderer);
|
||||
UNUSED(location);
|
||||
result.base = result.final = base;
|
||||
result.inscattering = result.attenuation = COLOR_BLACK;
|
||||
return result;
|
||||
}
|
||||
|
||||
static AtmosphereResult _fakeGetSkyColor(Renderer* renderer, Vector3 direction)
|
||||
static AtmosphereResult _fakeGetSkyColor(Renderer*, Vector3)
|
||||
{
|
||||
AtmosphereResult result;
|
||||
UNUSED(renderer);
|
||||
UNUSED(direction);
|
||||
result.base = result.final = COLOR_WHITE;
|
||||
result.inscattering = result.attenuation = COLOR_BLACK;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void _fakeGetLightingStatus(Renderer* renderer, LightStatus* status, Vector3 normal, int opaque)
|
||||
static void _fakeGetLightingStatus(Renderer*, LightStatus* status, Vector3, int)
|
||||
{
|
||||
LightDefinition light;
|
||||
|
||||
UNUSED(renderer);
|
||||
UNUSED(normal);
|
||||
UNUSED(opaque);
|
||||
|
||||
light.color.r = 1.0;
|
||||
light.color.g = 1.0;
|
||||
light.color.b = 1.0;
|
||||
|
@ -91,7 +83,7 @@ static AtmosphereRenderer* _createRenderer()
|
|||
AtmosphereRenderer* result;
|
||||
|
||||
result = new AtmosphereRenderer;
|
||||
result->definition = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
|
||||
result->definition = new AtmosphereDefinition(NULL);
|
||||
|
||||
result->getLightingStatus = _fakeGetLightingStatus;
|
||||
result->getSunDirection = _realGetSunDirection;
|
||||
|
@ -103,13 +95,13 @@ static AtmosphereRenderer* _createRenderer()
|
|||
|
||||
static void _deleteRenderer(AtmosphereRenderer* renderer)
|
||||
{
|
||||
AtmosphereDefinitionClass.destroy(renderer->definition);
|
||||
delete renderer->definition;
|
||||
delete renderer;
|
||||
}
|
||||
|
||||
static void _bindRenderer(Renderer* renderer, AtmosphereDefinition* definition)
|
||||
{
|
||||
AtmosphereDefinitionClass.copy(definition, renderer->atmosphere->definition);
|
||||
definition->copy(renderer->atmosphere->definition);
|
||||
}
|
||||
|
||||
StandardRenderer AtmosphereRendererClass = {
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#define SUN_RADIUS 6.955e5
|
||||
#define SUN_RADIUS_SCALED (SUN_RADIUS / WORLD_SCALING)
|
||||
|
||||
void brunetonInit();
|
||||
AtmosphereResult brunetonGetSkyColor(Renderer* renderer, Vector3 eye, Vector3 direction, Vector3 sun_position, Color base);
|
||||
AtmosphereResult brunetonApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base);
|
||||
void brunetonGetLightingStatus(Renderer* renderer, LightStatus* status, Vector3 normal, int opaque);
|
||||
|
|
|
@ -1,44 +1,14 @@
|
|||
#ifndef _PAYSAGES_ATMOSPHERE_PUBLIC_H_
|
||||
#define _PAYSAGES_ATMOSPHERE_PUBLIC_H_
|
||||
|
||||
#include "rendering_global.h"
|
||||
|
||||
#include "../rendering_global.h"
|
||||
#include "../tools/lighting.h"
|
||||
#include "../tools/euclid.h"
|
||||
#include "../tools/color.h"
|
||||
#include "../shared/types.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ATMOSPHERE_PRESET_CLEAR_DAY = 0,
|
||||
ATMOSPHERE_PRESET_CLEAR_SUNSET = 1,
|
||||
ATMOSPHERE_PRESET_HAZY_MORNING = 2,
|
||||
ATMOSPHERE_PRESET_FOGGY = 3,
|
||||
ATMOSPHERE_PRESET_STORMY = 4
|
||||
} AtmospherePreset;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ATMOSPHERE_MODEL_BRUNETON = 0
|
||||
} AtmosphereModel;
|
||||
|
||||
class AtmosphereDefinition
|
||||
{
|
||||
public:
|
||||
AtmosphereModel model;
|
||||
int hour;
|
||||
int minute;
|
||||
double humidity;
|
||||
Color sun_color;
|
||||
double sun_radius;
|
||||
double dome_lighting;
|
||||
|
||||
double _daytime;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Color base;
|
||||
|
@ -67,11 +37,8 @@ public:
|
|||
/*void* _internal_data;*/
|
||||
};
|
||||
|
||||
RENDERINGSHARED_EXPORT extern StandardDefinition AtmosphereDefinitionClass;
|
||||
RENDERINGSHARED_EXPORT extern StandardRenderer AtmosphereRendererClass;
|
||||
|
||||
RENDERINGSHARED_EXPORT void atmosphereAutoPreset(AtmosphereDefinition* definition, AtmospherePreset preset);
|
||||
|
||||
RENDERINGSHARED_EXPORT void atmosphereRenderSkydome(Renderer* renderer);
|
||||
|
||||
RENDERINGSHARED_EXPORT void atmosphereInitResult(AtmosphereResult* result);
|
||||
|
|
|
@ -16,8 +16,6 @@ SOURCES += main.cpp \
|
|||
geoarea.cpp \
|
||||
atmosphere/atm_render.cpp \
|
||||
atmosphere/atm_raster.cpp \
|
||||
atmosphere/atm_presets.cpp \
|
||||
atmosphere/atm_definition.cpp \
|
||||
atmosphere/atm_bruneton.cpp \
|
||||
clouds/clo_walking.cpp \
|
||||
clouds/clo_rendering.cpp \
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include "tools/color.h"
|
||||
#include "CameraDefinition.h"
|
||||
#include "SoftwareRenderer.h"
|
||||
#include "atmosphere/public.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
#include "AtmosphereRenderer.h"
|
||||
#include "Scenery.h"
|
||||
#include "System.h"
|
||||
|
||||
|
@ -46,7 +47,7 @@ TEST(Bruneton, AerialPerspective2)
|
|||
AtmosphereDefinition* atmo = Scenery::getCurrent()->getAtmosphere();
|
||||
atmo->hour = 6;
|
||||
atmo->minute = 30;
|
||||
AtmosphereDefinitionClass.validate(atmo);
|
||||
atmo->validate();
|
||||
|
||||
Renderer renderer;
|
||||
renderer.render_width = 800;
|
||||
|
|
Loading…
Reference in a new issue