cloud_types: Added alto cumulus model
This commit is contained in:
parent
49564acc3c
commit
0ab61f8060
4 changed files with 100 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
|||
#include "CameraDefinition.h"
|
||||
|
||||
#include "clouds/BaseCloudsModel.h"
|
||||
#include "clouds/CloudModelAltoCumulus.h"
|
||||
#include "clouds/CloudModelStratoCumulus.h"
|
||||
|
||||
CloudsRenderer::CloudsRenderer(SoftwareRenderer* parent):
|
||||
|
@ -69,6 +70,8 @@ void CloudsRenderer::update()
|
|||
model = new CloudModelStratoCumulus(layer);
|
||||
break;
|
||||
case CloudLayerDefinition::ALTOCUMULUS:
|
||||
model = new CloudModelAltoCumulus(layer);
|
||||
break;
|
||||
case CloudLayerDefinition::ALTOSTRATUS:
|
||||
case CloudLayerDefinition::CUMULONIMBUS:
|
||||
case CloudLayerDefinition::CIRROCUMULUS:
|
||||
|
|
64
src/render/software/clouds/CloudModelAltoCumulus.cpp
Normal file
64
src/render/software/clouds/CloudModelAltoCumulus.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include "CloudModelAltoCumulus.h"
|
||||
|
||||
#include "NoiseGenerator.h"
|
||||
#include "Vector3.h"
|
||||
#include "CloudLayerDefinition.h"
|
||||
|
||||
CloudModelAltoCumulus::CloudModelAltoCumulus(CloudLayerDefinition* layer):
|
||||
BaseCloudsModel(layer)
|
||||
{
|
||||
noise = new NoiseGenerator();
|
||||
}
|
||||
|
||||
CloudModelAltoCumulus::~CloudModelAltoCumulus()
|
||||
{
|
||||
delete noise;
|
||||
}
|
||||
|
||||
void CloudModelAltoCumulus::update()
|
||||
{
|
||||
noise->clearLevels();
|
||||
noise->addLevelSimple(4.0, -1.0, 1.0);
|
||||
noise->addLevelSimple(1.0 / 2.0, -0.6, 0.6);
|
||||
noise->addLevelSimple(1.0 / 4.0, -0.3, 0.3);
|
||||
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 / 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->normalizeAmplitude(-4.0, 3.0, 0);
|
||||
noise->setState(layer->getNoiseState());
|
||||
}
|
||||
|
||||
void CloudModelAltoCumulus::getAltitudeRange(double *min_altitude, double *max_altitude) const
|
||||
{
|
||||
*min_altitude = 15.0 + 10.0 * layer->altitude;
|
||||
*max_altitude = *min_altitude + 18.0 * layer->scaling;
|
||||
}
|
||||
|
||||
double CloudModelAltoCumulus::getDensity(const Vector3 &location) const
|
||||
{
|
||||
double val;
|
||||
double min_altitude, max_altitude;
|
||||
double noise_scaling = 18.0 * layer->scaling;
|
||||
|
||||
getAltitudeRange(&min_altitude, &max_altitude);
|
||||
|
||||
if (location.y < min_altitude || location.y > max_altitude)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double x = 0.6 * location.x / noise_scaling;
|
||||
double y = (location.y - min_altitude) / noise_scaling;
|
||||
double z = 0.6 * 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.1 + coverage;
|
||||
}
|
||||
}
|
29
src/render/software/clouds/CloudModelAltoCumulus.h
Normal file
29
src/render/software/clouds/CloudModelAltoCumulus.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef CLOUDMODELALTOCUMULUS_H
|
||||
#define CLOUDMODELALTOCUMULUS_H
|
||||
|
||||
#include "../software_global.h"
|
||||
|
||||
#include "BaseCloudsModel.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace software {
|
||||
|
||||
class CloudModelAltoCumulus : public BaseCloudsModel
|
||||
{
|
||||
public:
|
||||
CloudModelAltoCumulus(CloudLayerDefinition* layer);
|
||||
virtual ~CloudModelAltoCumulus();
|
||||
|
||||
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 // CLOUDMODELALTOCUMULUS_H
|
|
@ -37,7 +37,8 @@ SOURCES += SoftwareRenderer.cpp \
|
|||
RenderArea.cpp \
|
||||
RayCastingManager.cpp \
|
||||
NightSky.cpp \
|
||||
TerrainRayWalker.cpp
|
||||
TerrainRayWalker.cpp \
|
||||
clouds/CloudModelAltoCumulus.cpp
|
||||
|
||||
HEADERS += SoftwareRenderer.h\
|
||||
software_global.h \
|
||||
|
@ -64,7 +65,8 @@ HEADERS += SoftwareRenderer.h\
|
|||
RenderArea.h \
|
||||
RayCastingManager.h \
|
||||
NightSky.h \
|
||||
TerrainRayWalker.h
|
||||
TerrainRayWalker.h \
|
||||
clouds/CloudModelAltoCumulus.h
|
||||
|
||||
unix:!symbian {
|
||||
maemo5 {
|
||||
|
|
Loading…
Reference in a new issue