From 85fba1325a030903c93d13db6d8b296c5b13f8bb Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 5 Nov 2009 12:48:16 +0000 Subject: [PATCH] pass the geodetic position and view orientation to the sky reposition function --- simgear/scene/sky/sky.cxx | 21 ++++++++++++++++----- simgear/scene/sky/sky.hxx | 6 ++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/simgear/scene/sky/sky.cxx b/simgear/scene/sky/sky.cxx index 5367550b..2eec5cc3 100644 --- a/simgear/scene/sky/sky.cxx +++ b/simgear/scene/sky/sky.cxx @@ -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(); } diff --git a/simgear/scene/sky/sky.hxx b/simgear/scene/sky/sky.hxx index 6590c03f..1f1190f8 100644 --- a/simgear/scene/sky/sky.hxx +++ b/simgear/scene/sky/sky.hxx @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -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; -- 2.39.5