pass the geodetic position and view orientation to the sky reposition function

This commit is contained in:
ehofman
2009-11-05 12:48:16 +00:00
committed by Tim Moore
parent e2ce4c0fa9
commit 85fba1325a
2 changed files with 20 additions and 7 deletions

View File

@@ -147,15 +147,27 @@ bool SGSky::reposition( const SGSkyState &st, const SGEphemeris& eph, double dt
double angle = st.gst * 15; // degrees
double angleRad = SGMiscd::deg2rad(angle);
dome->reposition( st.zero_elev, st.alt, st.lon, st.lat, st.spin );
SGVec3f view_pos, zero_elev, view_up;
double lon, lat, alt;
view_pos = toVec3f( SGVec3d::fromGeod(st.pos) );
SGGeod geodZeroViewPos = SGGeod::fromGeodM(st.pos, 0);
zero_elev = toVec3f( SGVec3d::fromGeod(geodZeroViewPos) );
view_up = toVec3f( st.ori.backTransform(SGVec3d::e2()) );
lon = st.pos.getLongitudeRad();
lat = st.pos.getLatitudeRad();
alt = st.pos.getElevationM();
dome->reposition( zero_elev, alt, lon, lat, st.spin );
osg::Matrix m = osg::Matrix::rotate(angleRad, osg::Vec3(0, 0, -1));
m.postMultTranslate(toOsg(st.view_pos));
m.postMultTranslate(toOsg(view_pos));
_ephTransform->setMatrix(m);
double sun_ra = eph.getSunRightAscension();
double sun_dec = eph.getSunDeclination();
oursun->reposition( sun_ra, sun_dec, st.sun_dist, st.lat, st.alt, st.sun_angle );
oursun->reposition( sun_ra, sun_dec, st.sun_dist, lat, alt, st.sun_angle );
double moon_ra = eph.getMoonRightAscension();
double moon_dec = eph.getMoonDeclination();
@@ -163,8 +175,7 @@ bool SGSky::reposition( const SGSkyState &st, const SGEphemeris& eph, double dt
for ( unsigned i = 0; i < 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, dt );
cloud_layers[i]->reposition( zero_elev, view_up, lon, lat, alt, dt);
} else
cloud_layers[i]->getNode()->setAllChildrenOff();
}

View File

@@ -45,6 +45,7 @@
#include <osg/Switch>
#include <simgear/ephemeris/ephemeris.hxx>
#include <simgear/math/SGMath.hxx>
#include <simgear/scene/sky/cloud.hxx>
#include <simgear/scene/sky/dome.hxx>
@@ -56,8 +57,9 @@ using std::vector;
typedef struct {
SGVec3f view_pos, zero_elev, view_up;
double lon, lat, alt, spin;
SGGeod pos;
SGQuatd ori;
double spin;
double gst;
double sun_dist;
double moon_dist;