#include <plib/ssg.h>
#include <simgear/constants.h>
+#include <simgear/math/point3d.hxx>
+#include <simgear/math/polar3d.hxx>
#include "cloud.hxx"
// 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" );
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;
}
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:
(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;
(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;