cloud_types: Added cumulo-nimbus model

This commit is contained in:
Michaël Lemaire 2014-03-18 21:27:35 +01:00
parent eea639a7fb
commit 1158aa248b
4 changed files with 112 additions and 11 deletions

View file

@ -11,6 +11,7 @@
#include "clouds/BaseCloudsModel.h"
#include "clouds/CloudModelAltoCumulus.h"
#include "clouds/CloudModelCirrus.h"
#include "clouds/CloudModelCumuloNimbus.h"
#include "clouds/CloudModelStratoCumulus.h"
CloudsRenderer::CloudsRenderer(SoftwareRenderer* parent):
@ -62,26 +63,26 @@ void CloudsRenderer::update()
BaseCloudsModel* model;
switch (layer->type)
{
case CloudLayerDefinition::STRATUS:
case CloudLayerDefinition::NIMBOSTRATUS:
case CloudLayerDefinition::CUMULUS:
model = new BaseCloudsModel(layer);
break;
case CloudLayerDefinition::STRATOCUMULUS:
model = new CloudModelStratoCumulus(layer);
break;
case CloudLayerDefinition::ALTOCUMULUS:
model = new CloudModelAltoCumulus(layer);
break;
case CloudLayerDefinition::ALTOSTRATUS:
case CloudLayerDefinition::CIRRUS:
model = new CloudModelCirrus(layer);
break;
case CloudLayerDefinition::CUMULONIMBUS:
model = new CloudModelCumuloNimbus(layer);
break;
case CloudLayerDefinition::STRATUS:
case CloudLayerDefinition::NIMBOSTRATUS:
case CloudLayerDefinition::CUMULUS:
case CloudLayerDefinition::ALTOSTRATUS:
case CloudLayerDefinition::CIRROCUMULUS:
case CloudLayerDefinition::CIRROSTRATUS:
model = new BaseCloudsModel(layer);
break;
case CloudLayerDefinition::CIRRUS:
model = new CloudModelCirrus(layer);
break;
}
layer_models.push_back(model);

View file

@ -0,0 +1,69 @@
#include "CloudModelCumuloNimbus.h"
#include "NoiseGenerator.h"
#include "Vector3.h"
#include "CloudLayerDefinition.h"
CloudModelCumuloNimbus::CloudModelCumuloNimbus(CloudLayerDefinition* layer):
BaseCloudsModel(layer)
{
noise = new NoiseGenerator();
}
CloudModelCumuloNimbus::~CloudModelCumuloNimbus()
{
delete noise;
}
void CloudModelCumuloNimbus::update()
{
noise->clearLevels();
noise->addLevelSimple(8.0, -1.0, 1.0);
noise->addLevelSimple(7.0 / 2.0, -0.6, 0.6);
noise->addLevelSimple(6.0 / 4.0, -0.3, 0.3);
noise->addLevelSimple(5.0 / 10.0, -0.15, 0.15);
/*noise->addLevelSimple(1.0 / 20.0, -0.09, 0.09);
noise->addLevelSimple(1.0 / 40.0, -0.06, 0.06);
noise->addLevelSimple(1.0 / 60.0, -0.03, 0.03);*/
noise->addLevelSimple(1.0 / 80.0, -0.015, 0.015);
noise->addLevelSimple(1.0 / 100.0, -0.06, 0.06);
noise->addLevelSimple(1.0 / 150.0, -0.015, 0.015);
noise->addLevelSimple(1.0 / 200.0, -0.009, 0.009);
noise->addLevelSimple(1.0 / 400.0, -0.024, 0.024);
noise->addLevelSimple(1.0 / 800.0, -0.003, 0.003);
noise->addLevelSimple(1.0 / 1000.0, -0.0015, 0.0015);
noise->normalizeAmplitude(-3.0, 4.0, 0);
noise->setState(layer->getNoiseState());
}
void CloudModelCumuloNimbus::getAltitudeRange(double *min_altitude, double *max_altitude) const
{
*min_altitude = 5.0 + 10.0 * layer->altitude;
*max_altitude = *min_altitude + 50.0 + 50.0 * layer->scaling;
}
double CloudModelCumuloNimbus::getDensity(const Vector3 &location) const
{
double val;
double min_altitude, max_altitude;
double noise_scaling = 60.0 * layer->scaling;
getAltitudeRange(&min_altitude, &max_altitude);
if (location.y < min_altitude || location.y > max_altitude)
{
return 0.0;
}
else
{
double x = 1.5 * location.x / noise_scaling;
double y = (location.y - min_altitude) / noise_scaling;
double z = 1.5 * location.z / noise_scaling;
//double coverage = layer->coverage * layer->_coverage_by_altitude->getValue((position.y - layer->altitude) / layer->scaling);
double coverage = layer->coverage;
val = 0.5 * noise->get3DTotal(x, y, z);
return val - 1.0 + coverage;
}
}

View file

@ -0,0 +1,29 @@
#ifndef CLOUDMODELCUMULONIMBUS_H
#define CLOUDMODELCUMULONIMBUS_H
#include "../software_global.h"
#include "BaseCloudsModel.h"
namespace paysages {
namespace software {
class CloudModelCumuloNimbus : public BaseCloudsModel
{
public:
CloudModelCumuloNimbus(CloudLayerDefinition* layer);
virtual ~CloudModelCumuloNimbus();
virtual void update() override;
virtual void getAltitudeRange(double *min_altitude, double *max_altitude) const override;
virtual double getDensity(const Vector3 &location) const override;
private:
NoiseGenerator* noise;
};
}
}
#endif // CLOUDMODELCUMULONIMBUS_H

View file

@ -39,7 +39,8 @@ SOURCES += SoftwareRenderer.cpp \
NightSky.cpp \
TerrainRayWalker.cpp \
clouds/CloudModelAltoCumulus.cpp \
clouds/CloudModelCirrus.cpp
clouds/CloudModelCirrus.cpp \
clouds/CloudModelCumuloNimbus.cpp
HEADERS += SoftwareRenderer.h\
software_global.h \
@ -68,7 +69,8 @@ HEADERS += SoftwareRenderer.h\
NightSky.h \
TerrainRayWalker.h \
clouds/CloudModelAltoCumulus.h \
clouds/CloudModelCirrus.h
clouds/CloudModelCirrus.h \
clouds/CloudModelCumuloNimbus.h
unix:!symbian {
maemo5 {