From 0ab61f80602daa5e297674552de885fee22add9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Tue, 18 Mar 2014 21:08:17 +0100 Subject: [PATCH 1/3] cloud_types: Added alto cumulus model --- src/render/software/CloudsRenderer.cpp | 3 + .../software/clouds/CloudModelAltoCumulus.cpp | 64 +++++++++++++++++++ .../software/clouds/CloudModelAltoCumulus.h | 29 +++++++++ src/render/software/software.pro | 6 +- 4 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 src/render/software/clouds/CloudModelAltoCumulus.cpp create mode 100644 src/render/software/clouds/CloudModelAltoCumulus.h diff --git a/src/render/software/CloudsRenderer.cpp b/src/render/software/CloudsRenderer.cpp index 69286a6..b8ee363 100644 --- a/src/render/software/CloudsRenderer.cpp +++ b/src/render/software/CloudsRenderer.cpp @@ -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: diff --git a/src/render/software/clouds/CloudModelAltoCumulus.cpp b/src/render/software/clouds/CloudModelAltoCumulus.cpp new file mode 100644 index 0000000..2e6b27f --- /dev/null +++ b/src/render/software/clouds/CloudModelAltoCumulus.cpp @@ -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; + } +} diff --git a/src/render/software/clouds/CloudModelAltoCumulus.h b/src/render/software/clouds/CloudModelAltoCumulus.h new file mode 100644 index 0000000..f14890a --- /dev/null +++ b/src/render/software/clouds/CloudModelAltoCumulus.h @@ -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 diff --git a/src/render/software/software.pro b/src/render/software/software.pro index ec32efa..f5afcfe 100644 --- a/src/render/software/software.pro +++ b/src/render/software/software.pro @@ -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 { From eea639a7fb7b984feb473e0ae3399b9d0b21e9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Tue, 18 Mar 2014 21:17:41 +0100 Subject: [PATCH 2/3] cloud_types: Added cirrus model --- src/render/software/CloudsRenderer.cpp | 5 +- .../software/clouds/CloudModelCirrus.cpp | 62 +++++++++++++++++++ src/render/software/clouds/CloudModelCirrus.h | 29 +++++++++ src/render/software/software.pro | 6 +- 4 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 src/render/software/clouds/CloudModelCirrus.cpp create mode 100644 src/render/software/clouds/CloudModelCirrus.h diff --git a/src/render/software/CloudsRenderer.cpp b/src/render/software/CloudsRenderer.cpp index b8ee363..2159638 100644 --- a/src/render/software/CloudsRenderer.cpp +++ b/src/render/software/CloudsRenderer.cpp @@ -10,6 +10,7 @@ #include "clouds/BaseCloudsModel.h" #include "clouds/CloudModelAltoCumulus.h" +#include "clouds/CloudModelCirrus.h" #include "clouds/CloudModelStratoCumulus.h" CloudsRenderer::CloudsRenderer(SoftwareRenderer* parent): @@ -76,9 +77,11 @@ void CloudsRenderer::update() case CloudLayerDefinition::CUMULONIMBUS: case CloudLayerDefinition::CIRROCUMULUS: case CloudLayerDefinition::CIRROSTRATUS: - case CloudLayerDefinition::CIRRUS: model = new BaseCloudsModel(layer); break; + case CloudLayerDefinition::CIRRUS: + model = new CloudModelCirrus(layer); + break; } layer_models.push_back(model); diff --git a/src/render/software/clouds/CloudModelCirrus.cpp b/src/render/software/clouds/CloudModelCirrus.cpp new file mode 100644 index 0000000..b6c8078 --- /dev/null +++ b/src/render/software/clouds/CloudModelCirrus.cpp @@ -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; + } +} diff --git a/src/render/software/clouds/CloudModelCirrus.h b/src/render/software/clouds/CloudModelCirrus.h new file mode 100644 index 0000000..5cdfcc4 --- /dev/null +++ b/src/render/software/clouds/CloudModelCirrus.h @@ -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 diff --git a/src/render/software/software.pro b/src/render/software/software.pro index f5afcfe..959a4c8 100644 --- a/src/render/software/software.pro +++ b/src/render/software/software.pro @@ -38,7 +38,8 @@ SOURCES += SoftwareRenderer.cpp \ RayCastingManager.cpp \ NightSky.cpp \ TerrainRayWalker.cpp \ - clouds/CloudModelAltoCumulus.cpp + clouds/CloudModelAltoCumulus.cpp \ + clouds/CloudModelCirrus.cpp HEADERS += SoftwareRenderer.h\ software_global.h \ @@ -66,7 +67,8 @@ HEADERS += SoftwareRenderer.h\ RayCastingManager.h \ NightSky.h \ TerrainRayWalker.h \ - clouds/CloudModelAltoCumulus.h + clouds/CloudModelAltoCumulus.h \ + clouds/CloudModelCirrus.h unix:!symbian { maemo5 { From 1158aa248b9d96746353e0e2a20f0451a8bfdb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Tue, 18 Mar 2014 21:27:35 +0100 Subject: [PATCH 3/3] cloud_types: Added cumulo-nimbus model --- src/render/software/CloudsRenderer.cpp | 19 ++--- .../clouds/CloudModelCumuloNimbus.cpp | 69 +++++++++++++++++++ .../software/clouds/CloudModelCumuloNimbus.h | 29 ++++++++ src/render/software/software.pro | 6 +- 4 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 src/render/software/clouds/CloudModelCumuloNimbus.cpp create mode 100644 src/render/software/clouds/CloudModelCumuloNimbus.h diff --git a/src/render/software/CloudsRenderer.cpp b/src/render/software/CloudsRenderer.cpp index 2159638..79df79f 100644 --- a/src/render/software/CloudsRenderer.cpp +++ b/src/render/software/CloudsRenderer.cpp @@ -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); diff --git a/src/render/software/clouds/CloudModelCumuloNimbus.cpp b/src/render/software/clouds/CloudModelCumuloNimbus.cpp new file mode 100644 index 0000000..0a43489 --- /dev/null +++ b/src/render/software/clouds/CloudModelCumuloNimbus.cpp @@ -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; + } +} diff --git a/src/render/software/clouds/CloudModelCumuloNimbus.h b/src/render/software/clouds/CloudModelCumuloNimbus.h new file mode 100644 index 0000000..72d4f31 --- /dev/null +++ b/src/render/software/clouds/CloudModelCumuloNimbus.h @@ -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 diff --git a/src/render/software/software.pro b/src/render/software/software.pro index 959a4c8..dd41b16 100644 --- a/src/render/software/software.pro +++ b/src/render/software/software.pro @@ -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 {