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 blue appearance at night
- Finalize lighting refactoring
=> Restore water and cloud filters
=> Restore water filtering
=> Restore cloud lighting
=> Restore and improve skydome lighting
- 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)
{
redraw();
}
void BasePreview::redraw()

View file

@ -13,10 +13,12 @@ public:
PreviewCloudsCoverage(QWidget* parent, CloudsLayerDefinition* layer):BasePreview(parent)
{
_renderer = cloudsCreatePreviewCoverageRenderer();
_3d = true;
_original_layer = layer;
_preview_definition = (CloudsDefinition*)CloudsDefinitionClass.create();
addToggle("3d", tr("Perspective"), true);
configScaling(100.0, 1000.0, 20.0, 200.0);
}
~PreviewCloudsCoverage()
@ -27,7 +29,15 @@ public:
protected:
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()
{
@ -40,6 +50,7 @@ private:
Renderer* _renderer;
CloudsLayerDefinition* _original_layer;
CloudsDefinition* _preview_definition;
bool _3d;
};
class PreviewCloudsColor:public BasePreview

View file

@ -26,8 +26,10 @@ Renderer* cloudsCreatePreviewCoverageRenderer()
return result;
}
Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling)
Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int perspective)
{
if (perspective)
{
Vector3 eye, look;
eye.x = 0.0;
@ -39,6 +41,18 @@ Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double sc
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);
}
}
Renderer* cloudsCreatePreviewColorRenderer()

View file

@ -82,7 +82,7 @@ LayerType cloudsGetLayerType();
void cloudsAutoPreset(CloudsLayerDefinition* definition, CloudsPreset preset);
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();
Color cloudsGetPreviewColor(Renderer* renderer, double x, double y);