// spin specifies a rotation about the new Z axis (and orients the
// sunrise/set effects
bool SGCloudLayer::reposition( sgVec3 p, sgVec3 up, double lon, double lat,
- double alt )
+ double alt, double dt )
{
sgMat4 T1, LON, LAT;
sgVec3 axis;
last_lat = lat;
}
- if ( lon != last_lon || lat != last_lat ) {
+ double sp_dist = speed*dt;
+
+ if ( lon != last_lon || lat != last_lat || sp_dist != 0 ) {
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 );
+ double course = 0.0, dist = 0.0;
+
+ if (dest != start) {
+ calc_gc_course_dist( dest, start, &course, &dist );
+ }
// cout << "course = " << course << ", dist = " << dist << endl;
- double xoff = cos( course ) * dist / (2 * scale);
- double yoff = sin( course ) * dist / (2 * scale);
+
+ // calculate cloud movement due to external forces
+ double ax = 0.0, ay = 0.0, bx = 0.0, by = 0.0;
+
+ if (dist > 0.0) {
+ ax = cos(course) * dist;
+ ay = sin(course) * dist;
+ }
+
+ if (sp_dist > 0) {
+ bx = cos(-direction * SGD_DEGREES_TO_RADIANS) * sp_dist;
+ by = sin(-direction * SGD_DEGREES_TO_RADIANS) * sp_dist;
+ }
+
+
+ double xoff = (ax + bx) / (2 * scale);
+ double yoff = (ay + by) / (2 * scale);
const float layer_scale = layer_span / scale;
* visibility.
*/
float getTransition_m () const;
+
/**
* set the transition layer size in meters
* @param transition_m the transition layer size in meters
/** get coverage type */
Coverage getCoverage () const;
+
/**
* set coverage type
* @param coverage the coverage type
*/
void setCoverage (Coverage coverage);
+ /**
+ * set the cloud movement direction
+ * @param dir the cloud movement direction
+ */
+ inline void setDirection(float dir) { direction = dir; }
+
+ /** get the cloud movement direction */
+ inline float getDirection() { return direction; }
+
+ /**
+ * set the cloud movement speed
+ * @param sp the cloud movement speed
+ */
+ inline void setSpeed(float sp) { speed = sp; }
+
+ /** get the cloud movement speed */
+ inline float getSpeed() { return speed; }
+
/** build the cloud object */
void rebuild();
* @param lat specifies a rotation about the new Y axis
* @param spin specifies a rotation about the new Z axis
* (and orients the sunrise/set effects)
+ * @param dt the time elapsed since the last call
*/
- bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt );
+ bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt,
+ double dt = 0.0 );
/** draw the cloud layer */
void draw();
float layer_transition;
Coverage layer_coverage;
float scale;
+ float speed;
+ float direction;
// for handling texture coordinates to simulate cloud movement
// from winds, and to simulate the clouds being tied to ground
// spin specifies a rotation about the new Z axis (this allows
// additional orientation for the sunrise/set effects and is used by
// the skydome and perhaps clouds.
-bool SGSky::reposition( SGSkyState &st )
+bool SGSky::reposition( SGSkyState &st, double dt )
{
double angle = st.gst * 15; // degrees
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
if ( cloud_layers[i]->getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR ) {
cloud_layers[i]->reposition( st.zero_elev, st.view_up,
- st.lon, st.lat, st.alt );
+ st.lon, st.lat, st.alt, dt );
}
}
* @param moon_dec the moon's current declination
* @param moon_dist the moon's distance from the current view point.
*/
- bool reposition( SGSkyState &st );
+ bool reposition( SGSkyState &st, double dt = 0.0 );
/**
* Modify the given visibility based on cloud layers, thickness,