From 2805a2d0cc86d03052fcd5da0e648ce5bfd82f7d Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Sun, 7 Aug 2011 12:56:10 +0100 Subject: [PATCH] Add support for "squashing" the billboarding of individual 3D cloud sprites, to allow thin layers of stratus to be generated by large textures. --- simgear/scene/sky/CloudShaderGeometry.cxx | 2 +- simgear/scene/sky/CloudShaderGeometry.hxx | 9 +++++---- simgear/scene/sky/newcloud.cxx | 3 ++- simgear/scene/sky/newcloud.hxx | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/simgear/scene/sky/CloudShaderGeometry.cxx b/simgear/scene/sky/CloudShaderGeometry.cxx index 229710db..ed9e94f6 100644 --- a/simgear/scene/sky/CloudShaderGeometry.cxx +++ b/simgear/scene/sky/CloudShaderGeometry.cxx @@ -116,7 +116,7 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const (GLfloat) t.cloud_height }; extensions->glVertexAttrib3fv(USR_ATTR_1, ua1 ); extensions->glVertexAttrib3fv(USR_ATTR_2, ua2 ); - glColor4f(t.position.x(), t.position.y(), t.position.z(), 1.0); + glColor4f(t.position.x(), t.position.y(), t.position.z(), zscale); _geometry->draw(renderInfo); } } diff --git a/simgear/scene/sky/CloudShaderGeometry.hxx b/simgear/scene/sky/CloudShaderGeometry.hxx index cd00da8d..78f245ab 100644 --- a/simgear/scene/sky/CloudShaderGeometry.hxx +++ b/simgear/scene/sky/CloudShaderGeometry.hxx @@ -52,8 +52,8 @@ class CloudShaderGeometry : public osg::Drawable setUseDisplayList(false); } - CloudShaderGeometry(int vx, int vy, float width, float height) : - varieties_x(vx), varieties_y(vy) + CloudShaderGeometry(int vx, int vy, float width, float height, float zsc) : + varieties_x(vx), varieties_y(vy), zscale(zsc) { setUseDisplayList(false); float x = width/2.0f; @@ -107,13 +107,14 @@ class CloudShaderGeometry : public osg::Drawable _geometry = geometry; } - void addSprite(const SGVec3f& p, int tx, int ty, float w, float h, - float s, float cull, float cloud_height); + void addSprite(const SGVec3f& p, int tx, int ty, float w, float h, + float s, float cull, float cloud_height); osg::ref_ptr _geometry; int varieties_x; int varieties_y; + float zscale; // Bounding box extents. osg::BoundingBox _bbox; diff --git a/simgear/scene/sky/newcloud.cxx b/simgear/scene/sky/newcloud.cxx index 69aa193c..0e76ecbe 100644 --- a/simgear/scene/sky/newcloud.cxx +++ b/simgear/scene/sky/newcloud.cxx @@ -83,6 +83,7 @@ SGNewCloud::SGNewCloud(const SGPath &texture_root, const SGPropertyNode *cld_def num_textures_x = cld_def->getIntValue("num-textures-x", 4); num_textures_y = cld_def->getIntValue("num-textures-y", 4); bottom_shade = cld_def->getDoubleValue("bottom-shade", 1.0); + zscale = cld_def->getDoubleValue("z-scale", 1.0); texture = cld_def->getStringValue("texture", "cl_cumulus.png"); // Create a new Effect for the texture, if required. @@ -165,7 +166,7 @@ osg::ref_ptr SGNewCloud::genCloud() { osg::ref_ptr geode = new EffectGeode; - CloudShaderGeometry* sg = new CloudShaderGeometry(num_textures_x, num_textures_y, max_width, max_height); + CloudShaderGeometry* sg = new CloudShaderGeometry(num_textures_x, num_textures_y, max_width, max_height, zscale); // Determine how big this specific cloud instance is. Note that we subtract // the sprite size because the width/height is used to define the limits of diff --git a/simgear/scene/sky/newcloud.hxx b/simgear/scene/sky/newcloud.hxx index 941b9ba1..eb92c924 100644 --- a/simgear/scene/sky/newcloud.hxx +++ b/simgear/scene/sky/newcloud.hxx @@ -70,6 +70,7 @@ private: double min_sprite_height; double max_sprite_height; double bottom_shade; + double zscale; int num_sprites; int num_textures_x; int num_textures_y; -- 2.39.5