forked from speed-dreams/speed-dreams-code
update OsgMoon & OsgSun
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5299 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 3959b6083e516ff73ea4de06f9237eb9d9805c42 Former-commit-id: b189e59ace62f0c899e4360d813406a3f181ad25
This commit is contained in:
parent
359243b455
commit
5fc6647b82
3 changed files with 17 additions and 18 deletions
|
@ -56,7 +56,7 @@ osg::Node* SDMoon::build( std::string path, double moon_size )
|
|||
osg::StateSet* stateSet = orb->getOrCreateStateSet();
|
||||
stateSet->setRenderBinDetails(-5, "RenderBin");
|
||||
|
||||
path = TmpPath+"moon.png";
|
||||
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());
|
||||
stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
|
||||
|
@ -135,14 +135,12 @@ bool SDMoon::reposition( osg::Vec3d p, double moon_dist )
|
|||
{
|
||||
osg::Matrix T1, T2, RA, DEC;
|
||||
|
||||
RA.makeRotate(moonAscension - 90.0 * SD_DEGREES_TO_RADIANS, osg::Vec3(0, 0, 1));
|
||||
DEC.makeRotate(moondeclination * SD_DEGREES_TO_RADIANS, osg::Vec3(1, 0, 0));
|
||||
//T2.makeTranslate(osg::Vec3(0, moon_dist, 0));
|
||||
T1.makeTranslate(p[0], p[1]+moon_dist, p[2]);
|
||||
|
||||
RA.makeRotate(moonAscension - 90.0 * SD_DEGREES_TO_RADIANS,
|
||||
osg::Vec3(0, 0, 1));
|
||||
DEC.makeRotate(moondeclination, osg::Vec3(1, 0, 0));
|
||||
T2.makeTranslate(osg::Vec3(0, moon_dist, 0));
|
||||
|
||||
moon_transform->setMatrix(T2*DEC*RA);
|
||||
moon_transform->setMatrix(T1*DEC*RA);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ osg::Node* SDRender::Init(osg::Group *m_sceneroot, tTrack *track)
|
|||
grTrack = track;
|
||||
|
||||
std::string datapath = GetDataDir();
|
||||
datapath +="/";
|
||||
//datapath +="/";
|
||||
thesky = new SDSky;
|
||||
GfOut("SDSky class\n");
|
||||
int SDSkyDomeDistance = 12000;
|
||||
|
@ -147,9 +147,9 @@ osg::Node* SDRender::Init(osg::Group *m_sceneroot, tTrack *track)
|
|||
SDMoonDeclination = (rand() % 270);
|
||||
|
||||
//SDMoonDeclination = grUpdateMoonPos(timeOfDay);
|
||||
SDMoonDeclination = 18.0; /*(rand() % 270);*/
|
||||
SDMoonDeclination = 22.0; /*(rand() % 270);*/
|
||||
|
||||
const float moonAscension = grTrack->local.sunascension;
|
||||
const float moonAscension = grTrack->local.sunascension - 180.0;
|
||||
|
||||
thesky->setMD( DEG2RAD(SDMoonDeclination) );
|
||||
thesky->setMRA( DEG2RAD(moonAscension) );
|
||||
|
|
|
@ -86,7 +86,7 @@ osg::Node* SDSun::build( std::string path, double sun_size )
|
|||
|
||||
stateSet->setRenderBinDetails(-6, "RenderBin");
|
||||
|
||||
path = TmpPath+"sun.png";
|
||||
path = TmpPath+"data/textures/sun.png";
|
||||
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(path);
|
||||
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D(image.get());
|
||||
stateSet->setTextureAttributeAndModes(0, texture);
|
||||
|
@ -125,7 +125,7 @@ osg::Node* SDSun::build( std::string path, double sun_size )
|
|||
stateSet = geode->getOrCreateStateSet();
|
||||
stateSet->setRenderBinDetails(-7, "RenderBin");
|
||||
|
||||
path = TmpPath+"inner_halo.png";
|
||||
path = TmpPath+"data/textures/inner_halo.png";
|
||||
osg::ref_ptr<osg::Image> image2 = osgDB::readImageFile(path);
|
||||
osg::ref_ptr<osg::Texture2D> texture2 = new osg::Texture2D(image2.get());
|
||||
stateSet->setTextureAttributeAndModes(0, texture2);
|
||||
|
@ -162,7 +162,7 @@ osg::Node* SDSun::build( std::string path, double sun_size )
|
|||
stateSet = geode->getOrCreateStateSet();
|
||||
stateSet->setRenderBinDetails(-8, "RenderBin");
|
||||
|
||||
path = TmpPath+"outer_halo.png";
|
||||
path = TmpPath+"data/textures/outer_halo.png";
|
||||
osg::ref_ptr<osg::Image> image3 = osgDB::readImageFile(path);
|
||||
osg::ref_ptr<osg::Texture2D> texture3 = new osg::Texture2D(image3.get());
|
||||
stateSet->setTextureAttributeAndModes(0, texture3);
|
||||
|
@ -367,13 +367,14 @@ bool SDSun::reposition( osg::Vec3d p, double sun_angle)
|
|||
{
|
||||
osg::Matrix T1, T2, RA, DEC;
|
||||
|
||||
|
||||
|
||||
RA.makeRotate(sun_right_ascension - 90 *SD_DEGREES_TO_RADIANS, osg::Vec3(0, 0, 1));
|
||||
DEC.makeRotate(sun_declination * SD_DEGREES_TO_RADIANS, osg::Vec3(1, 0, 0));
|
||||
//T2.makeTranslate(osg::Vec3(0, sun_dist, 0));
|
||||
T1.makeTranslate(p[0], p[1]+ sun_dist, p[2]);
|
||||
|
||||
RA.makeRotate(sun_right_ascension - 90*SD_DEGREES_TO_RADIANS, osg::Vec3(0, 0, 1));
|
||||
DEC.makeRotate(sun_declination, osg::Vec3(1, 0, 0));
|
||||
T2.makeTranslate(osg::Vec3(0, sun_dist, 0));
|
||||
|
||||
sun_transform->setMatrix(T2*DEC*RA);
|
||||
sun_transform->setMatrix(T1*DEC*RA);
|
||||
|
||||
// Suncolor related things:
|
||||
if ( prev_sun_angle != sun_angle )
|
||||
|
|
Loading…
Reference in a new issue