update matrix for SDSun & SDMoon
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5301 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: d60d80527577618f0a1c76f4ac3d4eab90d0c6bb Former-commit-id: 955038da935ade3f17caa857bd90f3d6bc6d8414
This commit is contained in:
parent
5fc6647b82
commit
03340950b5
6 changed files with 17 additions and 12 deletions
|
@ -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<osg::Image> image = osgDB::readImageFile(path);
|
||||
osg::ref_ptr<osg::Texture2D> 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;
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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) );
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue