diff --git a/src/modules/graphic/osggraph/OsgMoon.cpp b/src/modules/graphic/osggraph/OsgMoon.cpp index 2f53abd78..e4597df52 100644 --- a/src/modules/graphic/osggraph/OsgMoon.cpp +++ b/src/modules/graphic/osggraph/OsgMoon.cpp @@ -49,13 +49,16 @@ SDMoon::~SDMoon( void ) } // build the moon object -osg::Node* SDMoon::build( std::string path, double moon_size ) +osg::Node* SDMoon::build( std::string path, double dist, double size ) { std::string TmpPath = path; - osg::Node* orb = SDMakeSphere(moon_size, 15, 15); + osg::Node* orb = SDMakeSphere(size, 15, 15); osg::StateSet* stateSet = orb->getOrCreateStateSet(); stateSet->setRenderBinDetails(-5, "RenderBin"); + moon_size = size; + moon_dist = dist; + path = TmpPath+"data/textures/moon.rgba"; osg::ref_ptr image = osgDB::readImageFile(path); osg::ref_ptr texture = new osg::Texture2D(image.get()); @@ -131,7 +134,7 @@ bool SDMoon::repaint( double moon_angle ) return true; } -bool SDMoon::reposition( osg::Vec3d p, double moon_dist ) +bool SDMoon::reposition( osg::Vec3d p, double angle ) { osg::Matrix T1, T2, RA, DEC; @@ -140,7 +143,7 @@ bool SDMoon::reposition( osg::Vec3d p, double moon_dist ) //T2.makeTranslate(osg::Vec3(0, moon_dist, 0)); T1.makeTranslate(p[0], p[1]+moon_dist, p[2]); - moon_transform->setMatrix(T1*DEC*RA); + moon_transform->setMatrix(DEC*RA*T1); return true; } diff --git a/src/modules/graphic/osggraph/OsgMoon.h b/src/modules/graphic/osggraph/OsgMoon.h index 288933d5c..b5cb354e5 100644 --- a/src/modules/graphic/osggraph/OsgMoon.h +++ b/src/modules/graphic/osggraph/OsgMoon.h @@ -46,7 +46,7 @@ public: ~SDMoon( void ); // build the moon object - osg::Node *build( std::string path, double moon_size ); + osg::Node *build( std::string path, double dist, double size ); bool repaint( double moon_angle ); bool reposition( osg::Vec3d p, double angle ); diff --git a/src/modules/graphic/osggraph/OsgRender.cpp b/src/modules/graphic/osggraph/OsgRender.cpp index 28571a47f..68e983d74 100644 --- a/src/modules/graphic/osggraph/OsgRender.cpp +++ b/src/modules/graphic/osggraph/OsgRender.cpp @@ -147,9 +147,9 @@ osg::Node* SDRender::Init(osg::Group *m_sceneroot, tTrack *track) SDMoonDeclination = (rand() % 270); //SDMoonDeclination = grUpdateMoonPos(timeOfDay); - SDMoonDeclination = 22.0; /*(rand() % 270);*/ + //SDMoonDeclination = 22.0; /*(rand() % 270);*/ - const float moonAscension = grTrack->local.sunascension - 180.0; + const float moonAscension = grTrack->local.sunascension; thesky->setMD( DEG2RAD(SDMoonDeclination) ); thesky->setMRA( DEG2RAD(moonAscension) ); diff --git a/src/modules/graphic/osggraph/OsgSky.cpp b/src/modules/graphic/osggraph/OsgSky.cpp index eb8b5038b..68c55a00e 100644 --- a/src/modules/graphic/osggraph/OsgSky.cpp +++ b/src/modules/graphic/osggraph/OsgSky.cpp @@ -98,11 +98,11 @@ void SDSky::build( std::string tex_path, double h_radius, double v_radius, doubl //_ephTransform->addChild( stars->build(eph.getNumStars(), eph.getStars(), h_radius)); moon = new SDMoon; - pre_transform->addChild( moon->build( tex_path, moon_size)); + pre_transform->addChild( moon->build( tex_path, moon_dist, moon_size)); //_ephTransform->addChild( moon->build(tex_path, moon_size) ); sun = new SDSun; - pre_transform->addChild( sun->build( tex_path, moon_size)); + pre_transform->addChild( sun->build( tex_path, sun_dist, sun_size)); //_ephTransform->addChild( oursun->build(tex_path, sun_size, property_tree_node ) ); pre_selector->addChild( pre_transform.get()); diff --git a/src/modules/graphic/osggraph/OsgSun.cpp b/src/modules/graphic/osggraph/OsgSun.cpp index 765fedd21..17251f2fb 100644 --- a/src/modules/graphic/osggraph/OsgSun.cpp +++ b/src/modules/graphic/osggraph/OsgSun.cpp @@ -47,7 +47,7 @@ SDSun::~SDSun( void ) { } -osg::Node* SDSun::build( std::string path, double sun_size ) +osg::Node* SDSun::build( std::string path, double dist, double sun_size ) { std::string TmpPath = path; sun_transform = new osg::MatrixTransform; @@ -81,6 +81,8 @@ osg::Node* SDSun::build( std::string path, double sun_size ) stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF); stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); + sun_dist = dist; + osg::Node* sun = SDMakeSphere(sun_size, 15, 15); stateSet = sun->getOrCreateStateSet(); @@ -374,7 +376,7 @@ bool SDSun::reposition( osg::Vec3d p, double sun_angle) //T2.makeTranslate(osg::Vec3(0, sun_dist, 0)); T1.makeTranslate(p[0], p[1]+ sun_dist, p[2]); - sun_transform->setMatrix(T1*DEC*RA); + sun_transform->setMatrix(DEC*RA*T1); // Suncolor related things: if ( prev_sun_angle != sun_angle ) diff --git a/src/modules/graphic/osggraph/OsgSun.h b/src/modules/graphic/osggraph/OsgSun.h index 2626c5945..ae02428c3 100644 --- a/src/modules/graphic/osggraph/OsgSun.h +++ b/src/modules/graphic/osggraph/OsgSun.h @@ -53,7 +53,7 @@ public: // Destructor ~SDSun( void ); - osg::Node* build( std::string path, double sun_size ); + osg::Node* build( std::string path, double dist, double sun_size ); bool repaint( double sun_angle, double new_visibility ); bool reposition( osg::Vec3d p, double angle);