paysages : Added cloud preview from above.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@507 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2013-01-30 10:57:41 +00:00 committed by ThunderK
parent 309450deca
commit fad0b9941b
5 changed files with 39 additions and 13 deletions

2
TODO
View file

@ -9,7 +9,7 @@ Technology Preview 2 :
=> Fix artifacts on aerial perspective => Fix artifacts on aerial perspective
=> Fix blue appearance at night => Fix blue appearance at night
- Finalize lighting refactoring - Finalize lighting refactoring
=> Restore water and cloud filters => Restore water filtering
=> Restore cloud lighting => Restore cloud lighting
=> Restore and improve skydome lighting => Restore and improve skydome lighting
- Apply Preetham's model usage - Apply Preetham's model usage

View file

@ -507,6 +507,7 @@ void BasePreview::addToggle(const QString& key, const QString& text, bool init_v
void BasePreview::toggleChangeEvent(QString, bool) void BasePreview::toggleChangeEvent(QString, bool)
{ {
redraw();
} }
void BasePreview::redraw() void BasePreview::redraw()

View file

@ -13,10 +13,12 @@ public:
PreviewCloudsCoverage(QWidget* parent, CloudsLayerDefinition* layer):BasePreview(parent) PreviewCloudsCoverage(QWidget* parent, CloudsLayerDefinition* layer):BasePreview(parent)
{ {
_renderer = cloudsCreatePreviewCoverageRenderer(); _renderer = cloudsCreatePreviewCoverageRenderer();
_3d = true;
_original_layer = layer; _original_layer = layer;
_preview_definition = (CloudsDefinition*)CloudsDefinitionClass.create(); _preview_definition = (CloudsDefinition*)CloudsDefinitionClass.create();
addToggle("3d", tr("Perspective"), true);
configScaling(100.0, 1000.0, 20.0, 200.0); configScaling(100.0, 1000.0, 20.0, 200.0);
} }
~PreviewCloudsCoverage() ~PreviewCloudsCoverage()
@ -27,7 +29,15 @@ public:
protected: protected:
Color getColor(double x, double y) Color getColor(double x, double y)
{ {
return cloudsGetPreviewCoverage(_renderer, x, y, scaling); return cloudsGetPreviewCoverage(_renderer, x, y, scaling, _3d);
}
virtual void toggleChangeEvent(QString key, bool value)
{
if (key == "3d")
{
_3d = value;
}
BasePreview::toggleChangeEvent(key, value);
} }
void updateData() void updateData()
{ {
@ -40,6 +50,7 @@ private:
Renderer* _renderer; Renderer* _renderer;
CloudsLayerDefinition* _original_layer; CloudsLayerDefinition* _original_layer;
CloudsDefinition* _preview_definition; CloudsDefinition* _preview_definition;
bool _3d;
}; };
class PreviewCloudsColor:public BasePreview class PreviewCloudsColor:public BasePreview

View file

@ -26,19 +26,33 @@ Renderer* cloudsCreatePreviewCoverageRenderer()
return result; return result;
} }
Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling) Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int perspective)
{ {
Vector3 eye, look; if (perspective)
{
Vector3 eye, look;
eye.x = 0.0; eye.x = 0.0;
eye.y = scaling; eye.y = scaling;
eye.z = -10.0 * scaling; eye.z = -10.0 * scaling;
look.x = x * 0.01 / scaling; look.x = x * 0.01 / scaling;
look.y = -y * 0.01 / scaling - 0.3; look.y = -y * 0.01 / scaling - 0.3;
look.z = 1.0; look.z = 1.0;
look = v3Normalize(look); look = v3Normalize(look);
return renderer->clouds->getColor(renderer, COLOR_BLUE, eye, v3Add(eye, v3Scale(look, 1000.0))); 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);
}
} }
Renderer* cloudsCreatePreviewColorRenderer() Renderer* cloudsCreatePreviewColorRenderer()

View file

@ -82,7 +82,7 @@ LayerType cloudsGetLayerType();
void cloudsAutoPreset(CloudsLayerDefinition* definition, CloudsPreset preset); void cloudsAutoPreset(CloudsLayerDefinition* definition, CloudsPreset preset);
Renderer* cloudsCreatePreviewCoverageRenderer(); Renderer* cloudsCreatePreviewCoverageRenderer();
Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling); Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int perspective);
Renderer* cloudsCreatePreviewColorRenderer(); Renderer* cloudsCreatePreviewColorRenderer();
Color cloudsGetPreviewColor(Renderer* renderer, double x, double y); Color cloudsGetPreviewColor(Renderer* renderer, double x, double y);