cloud_types: Added cirrus model

This commit is contained in:
Michaël Lemaire 2014-03-18 21:17:41 +01:00
parent 0ab61f8060
commit eea639a7fb
4 changed files with 99 additions and 3 deletions

View file

@ -10,6 +10,7 @@
#include "clouds/BaseCloudsModel.h" #include "clouds/BaseCloudsModel.h"
#include "clouds/CloudModelAltoCumulus.h" #include "clouds/CloudModelAltoCumulus.h"
#include "clouds/CloudModelCirrus.h"
#include "clouds/CloudModelStratoCumulus.h" #include "clouds/CloudModelStratoCumulus.h"
CloudsRenderer::CloudsRenderer(SoftwareRenderer* parent): CloudsRenderer::CloudsRenderer(SoftwareRenderer* parent):
@ -76,9 +77,11 @@ void CloudsRenderer::update()
case CloudLayerDefinition::CUMULONIMBUS: case CloudLayerDefinition::CUMULONIMBUS:
case CloudLayerDefinition::CIRROCUMULUS: case CloudLayerDefinition::CIRROCUMULUS:
case CloudLayerDefinition::CIRROSTRATUS: case CloudLayerDefinition::CIRROSTRATUS:
case CloudLayerDefinition::CIRRUS:
model = new BaseCloudsModel(layer); model = new BaseCloudsModel(layer);
break; break;
case CloudLayerDefinition::CIRRUS:
model = new CloudModelCirrus(layer);
break;
} }
layer_models.push_back(model); layer_models.push_back(model);

View file

@ -0,0 +1,62 @@
#include "CloudModelCirrus.h"
#include "NoiseGenerator.h"
#include "Vector3.h"
#include "CloudLayerDefinition.h"
CloudModelCirrus::CloudModelCirrus(CloudLayerDefinition* layer):
BaseCloudsModel(layer)
{
noise = new NoiseGenerator();
}
CloudModelCirrus::~CloudModelCirrus()
{
delete noise;
}
void CloudModelCirrus::update()
{
noise->clearLevels();
noise->addLevelSimple(1.0, -1.0, 1.0);
noise->addLevelSimple(1.0 / 6.0, -0.6, 0.6);
noise->addLevelSimple(1.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 / 120.0, -0.03, 0.03);
noise->addLevelSimple(1.0 / 300.0, -0.01, 0.01);
noise->normalizeAmplitude(-4.0, 3.0, 0);
noise->setState(layer->getNoiseState());
}
void CloudModelCirrus::getAltitudeRange(double *min_altitude, double *max_altitude) const
{
*min_altitude = 45.0 + 20.0 * layer->altitude;
*max_altitude = *min_altitude + 20.0 * layer->scaling;
}
double CloudModelCirrus::getDensity(const Vector3 &location) const
{
double val;
double min_altitude, max_altitude;
double noise_scaling = 30.0 * layer->scaling;
getAltitudeRange(&min_altitude, &max_altitude);
if (location.y < min_altitude || location.y > max_altitude)
{
return 0.0;
}
else
{
double x = 0.03 * location.x / noise_scaling;
double y = (location.y - min_altitude) / noise_scaling;
double z = 0.03 * 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.6 * noise->get3DTotal(x, y, z);
return val - 1.1 + coverage;
}
}

View file

@ -0,0 +1,29 @@
#ifndef CLOUDMODELCIRRUS_H
#define CLOUDMODELCIRRUS_H
#include "../software_global.h"
#include "BaseCloudsModel.h"
namespace paysages {
namespace software {
class CloudModelCirrus : public BaseCloudsModel
{
public:
CloudModelCirrus(CloudLayerDefinition* layer);
virtual ~CloudModelCirrus();
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 // CLOUDMODELCIRRUS_H

View file

@ -38,7 +38,8 @@ SOURCES += SoftwareRenderer.cpp \
RayCastingManager.cpp \ RayCastingManager.cpp \
NightSky.cpp \ NightSky.cpp \
TerrainRayWalker.cpp \ TerrainRayWalker.cpp \
clouds/CloudModelAltoCumulus.cpp clouds/CloudModelAltoCumulus.cpp \
clouds/CloudModelCirrus.cpp
HEADERS += SoftwareRenderer.h\ HEADERS += SoftwareRenderer.h\
software_global.h \ software_global.h \
@ -66,7 +67,8 @@ HEADERS += SoftwareRenderer.h\
RayCastingManager.h \ RayCastingManager.h \
NightSky.h \ NightSky.h \
TerrainRayWalker.h \ TerrainRayWalker.h \
clouds/CloudModelAltoCumulus.h clouds/CloudModelAltoCumulus.h \
clouds/CloudModelCirrus.h
unix:!symbian { unix:!symbian {
maemo5 { maemo5 {