From 7b5d49ef60733314a280b766a34f9ca448b956f6 Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 22 May 2005 08:09:08 +0000 Subject: [PATCH] Harald JOHSNEN: Changes ======= - correct the transparency probleme when old 3d clouds were enabled (rendering context with an alpha channel) - changed rain cone orientation, it can now be viewed from helicopter or chase view (still not tower view) - clouds are a bit more yellow/red at dawn/dusk - weather data is now correctly propagated to the interpolator, this correct visibility, wind, etc - the 'metar' weather scenario now immedialty reuse the real metar data - real metar no more overwrite custom weather scenario --- simgear/environment/visual_enviro.cxx | 11 ++++++----- simgear/environment/visual_enviro.hxx | 4 ++-- simgear/scene/sky/bbcache.cxx | 9 +++++++-- simgear/scene/sky/cloudfield.cxx | 19 +++++++++++++++---- simgear/scene/sky/cloudfield.hxx | 2 +- 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/simgear/environment/visual_enviro.cxx b/simgear/environment/visual_enviro.cxx index 0c5192eb..8855689a 100644 --- a/simgear/environment/visual_enviro.cxx +++ b/simgear/environment/visual_enviro.cxx @@ -388,14 +388,14 @@ void SGEnviro::DrawCone2(float baseRadius, float height, int slices, bool down, } // TODO:check alt vs layer -void SGEnviro::drawRain(double pitch, double roll, double speed, double rain_norm) { +void SGEnviro::drawRain(double pitch, double roll, double heading, double speed, double rain_norm) { glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); glEnable(GL_BLEND); - glBlendFunc( GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); glDisable( GL_FOG ); glDisable(GL_LIGHTING); @@ -411,11 +411,12 @@ void SGEnviro::drawRain(double pitch, double roll, double speed, double rain_nor angle = -pitch - angle; glRotatef(angle, 1.0, 0.0, 0.0); glRotatef(roll, 0.0, 1.0, 0.0); + glRotatef(heading, 0.0, 0.0, 1.0); // up cone DrawCone2(15.0, 30.0, slice_count, true, rain_norm, speed); // down cone (usually not visible) - if(angle > 0.0) + if(angle > 0.0 || heading != 0.0) DrawCone2(15.0, -30.0, slice_count, false, rain_norm, speed); glPopMatrix(); @@ -431,10 +432,10 @@ void SGEnviro::set_soundMgr(SGSoundMgr *mgr) { soundMgr = mgr; } -void SGEnviro::drawPrecipitation(double rain_norm, double snow_norm, double hail_norm, double pitch, double roll, double speed) { +void SGEnviro::drawPrecipitation(double rain_norm, double snow_norm, double hail_norm, double pitch, double roll, double heading, double speed) { // TODO:check alt with right layer (wich layer ?) if( precipitation_enable_state && rain_norm > 0.0) - drawRain(pitch, roll, speed, rain_norm); + drawRain(pitch, roll, heading, speed, rain_norm); } diff --git a/simgear/environment/visual_enviro.hxx b/simgear/environment/visual_enviro.hxx index 6e2e7d53..d4c89194 100644 --- a/simgear/environment/visual_enviro.hxx +++ b/simgear/environment/visual_enviro.hxx @@ -77,7 +77,7 @@ public: */ void callback_cloud(float heading, float alt, float radius, int familly, float dist); - void drawRain(double pitch, double roll, double speed, double rain_norm); + void drawRain(double pitch, double roll, double heading, double speed, double rain_norm); /** * Draw rain or snow precipitation around the viewer. * @param rain_norm rain normalized intensity given by metar class @@ -88,7 +88,7 @@ public: * @param speed moving speed of viewer in kt */ void drawPrecipitation(double rain_norm, double snow_norm, double hail_norm, - double pitch, double roll, double speed); + double pitch, double roll, double heading, double speed); /** * Draw the lightnings spawned by cumulo nimbus. diff --git a/simgear/scene/sky/bbcache.cxx b/simgear/scene/sky/bbcache.cxx index c9af9c26..da84fbce 100644 --- a/simgear/scene/sky/bbcache.cxx +++ b/simgear/scene/sky/bbcache.cxx @@ -25,6 +25,7 @@ #endif #include +#include #include #include @@ -115,8 +116,10 @@ void SGBbCache::init(int cacheCount) { rt->Reset("rgba tex2D ctt"); // rt->Reset("rgba tex2D"); if( rt->Initialize(256, 256, true) ) { + SG_LOG(SG_ALL, SG_INFO, "bbcache:Initialize sucessfull"); if (rt->BeginCapture()) { + SG_LOG(SG_ALL, SG_INFO, "bbcache:BeginCapture sucessfull, RTT available"); rtAvailable = true; glViewport(0, 0, 256, 256); glMatrixMode(GL_PROJECTION); @@ -138,8 +141,10 @@ void SGBbCache::init(int cacheCount) { glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); rt->EndCapture(); - } - } + } else + SG_LOG(SG_ALL, SG_WARN, "bbcache:BeginCapture failed, RTT not available for 3D clouds"); + } else + SG_LOG(SG_ALL, SG_WARN, "bbcache:Initialize failed, RTT not available for 3D clouds"); if( cacheCount ) allocTextureMemory( cacheCount, 64 ); diff --git a/simgear/scene/sky/cloudfield.cxx b/simgear/scene/sky/cloudfield.cxx index 0deadad7..725f8876 100644 --- a/simgear/scene/sky/cloudfield.cxx +++ b/simgear/scene/sky/cloudfield.cxx @@ -38,9 +38,12 @@ SG_USING_STD(vector); #include +#include "sky.hxx" #include "newcloud.hxx" #include "cloudfield.hxx" +extern SGSky *thesky; + static list_of_culledCloud inViewClouds; // visibility distance for clouds in meters @@ -51,7 +54,7 @@ bool SGCloudField::enable3D = false; double SGCloudField::fieldSize = 50000.0; float SGCloudField::density = 100.0; double SGCloudField::timer_dt = 0.0; -sgVec3 SGCloudField::view_vec; +sgVec3 SGCloudField::view_vec, SGCloudField::view_X, SGCloudField::view_Y; static int last_cache_size = 1*1024; static int cacheResolution = 64; @@ -364,8 +367,13 @@ void SGCloudField::Render(void) { sgVec4 diffuse, ambient; ssgGetLight( 0 )->getColour( GL_DIFFUSE, diffuse ); ssgGetLight( 0 )->getColour( GL_AMBIENT, ambient ); - sgScaleVec3 ( SGNewCloud::sunlight, diffuse , 1.0f); - sgScaleVec3 ( SGNewCloud::ambLight, ambient , 1.0f); +// sgScaleVec3 ( SGNewCloud::sunlight, diffuse , 1.0f); + sgScaleVec3 ( SGNewCloud::ambLight, ambient , 1.1f); + // trying something else : clouds are more yellow/red at dawn/dusk + // and added a bit of blue ambient + float *sun_color = thesky->get_sun_color(); + sgScaleVec3 ( SGNewCloud::sunlight, sun_color , 0.4f); + SGNewCloud::ambLight[2] += 0.1f; sgVec3 delta_light; sgSubVec3(delta_light, last_sunlight, SGNewCloud::sunlight); @@ -389,6 +397,8 @@ void SGCloudField::Render(void) { rely = fmod( rely + fieldSize, fieldSize ); sgSetVec3( eyePos, relx, alt, rely); sgCopyVec3( view_vec, tmp[1] ); + sgCopyVec3( view_X, tmp[0] ); + sgCopyVec3( view_Y, tmp[2] ); tmp[3][2] = 0; tmp[3][0] = 0; @@ -424,9 +434,10 @@ void SGCloudField::Render(void) { glAlphaFunc(GL_GREATER, 0.0f); glDisable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); + glDepthMask( GL_FALSE ); glEnable(GL_SMOOTH); glEnable(GL_BLEND); - glBlendFunc( GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); glEnable( GL_TEXTURE_2D ); glDisable( GL_FOG ); glDisable(GL_LIGHTING); diff --git a/simgear/scene/sky/cloudfield.hxx b/simgear/scene/sky/cloudfield.hxx index 8bd8599f..703b17a1 100644 --- a/simgear/scene/sky/cloudfield.hxx +++ b/simgear/scene/sky/cloudfield.hxx @@ -104,7 +104,7 @@ public: // visibility distance for clouds in meters static float CloudVis; - static sgVec3 view_vec; + static sgVec3 view_vec, view_X, view_Y; static float density; static double timer_dt; -- 2.39.5