forked from speed-dreams/speed-dreams-code
OSG: calculating sun position and angle to plan
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5304 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 52cffd0d7250b81d41e826fb8d089d6d099d799d Former-commit-id: be22466a615a106922fa56d9be33d215db88cbbb
This commit is contained in:
parent
8ec3ca019f
commit
e213e2442b
3 changed files with 17 additions and 2 deletions
|
@ -227,7 +227,7 @@ bool SDScenery::LoadTrack(std::string strTrack)
|
||||||
|
|
||||||
if (pTrack)
|
if (pTrack)
|
||||||
{
|
{
|
||||||
pTrack->getOrCreateStateSet()->setRenderBinDetails(TRACKBIN,"RenderBin");
|
pTrack->getOrCreateStateSet()->setRenderBinDetails(TRACKBIN,"RenderBin");
|
||||||
_scenery->addChild(pTrack);
|
_scenery->addChild(pTrack);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -376,7 +376,18 @@ bool SDSun::reposition( osg::Vec3d p, double sun_angle)
|
||||||
//T2.makeTranslate(osg::Vec3(0, sun_dist, 0));
|
//T2.makeTranslate(osg::Vec3(0, sun_dist, 0));
|
||||||
T1.makeTranslate(0, sun_dist, 0);
|
T1.makeTranslate(0, sun_dist, 0);
|
||||||
|
|
||||||
sun_transform->setMatrix(T1*DEC*RA);
|
osg::Matrix R = T1*DEC*RA;
|
||||||
|
sun_transform->setMatrix(R);
|
||||||
|
|
||||||
|
osg::Vec4f pos = R*osg::Vec4f(0.0,0.0,0.0,1.0);
|
||||||
|
sun_position = osg::Vec3f(pos._v[0],pos._v[1],pos._v[2]);
|
||||||
|
|
||||||
|
osg::Vec3f upos = osg::Vec3f(sun_position);
|
||||||
|
osg::Vec3f uplan = osg::Vec3f(sun_position._v[0],0.0,sun_position._v[2]);
|
||||||
|
upos.normalize();
|
||||||
|
uplan.normalize();
|
||||||
|
|
||||||
|
sun_angle_to_scene = acos(upos*uplan);
|
||||||
|
|
||||||
// Suncolor related things:
|
// Suncolor related things:
|
||||||
if ( prev_sun_angle != sun_angle )
|
if ( prev_sun_angle != sun_angle )
|
||||||
|
|
|
@ -37,6 +37,7 @@ class SDSun
|
||||||
double prev_sun_angle;
|
double prev_sun_angle;
|
||||||
double sun_angle;
|
double sun_angle;
|
||||||
double sun_rotation;
|
double sun_rotation;
|
||||||
|
double sun_angle_to_scene;
|
||||||
|
|
||||||
// used by reposition
|
// used by reposition
|
||||||
double sun_right_ascension;
|
double sun_right_ascension;
|
||||||
|
@ -44,6 +45,7 @@ class SDSun
|
||||||
double sun_dist;
|
double sun_dist;
|
||||||
double path_distance;
|
double path_distance;
|
||||||
double sun_exp2_punch_through;
|
double sun_exp2_punch_through;
|
||||||
|
osg::Vec3f sun_position;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -82,6 +84,8 @@ public:
|
||||||
|
|
||||||
void setSunDistance( double dist ) { sun_dist = dist; }
|
void setSunDistance( double dist ) { sun_dist = dist; }
|
||||||
double getSunDistance() { return sun_dist; }
|
double getSunDistance() { return sun_dist; }
|
||||||
|
|
||||||
|
osg::Vec3f getSunPosition(){return sun_position;}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _OSGSUN_H_
|
#endif // _OSGSUN_H_
|
||||||
|
|
Loading…
Reference in a new issue