Cloud texcoord fixes to tie apparent cloud position to earth even though

the whole cloud structure is actual tied to ownship movement.
This commit is contained in:
curt
2000-06-20 02:49:03 +00:00
parent 242eceb1c6
commit 7db73cd215
4 changed files with 65 additions and 3 deletions

View File

@@ -26,6 +26,8 @@
#include <plib/ssg.h>
#include <simgear/constants.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#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;
}

View File

@@ -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:

View File

@@ -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;

View File

@@ -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;