From: curt Date: Tue, 20 Jun 2000 02:49:03 +0000 (+0000) Subject: Cloud texcoord fixes to tie apparent cloud position to earth even though X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7db73cd2150b69aa7ae38fa8a46862c8d12231b9;p=simgear.git Cloud texcoord fixes to tie apparent cloud position to earth even though the whole cloud structure is actual tied to ownship movement. --- diff --git a/simgear/sky/cloud.cxx b/simgear/sky/cloud.cxx index 147f8078..20215a18 100644 --- a/simgear/sky/cloud.cxx +++ b/simgear/sky/cloud.cxx @@ -26,6 +26,8 @@ #include #include +#include +#include #include "cloud.hxx" @@ -41,9 +43,11 @@ SGCloudLayer::~SGCloudLayer( void ) { // build the moon object -ssgBranch * SGCloudLayer::build( FGPath path, double size, double asl ) { +ssgBranch * SGCloudLayer::build( FGPath path, double s, double asl ) { layer_asl = asl; + size = s; + last_lon = last_lat = -999.0f; // set up the cloud state path.append( "cloud.rgba" ); @@ -176,5 +180,49 @@ bool SGCloudLayer::reposition( sgVec3 p, sgVec3 up, double lon, double lat ) { layer_transform->setTransform( &layerpos ); + // now calculate update texture coordinates + if ( last_lon < -900 ) { + last_lon = lon; + last_lat = lat; + } + + if ( lon != last_lon || lat != last_lat ) { + Point3D start( last_lon, last_lat, 0.0 ); + Point3D dest( lon, lat, 0.0 ); + double course, dist; + calc_gc_course_dist( dest, start, &course, &dist ); + // cout << "course = " << course << ", dist = " << dist << endl; + + double xoff = cos( course ) * dist / 500.0; + double yoff = sin( course ) * dist / 500.0; + + // cout << "xoff = " << xoff << ", yoff = " << yoff << endl; + + float *base, *tc; + base = tl->get( 0 ); + + base[0] += xoff; + while ( base[0] > 1.0 ) { base[0] -= 1.0; } + while ( base[0] < 0.0 ) { base[0] += 1.0; } + + base[1] += yoff; + while ( base[1] > 1.0 ) { base[1] -= 1.0; } + while ( base[1] < 0.0 ) { base[1] += 1.0; } + + // cout << "base = " << base[0] << "," << base[1] << endl; + + tc = tl->get( 1 ); + sgSetVec2( tc, base[0] + size / 1000.0f, base[1] ); + + tc = tl->get( 2 ); + sgSetVec2( tc, base[0], base[1] + size / 1000.0f ); + + tc = tl->get( 3 ); + sgSetVec2( tc, base[0] + size / 1000.0f, base[1] + size / 1000.0f ); + + last_lon = lon; + last_lat = lat; + } + return true; } diff --git a/simgear/sky/cloud.hxx b/simgear/sky/cloud.hxx index 1faabb3f..37deac19 100644 --- a/simgear/sky/cloud.hxx +++ b/simgear/sky/cloud.hxx @@ -39,7 +39,15 @@ class SGCloudLayer { ssgVertexArray *vl; ssgTexCoordArray *tl; - float layer_asl; // height above sea level (meters) + // height above sea level (meters) + float layer_asl; + float size; + + // for handling texture coordinates to simulate cloud movement + // from winds, and to simulate the clouds being tied to ground + // position, not view position + // double xoff, yoff; + double last_lon, last_lat; public: diff --git a/simgear/sky/moon.cxx b/simgear/sky/moon.cxx index 3923ed2f..322a7321 100644 --- a/simgear/sky/moon.cxx +++ b/simgear/sky/moon.cxx @@ -220,7 +220,10 @@ bool SGMoon::repaint( double moon_angle ) { (ambient * 11.0) - 3.0, // minimum value = 0.3 (ambient * 12.0) - 3.6, // minimum value = 0.0 0.5 ); - + + // temp test, forces the color to always be white + // sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 ); + if (color[0] > 1.0) color[0] = 1.0; if (color[1] > 1.0) color[1] = 1.0; if (color[2] > 1.0) color[2] = 1.0; diff --git a/simgear/sky/oursun.cxx b/simgear/sky/oursun.cxx index 62d97867..6890b8b3 100644 --- a/simgear/sky/oursun.cxx +++ b/simgear/sky/oursun.cxx @@ -312,6 +312,9 @@ bool SGSun::repaint( double sun_angle ) { (ambient * 12.0) - 3.6, // minimum value = 0.0 1.0 ); + // temp test, forces the color to always be white + // sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 ); + if (color[0] > 1.0) color[0] = 1.0; if (color[1] > 1.0) color[1] = 1.0; if (color[2] > 1.0) color[2] = 1.0;