Refactored cloud previews
This commit is contained in:
parent
532685f7cb
commit
ee78af05d5
14 changed files with 248 additions and 341 deletions
|
@ -1,87 +1,16 @@
|
||||||
#include "formclouds.h"
|
#include "formclouds.h"
|
||||||
|
|
||||||
#include "clouds/clo_preview.h"
|
|
||||||
#include "tools/euclid.h"
|
#include "tools/euclid.h"
|
||||||
#include "RenderingScenery.h"
|
#include "RenderingScenery.h"
|
||||||
#include "BasePreview.h"
|
#include "BasePreview.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "CloudsDefinition.h"
|
#include "CloudsDefinition.h"
|
||||||
#include "CloudLayerDefinition.h"
|
#include "CloudLayerDefinition.h"
|
||||||
|
#include "CloudsCoveragePreviewRenderer.h"
|
||||||
|
#include "CloudsAspectPreviewRenderer.h"
|
||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
/**************** Previews ****************/
|
|
||||||
class PreviewCloudsCoverage:public BasePreview
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PreviewCloudsCoverage(QWidget* parent, CloudLayerDefinition* layer):BasePreview(parent)
|
|
||||||
{
|
|
||||||
_renderer = cloudsPreviewCoverageCreateRenderer();
|
|
||||||
_3d = true;
|
|
||||||
|
|
||||||
_original_layer = layer;
|
|
||||||
|
|
||||||
addToggle("3d", tr("Perspective"), true);
|
|
||||||
configScaling(100.0, 1000.0, 20.0, 200.0);
|
|
||||||
}
|
|
||||||
~PreviewCloudsCoverage()
|
|
||||||
{
|
|
||||||
rendererDelete(_renderer);
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
Color getColor(double x, double y)
|
|
||||||
{
|
|
||||||
return cloudsPreviewCoverageGetPixel(_renderer, x, y, scaling, _3d);
|
|
||||||
}
|
|
||||||
virtual void toggleChangeEvent(QString key, bool value)
|
|
||||||
{
|
|
||||||
if (key == "3d")
|
|
||||||
{
|
|
||||||
_3d = value;
|
|
||||||
}
|
|
||||||
BasePreview::toggleChangeEvent(key, value);
|
|
||||||
}
|
|
||||||
void updateData()
|
|
||||||
{
|
|
||||||
cloudsPreviewCoverageBindLayer(_renderer, _original_layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Renderer* _renderer;
|
|
||||||
CloudLayerDefinition* _original_layer;
|
|
||||||
bool _3d;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PreviewCloudsColor:public BasePreview
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PreviewCloudsColor(QWidget* parent, CloudLayerDefinition* layer):BasePreview(parent)
|
|
||||||
{
|
|
||||||
_original_layer = layer;
|
|
||||||
|
|
||||||
_renderer = cloudsPreviewMaterialCreateRenderer();
|
|
||||||
|
|
||||||
configScaling(0.5, 2.0, 0.1, 2.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
~PreviewCloudsColor()
|
|
||||||
{
|
|
||||||
rendererDelete(_renderer);
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
Color getColor(double x, double y)
|
|
||||||
{
|
|
||||||
return cloudsPreviewMaterialGetPixel(_renderer, x, y);
|
|
||||||
}
|
|
||||||
void updateData()
|
|
||||||
{
|
|
||||||
cloudsPreviewMaterialBindLayer(_renderer, _original_layer);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
Renderer* _renderer;
|
|
||||||
CloudLayerDefinition* _original_layer;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**************** Form ****************/
|
/**************** Form ****************/
|
||||||
FormClouds::FormClouds(QWidget *parent):
|
FormClouds::FormClouds(QWidget *parent):
|
||||||
BaseFormLayer(parent)
|
BaseFormLayer(parent)
|
||||||
|
@ -94,10 +23,15 @@ FormClouds::FormClouds(QWidget *parent):
|
||||||
_definition = new CloudsDefinition(NULL);
|
_definition = new CloudsDefinition(NULL);
|
||||||
_layer = new CloudLayerDefinition(NULL);
|
_layer = new CloudLayerDefinition(NULL);
|
||||||
|
|
||||||
_previewCoverage = new PreviewCloudsCoverage(parent, _layer);
|
_previewCoverageRenderer = new CloudsCoveragePreviewRenderer(_layer);
|
||||||
_previewColor = new PreviewCloudsColor(parent, _layer);
|
_previewCoverage = new BasePreview(parent);
|
||||||
addPreview(_previewCoverage, tr("Layer coverage (no lighting)"));
|
addPreview(_previewCoverage, tr("Layer coverage (no lighting)"));
|
||||||
|
_previewCoverage->setRenderer(_previewCoverageRenderer);
|
||||||
|
|
||||||
|
_previewColorRenderer = new CloudsAspectPreviewRenderer(_layer);
|
||||||
|
_previewColor = new BasePreview(parent);
|
||||||
addPreview(_previewColor, tr("Appearance"));
|
addPreview(_previewColor, tr("Appearance"));
|
||||||
|
_previewColor->setRenderer(_previewColorRenderer);
|
||||||
|
|
||||||
addInputEnum(tr("Clouds model"), (int*)&_layer->type, QStringList() << tr("Cirrus") << tr("Cumulus") << tr("Stratocumulus") << tr("Stratus"));
|
addInputEnum(tr("Clouds model"), (int*)&_layer->type, QStringList() << tr("Cirrus") << tr("Cumulus") << tr("Stratocumulus") << tr("Stratus"));
|
||||||
addInputDouble(tr("Lower altitude"), &_layer->lower_altitude, -10.0, 50.0, 0.5, 5.0);
|
addInputDouble(tr("Lower altitude"), &_layer->lower_altitude, -10.0, 50.0, 0.5, 5.0);
|
||||||
|
@ -121,7 +55,10 @@ FormClouds::~FormClouds()
|
||||||
delete _definition;
|
delete _definition;
|
||||||
|
|
||||||
delete _previewCoverage;
|
delete _previewCoverage;
|
||||||
|
delete _previewCoverageRenderer;
|
||||||
|
|
||||||
delete _previewColor;
|
delete _previewColor;
|
||||||
|
delete _previewColorRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormClouds::revertConfig()
|
void FormClouds::revertConfig()
|
||||||
|
|
|
@ -27,8 +27,12 @@ protected:
|
||||||
private:
|
private:
|
||||||
CloudsDefinition* _definition;
|
CloudsDefinition* _definition;
|
||||||
CloudLayerDefinition* _layer;
|
CloudLayerDefinition* _layer;
|
||||||
|
|
||||||
BasePreview* _previewCoverage;
|
BasePreview* _previewCoverage;
|
||||||
|
CloudsCoveragePreviewRenderer* _previewCoverageRenderer;
|
||||||
|
|
||||||
BasePreview* _previewColor;
|
BasePreview* _previewColor;
|
||||||
|
CloudsAspectPreviewRenderer* _previewColorRenderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
104
src/render/preview/CloudsAspectPreviewRenderer.cpp
Normal file
104
src/render/preview/CloudsAspectPreviewRenderer.cpp
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
#include "CloudsAspectPreviewRenderer.h"
|
||||||
|
|
||||||
|
#include "clouds/public.h"
|
||||||
|
#include "atmosphere/public.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
|
#include "Scenery.h"
|
||||||
|
#include "CloudsDefinition.h"
|
||||||
|
#include "CloudLayerDefinition.h"
|
||||||
|
|
||||||
|
static void _getLightingStatus(Renderer*, LightStatus* status, Vector3, int)
|
||||||
|
{
|
||||||
|
LightDefinition light;
|
||||||
|
|
||||||
|
light.color.r = 0.5;
|
||||||
|
light.color.g = 0.5;
|
||||||
|
light.color.b = 0.5;
|
||||||
|
light.direction = Vector3(-1.0, 0.5, 1.0).normalize();
|
||||||
|
light.altered = 1;
|
||||||
|
light.reflection = 0.0;
|
||||||
|
lightingPushLight(status, &light);
|
||||||
|
|
||||||
|
light.color.r = 0.1;
|
||||||
|
light.color.g = 0.1;
|
||||||
|
light.color.b = 0.1;
|
||||||
|
light.direction = Vector3(1.0, -0.5, -1.0).normalize();
|
||||||
|
light.altered = 0;
|
||||||
|
light.reflection = 0.0;
|
||||||
|
lightingPushLight(status, &light);
|
||||||
|
}
|
||||||
|
|
||||||
|
static double _getDensity(Renderer*, CloudLayerDefinition* layer, Vector3 location)
|
||||||
|
{
|
||||||
|
double distance = 2.0 * v3Norm(location) / layer->thickness;
|
||||||
|
if (distance > 1.0)
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
else if (distance < 0.8)
|
||||||
|
{
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (1.0 - distance) / 0.2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static AtmosphereResult _fakeApplyAerialPerspective(Renderer*, Vector3, Color base)
|
||||||
|
{
|
||||||
|
AtmosphereResult result;
|
||||||
|
|
||||||
|
result.base = base;
|
||||||
|
result.final = base;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloudsAspectPreviewRenderer::CloudsAspectPreviewRenderer(CloudLayerDefinition* layer):
|
||||||
|
layer(layer)
|
||||||
|
{
|
||||||
|
CloudsDefinition* clouds = getScenery()->getClouds();
|
||||||
|
clouds->clear();
|
||||||
|
clouds->addLayer();
|
||||||
|
CloudsRendererClass.bind(this, clouds);
|
||||||
|
|
||||||
|
render_quality = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloudsAspectPreviewRenderer::bindEvent(BasePreview* preview)
|
||||||
|
{
|
||||||
|
preview->configScaling(0.5, 2.0, 0.1, 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloudsAspectPreviewRenderer::updateEvent()
|
||||||
|
{
|
||||||
|
CloudLayerDefinition* preview_layer = getScenery()->getClouds()->getCloudLayer(0);
|
||||||
|
layer->copy(preview_layer);
|
||||||
|
|
||||||
|
preview_layer->thickness = preview_layer->shape_scaling;
|
||||||
|
preview_layer->lower_altitude = -preview_layer->thickness / 2.0;
|
||||||
|
preview_layer->validate();
|
||||||
|
|
||||||
|
prepare();
|
||||||
|
|
||||||
|
clouds->getLayerDensity = _getDensity;
|
||||||
|
atmosphere->getLightingStatus = _getLightingStatus;
|
||||||
|
atmosphere->applyAerialPerspective = _fakeApplyAerialPerspective;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color CloudsAspectPreviewRenderer::getColor2D(double x, double y, double)
|
||||||
|
{
|
||||||
|
Vector3 start, end;
|
||||||
|
double thickness = layer->thickness;
|
||||||
|
|
||||||
|
start.x = x * thickness * 0.5;
|
||||||
|
start.z = y * thickness * 0.5;
|
||||||
|
start.y = thickness * 0.5;
|
||||||
|
|
||||||
|
end.x = start.x;
|
||||||
|
end.z = start.z;
|
||||||
|
end.y = -start.y;
|
||||||
|
|
||||||
|
return clouds->getColor(this, COLOR_BLUE, start, end);
|
||||||
|
}
|
27
src/render/preview/CloudsAspectPreviewRenderer.h
Normal file
27
src/render/preview/CloudsAspectPreviewRenderer.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef CLOUDSASPECTPREVIEWRENDERER_H
|
||||||
|
#define CLOUDSASPECTPREVIEWRENDERER_H
|
||||||
|
|
||||||
|
#include "preview_global.h"
|
||||||
|
|
||||||
|
#include "Base2dPreviewRenderer.h"
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace preview {
|
||||||
|
|
||||||
|
class PREVIEWSHARED_EXPORT CloudsAspectPreviewRenderer : public Base2dPreviewRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CloudsAspectPreviewRenderer(CloudLayerDefinition* layer);
|
||||||
|
|
||||||
|
virtual void bindEvent(BasePreview* preview) override;
|
||||||
|
virtual void updateEvent() override;
|
||||||
|
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
CloudLayerDefinition* layer;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CLOUDSASPECTPREVIEWRENDERER_H
|
65
src/render/preview/CloudsCoveragePreviewRenderer.cpp
Normal file
65
src/render/preview/CloudsCoveragePreviewRenderer.cpp
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
#include "CloudsCoveragePreviewRenderer.h"
|
||||||
|
|
||||||
|
#include "clouds/public.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
|
#include "Scenery.h"
|
||||||
|
#include "CloudsDefinition.h"
|
||||||
|
#include "CloudLayerDefinition.h"
|
||||||
|
|
||||||
|
Color _fakeApplyLightingToSurface(Renderer*, Vector3, Vector3, SurfaceMaterial*)
|
||||||
|
{
|
||||||
|
return COLOR_WHITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloudsCoveragePreviewRenderer::CloudsCoveragePreviewRenderer(CloudLayerDefinition* layer):
|
||||||
|
layer(layer)
|
||||||
|
{
|
||||||
|
perspective = true;
|
||||||
|
|
||||||
|
CloudsDefinition* clouds = getScenery()->getClouds();
|
||||||
|
clouds->clear();
|
||||||
|
clouds->addLayer();
|
||||||
|
CloudsRendererClass.bind(this, clouds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloudsCoveragePreviewRenderer::bindEvent(BasePreview* preview)
|
||||||
|
{
|
||||||
|
preview->addToggle("3d", "Perspective", perspective);
|
||||||
|
preview->configScaling(100.0, 1000.0, 20.0, 200.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloudsCoveragePreviewRenderer::updateEvent()
|
||||||
|
{
|
||||||
|
layer->copy(getScenery()->getClouds()->getCloudLayer(0));
|
||||||
|
prepare();
|
||||||
|
applyLightingToSurface = _fakeApplyLightingToSurface;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color CloudsCoveragePreviewRenderer::getColor2D(double x, double y, double scaling)
|
||||||
|
{
|
||||||
|
if (perspective)
|
||||||
|
{
|
||||||
|
Vector3 eye, look;
|
||||||
|
|
||||||
|
eye.x = 0.0;
|
||||||
|
eye.y = scaling;
|
||||||
|
eye.z = -10.0 * scaling;
|
||||||
|
look.x = x * 0.01 / scaling;
|
||||||
|
look.y = -(y * 0.01 - 0.3) / scaling;
|
||||||
|
look.z = 1.0;
|
||||||
|
look = look.normalize();
|
||||||
|
|
||||||
|
return clouds->getColor(this, COLOR_BLUE, eye, eye.add(look.scale(1000.0)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Vector3 start, end;
|
||||||
|
|
||||||
|
start.x = end.x = x;
|
||||||
|
start.z = end.z = y;
|
||||||
|
start.y = 1000.0;
|
||||||
|
end.y = -1000.0;
|
||||||
|
|
||||||
|
return clouds->getColor(this, COLOR_BLUE, start, end);
|
||||||
|
}
|
||||||
|
}
|
28
src/render/preview/CloudsCoveragePreviewRenderer.h
Normal file
28
src/render/preview/CloudsCoveragePreviewRenderer.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef CLOUDSCOVERAGEPREVIEWRENDERER_H
|
||||||
|
#define CLOUDSCOVERAGEPREVIEWRENDERER_H
|
||||||
|
|
||||||
|
#include "preview_global.h"
|
||||||
|
|
||||||
|
#include "Base2dPreviewRenderer.h"
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace preview {
|
||||||
|
|
||||||
|
class PREVIEWSHARED_EXPORT CloudsCoveragePreviewRenderer : public Base2dPreviewRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CloudsCoveragePreviewRenderer(CloudLayerDefinition* layer);
|
||||||
|
|
||||||
|
virtual void bindEvent(BasePreview* preview) override;
|
||||||
|
virtual void updateEvent() override;
|
||||||
|
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool perspective;
|
||||||
|
CloudLayerDefinition* layer;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CLOUDSCOVERAGEPREVIEWRENDERER_H
|
|
@ -17,7 +17,9 @@ SOURCES += Base2dPreviewRenderer.cpp \
|
||||||
BasePreview.cpp \
|
BasePreview.cpp \
|
||||||
PreviewOsd.cpp \
|
PreviewOsd.cpp \
|
||||||
DrawingWidget.cpp \
|
DrawingWidget.cpp \
|
||||||
PreviewOsdItem.cpp
|
PreviewOsdItem.cpp \
|
||||||
|
CloudsCoveragePreviewRenderer.cpp \
|
||||||
|
CloudsAspectPreviewRenderer.cpp
|
||||||
|
|
||||||
HEADERS += Base2dPreviewRenderer.h\
|
HEADERS += Base2dPreviewRenderer.h\
|
||||||
preview_global.h \
|
preview_global.h \
|
||||||
|
@ -25,7 +27,9 @@ HEADERS += Base2dPreviewRenderer.h\
|
||||||
BasePreview.h \
|
BasePreview.h \
|
||||||
PreviewOsd.h \
|
PreviewOsd.h \
|
||||||
DrawingWidget.h \
|
DrawingWidget.h \
|
||||||
PreviewOsdItem.h
|
PreviewOsdItem.h \
|
||||||
|
CloudsCoveragePreviewRenderer.h \
|
||||||
|
CloudsAspectPreviewRenderer.h
|
||||||
|
|
||||||
unix:!symbian {
|
unix:!symbian {
|
||||||
maemo5 {
|
maemo5 {
|
||||||
|
|
|
@ -18,6 +18,8 @@ namespace preview {
|
||||||
class BasePreview;
|
class BasePreview;
|
||||||
class Base2dPreviewRenderer;
|
class Base2dPreviewRenderer;
|
||||||
class AtmosphereColorPreviewRenderer;
|
class AtmosphereColorPreviewRenderer;
|
||||||
|
class CloudsCoveragePreviewRenderer;
|
||||||
|
class CloudsAspectPreviewRenderer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
using namespace paysages::preview;
|
using namespace paysages::preview;
|
||||||
|
|
|
@ -1,143 +0,0 @@
|
||||||
#include "clo_preview.h"
|
|
||||||
#include "private.h"
|
|
||||||
|
|
||||||
#include "../tools/euclid.h"
|
|
||||||
#include "../renderer.h"
|
|
||||||
#include "atmosphere/public.h"
|
|
||||||
#include "CloudsDefinition.h"
|
|
||||||
#include "CloudLayerDefinition.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clouds previews.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Color _fakeApplyLightingToSurface(Renderer*, Vector3, Vector3, SurfaceMaterial*)
|
|
||||||
{
|
|
||||||
return COLOR_WHITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Renderer* cloudsPreviewCoverageCreateRenderer()
|
|
||||||
{
|
|
||||||
Renderer* result = rendererCreate();
|
|
||||||
result->render_quality = 5;
|
|
||||||
result->applyLightingToSurface = _fakeApplyLightingToSurface;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cloudsPreviewCoverageBindLayer(Renderer* renderer, CloudLayerDefinition* layer)
|
|
||||||
{
|
|
||||||
CloudsDefinition clouds(NULL);
|
|
||||||
clouds.addLayer(layer->newCopy(&clouds));
|
|
||||||
CloudsRendererClass.bind(renderer, &clouds);
|
|
||||||
}
|
|
||||||
|
|
||||||
Color cloudsPreviewCoverageGetPixel(Renderer* renderer, double x, double y, double scaling, int perspective)
|
|
||||||
{
|
|
||||||
if (perspective)
|
|
||||||
{
|
|
||||||
Vector3 eye, look;
|
|
||||||
|
|
||||||
eye.x = 0.0;
|
|
||||||
eye.y = scaling;
|
|
||||||
eye.z = -10.0 * scaling;
|
|
||||||
look.x = x * 0.01 / scaling;
|
|
||||||
look.y = -(y * 0.01 - 0.3) / scaling;
|
|
||||||
look.z = 1.0;
|
|
||||||
look = v3Normalize(look);
|
|
||||||
|
|
||||||
return renderer->clouds->getColor(renderer, COLOR_BLUE, eye, v3Add(eye, v3Scale(look, 1000.0)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Vector3 start, end;
|
|
||||||
|
|
||||||
start.x = end.x = x;
|
|
||||||
start.z = end.z = y;
|
|
||||||
start.y = 1000.0;
|
|
||||||
end.y = -1000.0;
|
|
||||||
|
|
||||||
return renderer->clouds->getColor(renderer, COLOR_BLUE, start, end);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _getLightingStatus(Renderer*, LightStatus* status, Vector3, int)
|
|
||||||
{
|
|
||||||
LightDefinition light;
|
|
||||||
|
|
||||||
light.color.r = 0.5;
|
|
||||||
light.color.g = 0.5;
|
|
||||||
light.color.b = 0.5;
|
|
||||||
light.direction.x = -1.0;
|
|
||||||
light.direction.y = 0.5;
|
|
||||||
light.direction.z = 1.0;
|
|
||||||
light.direction = v3Normalize(light.direction);
|
|
||||||
light.altered = 1;
|
|
||||||
light.reflection = 0.0;
|
|
||||||
lightingPushLight(status, &light);
|
|
||||||
|
|
||||||
light.color.r = 0.1;
|
|
||||||
light.color.g = 0.1;
|
|
||||||
light.color.b = 0.1;
|
|
||||||
light.direction.x = 1.0;
|
|
||||||
light.direction.y = -0.5;
|
|
||||||
light.direction.z = -1.0;
|
|
||||||
light.direction = v3Normalize(light.direction);
|
|
||||||
light.altered = 0;
|
|
||||||
light.reflection = 0.0;
|
|
||||||
lightingPushLight(status, &light);
|
|
||||||
}
|
|
||||||
|
|
||||||
Renderer* cloudsPreviewMaterialCreateRenderer()
|
|
||||||
{
|
|
||||||
Renderer* result = rendererCreate();
|
|
||||||
result->render_quality = 6;
|
|
||||||
result->atmosphere->getLightingStatus = _getLightingStatus;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static double _getDensity(Renderer*, CloudLayerDefinition* layer, Vector3 location)
|
|
||||||
{
|
|
||||||
double distance = 2.0 * v3Norm(location) / layer->thickness;
|
|
||||||
if (distance > 1.0)
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
else if (distance < 0.8)
|
|
||||||
{
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (1.0 - distance) / 0.2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cloudsPreviewMaterialBindLayer(Renderer* renderer, CloudLayerDefinition* layer)
|
|
||||||
{
|
|
||||||
CloudsDefinition clouds(NULL);
|
|
||||||
clouds.addLayer(layer->newCopy(&clouds));
|
|
||||||
CloudsRendererClass.bind(renderer, &clouds);
|
|
||||||
|
|
||||||
layer = renderer->clouds->definition->getCloudLayer(0);
|
|
||||||
layer->thickness = layer->shape_scaling;
|
|
||||||
layer->lower_altitude = -layer->thickness / 2.0;
|
|
||||||
|
|
||||||
renderer->clouds->getLayerDensity = _getDensity;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color cloudsPreviewMaterialGetPixel(Renderer* renderer, double x, double y)
|
|
||||||
{
|
|
||||||
Vector3 start, end;
|
|
||||||
CloudLayerDefinition* layer = renderer->clouds->definition->getCloudLayer(0);
|
|
||||||
double thickness = layer->thickness;
|
|
||||||
|
|
||||||
start.x = x * thickness * 0.5;
|
|
||||||
start.z = y * thickness * 0.5;
|
|
||||||
start.y = thickness * 0.5;
|
|
||||||
|
|
||||||
end.x = start.x;
|
|
||||||
end.z = start.z;
|
|
||||||
end.y = -start.y;
|
|
||||||
|
|
||||||
return renderer->clouds->getColor(renderer, COLOR_BLUE, start, end);
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
#ifndef _PAYSAGES_CLOUDS_PREVIEW_H_
|
|
||||||
#define _PAYSAGES_CLOUDS_PREVIEW_H_
|
|
||||||
|
|
||||||
#include "public.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cloud preview helpers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT Renderer* cloudsPreviewCoverageCreateRenderer();
|
|
||||||
RENDERINGSHARED_EXPORT void cloudsPreviewCoverageBindLayer(Renderer* renderer, CloudLayerDefinition* layer);
|
|
||||||
RENDERINGSHARED_EXPORT Color cloudsPreviewCoverageGetPixel(Renderer* renderer, double x, double y, double scaling, int perspective);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT Renderer* cloudsPreviewMaterialCreateRenderer();
|
|
||||||
RENDERINGSHARED_EXPORT void cloudsPreviewMaterialBindLayer(Renderer* renderer, CloudLayerDefinition* layer);
|
|
||||||
RENDERINGSHARED_EXPORT Color cloudsPreviewMaterialGetPixel(Renderer* renderer, double x, double y);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,64 +0,0 @@
|
||||||
#include "geoarea.h"
|
|
||||||
|
|
||||||
#include "PackStream.h"
|
|
||||||
|
|
||||||
GeoArea geoareaCreate()
|
|
||||||
{
|
|
||||||
GeoArea result;
|
|
||||||
|
|
||||||
result.location_x = -40.0;
|
|
||||||
result.location_z = -40.0;
|
|
||||||
result.size_x = 80.0;
|
|
||||||
result.size_z = 80.0;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void geoareaDelete(GeoArea*)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void geoareaCopy(GeoArea* source, GeoArea* destination)
|
|
||||||
{
|
|
||||||
*destination = *source;
|
|
||||||
}
|
|
||||||
|
|
||||||
void geoareaValidate(GeoArea* geoarea)
|
|
||||||
{
|
|
||||||
if (geoarea->size_x < 0.000000001)
|
|
||||||
{
|
|
||||||
geoarea->size_x = 0.000000001;
|
|
||||||
}
|
|
||||||
if (geoarea->size_z < 0.000000001)
|
|
||||||
{
|
|
||||||
geoarea->size_z = 0.000000001;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void geoareaSave(PackStream* stream, GeoArea* geoarea)
|
|
||||||
{
|
|
||||||
stream->write(&geoarea->location_x);
|
|
||||||
stream->write(&geoarea->location_z);
|
|
||||||
stream->write(&geoarea->size_x);
|
|
||||||
stream->write(&geoarea->size_z);
|
|
||||||
}
|
|
||||||
|
|
||||||
void geoareaLoad(PackStream* stream, GeoArea* geoarea)
|
|
||||||
{
|
|
||||||
stream->read(&geoarea->location_x);
|
|
||||||
stream->read(&geoarea->location_z);
|
|
||||||
stream->read(&geoarea->size_x);
|
|
||||||
stream->read(&geoarea->size_z);
|
|
||||||
}
|
|
||||||
|
|
||||||
void geoareaToLocal(GeoArea* geoarea, double absolute_x, double absolute_z, double* local_x, double* local_z)
|
|
||||||
{
|
|
||||||
*local_x = (absolute_x - geoarea->location_x) / geoarea->size_x;
|
|
||||||
*local_z = (absolute_z - geoarea->location_z) / geoarea->size_z;
|
|
||||||
}
|
|
||||||
|
|
||||||
void geoareaFromLocal(GeoArea* geoarea, double local_x, double local_z, double* absolute_x, double* absolute_z)
|
|
||||||
{
|
|
||||||
*absolute_x = geoarea->location_x + local_x * geoarea->size_x;
|
|
||||||
*absolute_z = geoarea->location_z + local_z * geoarea->size_z;
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
#ifndef _PAYSAGES_GEOAREA_H_
|
|
||||||
#define _PAYSAGES_GEOAREA_H_
|
|
||||||
|
|
||||||
/* Geographic area definition */
|
|
||||||
|
|
||||||
#include "rendering_global.h"
|
|
||||||
|
|
||||||
namespace paysages {
|
|
||||||
namespace system {
|
|
||||||
class PackStream;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
double location_x;
|
|
||||||
double location_z;
|
|
||||||
double size_x;
|
|
||||||
double size_z;
|
|
||||||
} GeoArea;
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT GeoArea geoareaCreate();
|
|
||||||
RENDERINGSHARED_EXPORT void geoareaDelete(GeoArea* geoarea);
|
|
||||||
RENDERINGSHARED_EXPORT void geoareaCopy(GeoArea* source, GeoArea* destination);
|
|
||||||
RENDERINGSHARED_EXPORT void geoareaValidate(GeoArea* geoarea);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void geoareaSave(PackStream* stream, GeoArea* geoarea);
|
|
||||||
RENDERINGSHARED_EXPORT void geoareaLoad(PackStream* stream, GeoArea* geoarea);
|
|
||||||
|
|
||||||
RENDERINGSHARED_EXPORT void geoareaToLocal(GeoArea* geoarea, double absolute_x, double absolute_z, double* local_x, double* local_z);
|
|
||||||
RENDERINGSHARED_EXPORT void geoareaFromLocal(GeoArea* geoarea, double local_x, double local_z, double* absolute_x, double* absolute_z);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -12,13 +12,11 @@ SOURCES += main.cpp \
|
||||||
renderer.cpp \
|
renderer.cpp \
|
||||||
render.cpp \
|
render.cpp \
|
||||||
opencl.cpp \
|
opencl.cpp \
|
||||||
geoarea.cpp \
|
|
||||||
atmosphere/atm_render.cpp \
|
atmosphere/atm_render.cpp \
|
||||||
atmosphere/atm_raster.cpp \
|
atmosphere/atm_raster.cpp \
|
||||||
atmosphere/atm_bruneton.cpp \
|
atmosphere/atm_bruneton.cpp \
|
||||||
clouds/clo_walking.cpp \
|
clouds/clo_walking.cpp \
|
||||||
clouds/clo_rendering.cpp \
|
clouds/clo_rendering.cpp \
|
||||||
clouds/clo_preview.cpp \
|
|
||||||
clouds/clo_density.cpp \
|
clouds/clo_density.cpp \
|
||||||
terrain/ter_render.cpp \
|
terrain/ter_render.cpp \
|
||||||
terrain/ter_raster.cpp \
|
terrain/ter_raster.cpp \
|
||||||
|
@ -36,7 +34,6 @@ SOURCES += main.cpp \
|
||||||
water/wat_render.cpp \
|
water/wat_render.cpp \
|
||||||
water/wat_raster.cpp \
|
water/wat_raster.cpp \
|
||||||
water/wat_preview.cpp \
|
water/wat_preview.cpp \
|
||||||
water/wat_definition.cpp \
|
|
||||||
RenderingScenery.cpp
|
RenderingScenery.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
@ -44,13 +41,11 @@ HEADERS += \
|
||||||
render.h \
|
render.h \
|
||||||
opencl.h \
|
opencl.h \
|
||||||
main.h \
|
main.h \
|
||||||
geoarea.h \
|
|
||||||
atmosphere/public.h \
|
atmosphere/public.h \
|
||||||
atmosphere/private.h \
|
atmosphere/private.h \
|
||||||
clouds/public.h \
|
clouds/public.h \
|
||||||
clouds/private.h \
|
clouds/private.h \
|
||||||
clouds/clo_walking.h \
|
clouds/clo_walking.h \
|
||||||
clouds/clo_preview.h \
|
|
||||||
clouds/clo_density.h \
|
clouds/clo_density.h \
|
||||||
shared/types.h \
|
shared/types.h \
|
||||||
terrain/ter_raster.h \
|
terrain/ter_raster.h \
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
#include "private.h"
|
|
Loading…
Reference in a new issue