forked from speed-dreams/speed-dreams-code
update SDRender
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5430 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 77d31604c365f5fe511277cf5719c930ae6e104a Former-commit-id: 8d8d36267a19d5eae917ffdb8bb88970b093199c
This commit is contained in:
parent
b3f7948ca5
commit
b5734187e2
8 changed files with 107 additions and 104 deletions
|
@ -94,7 +94,6 @@ SDPerspCamera::SDPerspCamera(SDView *myscreen, int id, int drawCurr, int drawDrv
|
|||
fogstart = myfogstart;
|
||||
fogend = myfogend;
|
||||
|
||||
|
||||
viewOffset = 0;
|
||||
spanOffset = 0;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,11 @@ void * getCars()
|
|||
return cars;
|
||||
}
|
||||
|
||||
void * getScenery()
|
||||
{
|
||||
return scenery;
|
||||
}
|
||||
|
||||
static osg::ref_ptr<osg::Group> m_sceneroot = NULL;
|
||||
static osg::ref_ptr<osg::Group> m_carroot = NULL;
|
||||
static osg::Timer m_timer;
|
||||
|
@ -368,8 +373,9 @@ int initTrack(tTrack *track)
|
|||
sceneroot = new osg::Group;
|
||||
m_sceneroot = new osg::Group;
|
||||
m_sceneroot->removeChildren(0, m_sceneroot->getNumChildren());
|
||||
sceneroot->addChild(scenery->LoadScene(track));
|
||||
m_sceneroot->addChild(render->Init(sceneroot, track));
|
||||
scenery->LoadScene(track);
|
||||
render->Init(track);
|
||||
m_sceneroot->addChild(render->getRoot());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -89,4 +89,6 @@ class SDFrameInfo
|
|||
void * getScreens();
|
||||
void * getRender();
|
||||
void * getCars();
|
||||
void * getScenery();
|
||||
|
||||
#endif /* _OSGMAIN_H_ */
|
||||
|
|
|
@ -39,9 +39,6 @@
|
|||
#include <glfeatures.h> //gluXXX
|
||||
#include <robottools.h> //RtXXX()
|
||||
|
||||
//static osg::ref_ptr<osg::Group> mRealRoot = new osg::Group;
|
||||
//static osg::ref_ptr<osg::Group> mRoot = new osg::Group;
|
||||
|
||||
SDSky *thesky = NULL;
|
||||
static tTrack *grTrack;
|
||||
|
||||
|
@ -59,8 +56,8 @@ static tTrack *grTrack;
|
|||
|
||||
SDRender::SDRender(void)
|
||||
{
|
||||
osg::Vec4 BaseSkyColor ( 0.31, 0.43, 0.69, 1.0 );
|
||||
osg::Vec4 BaseFogColor ( 0.84, 0.84, 1.0, 1.0 );
|
||||
BaseSkyColor = osg::Vec3f( 0.31f, 0.43f, 0.69f );
|
||||
BaseFogColor = osg::Vec3f( 0.84f, 0.84f, 1.0f );
|
||||
|
||||
SDSkyDomeDistance = 0;
|
||||
SDSkyDomeDistThresh = 12000;
|
||||
|
@ -76,11 +73,13 @@ SDRender::SDRender(void)
|
|||
NPlanets = 0;
|
||||
sol_angle = 0.0;
|
||||
moon_angle = 0.0;
|
||||
m_scene = NULL;
|
||||
}
|
||||
|
||||
SDRender::~SDRender(void)
|
||||
{
|
||||
delete thesky;
|
||||
m_scene = NULL;
|
||||
}
|
||||
|
||||
SDSky * SDRender::getSky()
|
||||
|
@ -94,7 +93,7 @@ SDSky * SDRender::getSky()
|
|||
*
|
||||
* @return 0 if OK, -1 if something failed
|
||||
*/
|
||||
osg::ref_ptr<osg::Node> SDRender::Init(osg::Group *m_sceneroot, tTrack *track)
|
||||
void SDRender::Init(tTrack *track)
|
||||
{
|
||||
char buf[256];
|
||||
//void *hndl = grTrackHandle;
|
||||
|
@ -155,7 +154,7 @@ osg::ref_ptr<osg::Node> SDRender::Init(osg::Group *m_sceneroot, tTrack *track)
|
|||
|
||||
GfLogInfo(" domeSizeRation : %d\n", domeSizeRatio);
|
||||
|
||||
thesky->build(datapath, SDSkyDomeDistance, SDSkyDomeDistance, 1000,
|
||||
thesky->build(datapath, SDSkyDomeDistance, SDSkyDomeDistance, 800,
|
||||
40000, 800, 30000, NPlanets,
|
||||
APlanetsData, NStars, AStarsData );
|
||||
GfOut("Build SKY\n");
|
||||
|
@ -186,8 +185,9 @@ osg::ref_ptr<osg::Node> SDRender::Init(osg::Group *m_sceneroot, tTrack *track)
|
|||
SDMoonDeclination, moonAscension);
|
||||
|
||||
// Initialize the whole sky dome.
|
||||
double r_WrldX = SDScenery::getWorldX();
|
||||
double r_WrldY = SDScenery::getWorldY();
|
||||
SDScenery * scenery = (SDScenery *)getScenery();
|
||||
double r_WrldX = scenery->getWorldX();
|
||||
double r_WrldY = scenery->getWorldY();
|
||||
//double r_WrldZ = SDScenery::getWorldZ();
|
||||
osg::Vec3 viewPos(r_WrldX / 2, r_WrldY/ 2, 0.0 );
|
||||
|
||||
|
@ -219,19 +219,19 @@ osg::ref_ptr<osg::Node> SDRender::Init(osg::Group *m_sceneroot, tTrack *track)
|
|||
thesky->repaint(SkyColor, FogColor, CloudsColor, sol_angle, moon_angle, NPlanets,
|
||||
APlanetsData, NStars, AStarsData);
|
||||
|
||||
osg::Group* sceneGroup = new osg::Group;
|
||||
osg::ref_ptr<osg::Group> sceneGroup = new osg::Group;
|
||||
osg::ref_ptr<osg::Group> mRoot = new osg::Group;
|
||||
sceneGroup->addChild(m_sceneroot);
|
||||
sceneGroup->addChild(scenery->getScene());
|
||||
//sceneGroup->setNodeMask(~simgear::BACKGROUND_BIT);
|
||||
osg::StateSet* stateSet = sceneGroup->getOrCreateStateSet();
|
||||
osg::ref_ptr<osg::StateSet> stateSet = sceneGroup->getOrCreateStateSet();
|
||||
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
|
||||
|
||||
osg::Material* material = new osg::Material;
|
||||
osg::ref_ptr<osg::Material> material = new osg::Material;
|
||||
material->setColorMode(osg::Material::OFF); // switch glColor usage off
|
||||
stateSet->setAttributeAndModes(material, osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
||||
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
||||
|
||||
osg::LightSource* lightSource = new osg::LightSource;
|
||||
osg::ref_ptr<osg::LightSource> lightSource = new osg::LightSource;
|
||||
lightSource->getLight()->setDataVariance(osg::Object::DYNAMIC);
|
||||
// relative because of CameraView being just a clever transform node
|
||||
lightSource->setReferenceFrame(osg::LightSource::RELATIVE_RF);
|
||||
|
@ -245,7 +245,7 @@ osg::ref_ptr<osg::Node> SDRender::Init(osg::Group *m_sceneroot, tTrack *track)
|
|||
//osg::LightSource lightSource = static_cast<osg::LightSource*>(mRoot);
|
||||
|
||||
// we need a white diffuse light for the phase of the moon
|
||||
osg::LightSource* sunLight = new osg::LightSource;
|
||||
osg::ref_ptr<osg::LightSource> sunLight = new osg::LightSource;
|
||||
sunLight->getLight()->setDataVariance(osg::Object::DYNAMIC);
|
||||
sunLight->getLight()->setLightNum(1);
|
||||
sunLight->setReferenceFrame(osg::LightSource::RELATIVE_RF);
|
||||
|
@ -261,14 +261,14 @@ osg::ref_ptr<osg::Node> SDRender::Init(osg::Group *m_sceneroot, tTrack *track)
|
|||
sunLight->getLight()->setPosition(position);
|
||||
sunLight->getLight()->setDirection(sun_direction);
|
||||
|
||||
osg::Group* skyGroup = new osg::Group;
|
||||
osg::StateSet* skySS = skyGroup->getOrCreateStateSet();
|
||||
osg::ref_ptr<osg::Group> skyGroup = new osg::Group;
|
||||
osg::ref_ptr<osg::StateSet> skySS = skyGroup->getOrCreateStateSet();
|
||||
skySS->setMode(GL_LIGHT0, osg::StateAttribute::OFF);
|
||||
skyGroup->addChild(thesky->getPreRoot());
|
||||
sunLight->addChild(skyGroup);
|
||||
mRoot->addChild(sceneGroup);
|
||||
sunLight->addChild(skyGroup.get());
|
||||
mRoot->addChild(sceneGroup.get());
|
||||
mRoot->setStateSet(setFogState().get());
|
||||
mRoot->addChild(sunLight);
|
||||
mRoot->addChild(sunLight.get());
|
||||
//mRoot->addChild(lightSource);
|
||||
|
||||
|
||||
|
@ -278,67 +278,61 @@ osg::ref_ptr<osg::Node> SDRender::Init(osg::Group *m_sceneroot, tTrack *track)
|
|||
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
|
||||
|
||||
m_scene = new osg::Group;
|
||||
m_scene->addChild(mRoot.get());
|
||||
|
||||
GfOut("LE POINTEUR %d\n",mRoot.get());
|
||||
|
||||
return mRoot.get();
|
||||
//return mRoot.get();
|
||||
}//SDRender::Init
|
||||
|
||||
void SDRender::UpdateLight( void )
|
||||
{
|
||||
sol_angle = (float)thesky->getSA();
|
||||
moon_angle = (float)thesky->getMA();
|
||||
float deg = sol_angle * SD_RADIANS_TO_DEGREES;
|
||||
float sky_brightness = (float)(1.0 + cos(sol_angle)) / 2.0f;
|
||||
|
||||
GfOut("Sun Angle in Render = %f - sky brightness = %f\n", sol_angle, sky_brightness);
|
||||
|
||||
|
||||
if (grTrack->local.rain > 0) // TODO: Different values for each rain strength value ?
|
||||
{
|
||||
BaseFogColor[0] = 0.42f;
|
||||
BaseFogColor[1] = 0.44f;
|
||||
BaseFogColor[2] = 0.50f;
|
||||
|
||||
BaseFogColor = osg::Vec3f(0.42f, 0.44f, 0.50f);
|
||||
sky_brightness = (float)pow(sky_brightness, 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseFogColor[0] = 0.84f;
|
||||
BaseFogColor[1] = 0.87f;
|
||||
BaseFogColor[2] = 1.00f;
|
||||
BaseFogColor = osg::Vec3f(0.84f, 0.87f, 1.00f);
|
||||
}
|
||||
|
||||
SkyColor[0] = BaseSkyColor[0] * sky_brightness;
|
||||
SkyColor[1] = BaseSkyColor[1] * sky_brightness;
|
||||
SkyColor[2] = BaseSkyColor[2] * sky_brightness;
|
||||
SkyColor[3] = BaseSkyColor[3];
|
||||
SkyColor = BaseSkyColor * sky_brightness;
|
||||
|
||||
UpdateFogColor(sol_angle);
|
||||
|
||||
sd_gamma_correct_rgb( SkyColor._v );
|
||||
|
||||
// 3a)cloud and fog color
|
||||
CloudsColor[0] = FogColor[0] = BaseFogColor[0] * sky_brightness;
|
||||
CloudsColor[1] = FogColor[1] = BaseFogColor[1] * sky_brightness;
|
||||
CloudsColor[2] = FogColor[2] = BaseFogColor[2] * sky_brightness;
|
||||
CloudsColor[3] = FogColor[3] = BaseFogColor[3];
|
||||
CloudsColor = FogColor = BaseFogColor * sky_brightness;
|
||||
|
||||
//grUpdateFogColor(sol_angle);
|
||||
sd_gamma_correct_rgb( CloudsColor._v );
|
||||
|
||||
|
||||
osg::Vec4f sun_color = thesky->get_sun_color();
|
||||
osg::Vec4f suncolor = thesky->get_sun_color();
|
||||
//osg::Vec3f sun_color = osg::Vec3f(suncolor._v[0], suncolor._v[1], suncolor._v[2]);
|
||||
osg::Vec3f sun_color = osg::Vec3f(0.7f, 0.7f, 0.7f); // For Test !!!
|
||||
GfOut("Sun Color in Render = %f R - %f V - %f B\n", sun_color._v[0], sun_color._v[1], sun_color._v[2]);
|
||||
|
||||
if (sol_angle > 1.0)
|
||||
{
|
||||
if (SDVisibility > 1000 /*&& cloudsTextureIndex < 8*/)
|
||||
{
|
||||
CloudsColor[0] = CloudsColor[0] * sun_color[0];
|
||||
CloudsColor[1] = CloudsColor[1] * sun_color[1];
|
||||
CloudsColor[2] = CloudsColor[2] * sun_color[2];
|
||||
CloudsColor = osg::componentMultiply(CloudsColor, sun_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
CloudsColor[0] = CloudsColor[0] * sun_color[0];
|
||||
CloudsColor[1] = CloudsColor[1] * sun_color[0];
|
||||
CloudsColor[2] = CloudsColor[2] * sun_color[0];
|
||||
CloudsColor = CloudsColor * sun_color[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,37 +345,20 @@ void SDRender::UpdateLight( void )
|
|||
// 3c) update scene colors.
|
||||
if (SDVisibility > 1000 /*&& cloudsTextureIndex < 8*/)
|
||||
{
|
||||
SceneAmbiant[0] = (sun_color[0]*0.25f + CloudsColor[0]*0.75f) * sky_brightness;
|
||||
SceneAmbiant[1] = (sun_color[1]*0.25f + CloudsColor[1]*0.75f) * sky_brightness;
|
||||
SceneAmbiant[2] = (sun_color[2]*0.25f + CloudsColor[2]*0.75f) * sky_brightness;
|
||||
SceneAmbiant[3] = 1.0;
|
||||
|
||||
SceneDiffuse[0] = (sun_color[0]*0.25f + FogColor[0]*0.75f) * sky_brightness;
|
||||
SceneDiffuse[1] = (sun_color[1]*0.25f + FogColor[1]*0.75f) * sky_brightness;
|
||||
SceneDiffuse[2] = (sun_color[2]*0.25f + FogColor[2]*0.75f) * sky_brightness;
|
||||
SceneDiffuse[3] = 1.0;
|
||||
|
||||
SceneSpecular[0] = sun_color[0] * sky_brightness;
|
||||
SceneSpecular[1] = sun_color[1] * sky_brightness;
|
||||
SceneSpecular[2] = sun_color[2] * sky_brightness;
|
||||
SceneSpecular[3] = 1.0;
|
||||
SceneAmbiant = osg::Vec4f((sun_color * 0.25f) + (CloudsColor * 0.75f) * sky_brightness, 1.0f);
|
||||
SceneDiffuse = osg::Vec4f((sun_color * 0.25f) + (FogColor * 0.75f) * sky_brightness, 1.0f);
|
||||
SceneSpecular = osg::Vec4f(sun_color * sky_brightness, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
SceneAmbiant[0] = (sun_color[0]*0.25f + CloudsColor[0]*0.75f) * sky_brightness;
|
||||
SceneAmbiant[1] = (sun_color[0]*0.25f + CloudsColor[1]*0.75f) * sky_brightness;
|
||||
SceneAmbiant[2] = (sun_color[0]*0.25f + CloudsColor[2]*0.75f) * sky_brightness;
|
||||
SceneAmbiant[3] = 1.0;
|
||||
|
||||
SceneDiffuse[0] = (sun_color[0]*0.25f + FogColor[0]*0.75f) * sky_brightness;
|
||||
SceneDiffuse[1] = (sun_color[0]*0.25f + FogColor[1]*0.75f) * sky_brightness;
|
||||
SceneDiffuse[2] = (sun_color[0]*0.25f + FogColor[2]*0.75f) * sky_brightness;
|
||||
SceneDiffuse[3] = 1.0;
|
||||
|
||||
SceneSpecular[0] = sun_color[0] * sky_brightness;
|
||||
SceneSpecular[1] = sun_color[0] * sky_brightness;
|
||||
SceneSpecular[2] = sun_color[0] * sky_brightness;
|
||||
SceneSpecular[3] = 1.0;
|
||||
SceneAmbiant = osg::Vec4f(((CloudsColor._v[0] * 0.75f) + (sun_color._v[0] * 0.25f)) * sky_brightness,
|
||||
((CloudsColor._v[1] * 0.75f) + (sun_color._v[0] * 0.25f)) * sky_brightness,
|
||||
((CloudsColor._v[2] * 0.75f) + (sun_color._v[0] * 0.25f)) * sky_brightness, 1.0f);
|
||||
SceneDiffuse = osg::Vec4f(((FogColor._v[0] * 0.75f) + (sun_color._v[0] * 0.25f)) * sky_brightness,
|
||||
((FogColor._v[1] * 0.75f) + (sun_color._v[0] * 0.25f)) * sky_brightness,
|
||||
((FogColor._v[2] * 0.75f) + (sun_color._v[0] * 0.25f)) * sky_brightness, 1.0f);
|
||||
SceneSpecular = osg::Vec4f(sun_color._v[0] * sky_brightness, sun_color._v[0] * sky_brightness,
|
||||
sun_color._v[0] * sky_brightness, 1.0f);
|
||||
}
|
||||
|
||||
}//grUpdateLight
|
||||
|
@ -391,10 +368,9 @@ osg::ref_ptr< osg::StateSet> SDRender::setFogState()
|
|||
static const double m_log01 = -log( 0.01 );
|
||||
static const double sqrt_m_log01 = sqrt( m_log01 );
|
||||
const GLfloat fog_exp2_density = sqrt_m_log01 / thesky->get_visibility();
|
||||
SceneFog[0] = FogColor[0];
|
||||
SceneFog[1] = FogColor[1];
|
||||
SceneFog[2] = FogColor[2];
|
||||
SceneFog[3] = 1.0f;
|
||||
|
||||
SceneFog = osg::Vec4f(FogColor, 1.0f);
|
||||
|
||||
osg::ref_ptr<osg::Fog> fog = new osg::Fog(); //The fog object
|
||||
fog->setMode(osg::Fog::EXP2); //Fog type
|
||||
fog->setDensity(fog_exp2_density); //Fog density
|
||||
|
@ -434,9 +410,9 @@ void SDRender::UpdateFogColor(double sol_angle)
|
|||
// Calculate the fog color in the direction of the sun for
|
||||
// sunrise/sunset effects.
|
||||
//
|
||||
float s_red = (BaseFogColor[0] + 2 * sun_color[0] * sun_color[0]) / 3;
|
||||
float s_green = (BaseFogColor[1] + 2 * sun_color[1] * sun_color[1]) / 3;
|
||||
float s_blue = (BaseFogColor[2] + 2 * sun_color[2] * sun_color[2]) / 3;
|
||||
float s_red = (BaseFogColor._v[0] + 2 * sun_color._v[0] * sun_color._v[0]) / 3;
|
||||
float s_green = (BaseFogColor._v[1] + 2 * sun_color._v[1] * sun_color._v[1]) / 3;
|
||||
float s_blue = (BaseFogColor._v[2] + 2 * sun_color._v[2] * sun_color._v[2]) / 3;
|
||||
|
||||
// interpolate beween the sunrise/sunset color and the color
|
||||
// at the opposite direction of this effect. Take in account
|
||||
|
@ -456,9 +432,9 @@ void SDRender::UpdateFogColor(double sol_angle)
|
|||
float rf2 = avf * pow(rf1 * rf1, 1 /sif);
|
||||
float rf3 = 0.94 - rf2;
|
||||
|
||||
FogColor[0] = rf3 * BaseFogColor[0] + rf2 * s_red;
|
||||
FogColor[1] = rf3 * BaseFogColor[1] + rf2 * s_green;
|
||||
FogColor[2] = rf3 * BaseFogColor[2] + rf2 * s_blue;
|
||||
FogColor._v[0] = rf3 * BaseFogColor._v[0] + rf2 * s_red;
|
||||
FogColor._v[1] = rf3 * BaseFogColor._v[1] + rf2 * s_green;
|
||||
FogColor._v[2] = rf3 * BaseFogColor._v[2] + rf2 * s_blue;
|
||||
sd_gamma_correct_rgb( FogColor._v );
|
||||
|
||||
// make sure the colors have their original value before they are being
|
||||
|
|
|
@ -26,16 +26,17 @@
|
|||
#include <raceman.h> // tSituation
|
||||
|
||||
class SDSky;
|
||||
class SDScenery;
|
||||
|
||||
class SDRender
|
||||
{
|
||||
private:
|
||||
osg::ref_ptr<osg::Group> m_sceneroot;
|
||||
osg::ref_ptr<osg::Group> m_scene;
|
||||
//osg::ref_ptr<osg::Group> m_carroot;
|
||||
|
||||
|
||||
const osg::Vec4 BaseSkyColor;
|
||||
osg::Vec4 BaseFogColor;
|
||||
osg::Vec3f BaseSkyColor;
|
||||
osg::Vec3f BaseFogColor;
|
||||
osg::Vec3f SkyColor;
|
||||
osg::Vec3f FogColor;
|
||||
osg::Vec3f CloudsColor;
|
||||
|
@ -66,7 +67,7 @@ public:
|
|||
SDRender(void);
|
||||
~SDRender(void);
|
||||
|
||||
osg::ref_ptr<osg::Node> Init(osg::Group* root, tTrack *track);
|
||||
void Init(tTrack *track);
|
||||
osg::ref_ptr< osg::StateSet> setFogState();
|
||||
void Update(float speedcar, tSituation *s);
|
||||
void UpdateTime(tSituation *s);
|
||||
|
@ -74,6 +75,7 @@ public:
|
|||
void UpdateFogColor(double angle);
|
||||
|
||||
SDSky * getSky();
|
||||
osg::Node* getRoot() { return m_scene.get(); }
|
||||
};
|
||||
|
||||
#endif //_OSGRENDER_H_
|
||||
|
|
|
@ -71,7 +71,7 @@ SDScenery::~SDScenery(void)
|
|||
_scenery = NULL;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Node> SDScenery::LoadScene(tTrack *track)
|
||||
void SDScenery::LoadScene(tTrack *track)
|
||||
{
|
||||
void *hndl = grTrackHandle;
|
||||
const char *acname;
|
||||
|
@ -165,13 +165,10 @@ osg::ref_ptr<osg::Node> SDScenery::LoadScene(tTrack *track)
|
|||
rot->setMatrix(mat);
|
||||
rot->addChild(pTrack);
|
||||
_scenery->addChild(rot);
|
||||
return _scenery;
|
||||
}
|
||||
|
||||
_scenery->addChild(pTrack);
|
||||
_scenery->addChild(pTrack.get());
|
||||
}
|
||||
|
||||
return _scenery;
|
||||
}
|
||||
|
||||
void SDScenery::LoadSkyOptions()
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
/* Destructor */
|
||||
~SDScenery(void);
|
||||
|
||||
osg::ref_ptr<osg::Node> LoadScene(tTrack *track);
|
||||
void LoadScene(tTrack *track);
|
||||
void CreatePit(tTrack *track);
|
||||
//void addSpectators(SDSpectators->build(number, tTrack *track));
|
||||
//void addTrees(SDTrees->build(tTrack *track));
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
inline static int getWorldZ(){return grWrldZ;}
|
||||
inline static int getWorldMaxSize(){return grWrldMaxSize;}
|
||||
|
||||
//osg::Node* getPreRoot() { return pre_root.get(); }
|
||||
osg::Node* getScene() { return _scenery.get(); }
|
||||
|
||||
//osg::ref_ptr<osg::Group> getSDScenery { return _scenery };
|
||||
//osg::Group getSDBackground { return SDBackground->getbackground; }
|
||||
|
|
|
@ -39,7 +39,6 @@ SDSun::SDSun( void ) :
|
|||
visibility(-9999.0), prev_sun_angle(-9999.0), path_distance(60000.0),
|
||||
sun_exp2_punch_through(7.0e-06)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
@ -83,12 +82,12 @@ osg::Node* SDSun::build( std::string path, double dist, double sun_size )
|
|||
|
||||
sun_dist = dist;
|
||||
|
||||
osg::Node* sun = SDMakeSphere(sun_size, 15, 15);
|
||||
stateSet = sun->getOrCreateStateSet();
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
stateSet = geode->getOrCreateStateSet();
|
||||
|
||||
stateSet->setRenderBinDetails(-6, "RenderBin");
|
||||
|
||||
path = TmpPath+"data/textures/sun.png";
|
||||
path = TmpPath+"data/textures/inner_halo.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);
|
||||
|
@ -99,10 +98,32 @@ osg::Node* SDSun::build( std::string path, double dist, double sun_size )
|
|||
scene_cl = new osg::Vec4Array;
|
||||
scene_cl->push_back(osg::Vec4(1, 1, 1, 1));
|
||||
|
||||
sun_transform->addChild( sun );
|
||||
osg::Vec3Array* sun_vl = new osg::Vec3Array;
|
||||
sun_vl->push_back(osg::Vec3(-sun_size, 0, -sun_size));
|
||||
sun_vl->push_back(osg::Vec3(sun_size, 0, -sun_size));
|
||||
sun_vl->push_back(osg::Vec3(-sun_size, 0, sun_size));
|
||||
sun_vl->push_back(osg::Vec3(sun_size, 0, sun_size));
|
||||
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
stateSet = geode->getOrCreateStateSet();
|
||||
osg::Vec2Array* sun_tl = new osg::Vec2Array;
|
||||
sun_tl->push_back(osg::Vec2(0, 0));
|
||||
sun_tl->push_back(osg::Vec2(1, 0));
|
||||
sun_tl->push_back(osg::Vec2(0, 1));
|
||||
sun_tl->push_back(osg::Vec2(1, 1));
|
||||
|
||||
osg::Geometry* geometry = new osg::Geometry;
|
||||
geometry->setUseDisplayList(false);
|
||||
geometry->setVertexArray(sun_vl);
|
||||
geometry->setColorArray(sun_cl.get());
|
||||
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geometry->setNormalBinding(osg::Geometry::BIND_OFF);
|
||||
geometry->setTexCoordArray(0, sun_tl);
|
||||
geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||
geode->addDrawable(geometry);
|
||||
|
||||
sun_transform->addChild( geode );
|
||||
|
||||
osg::Geode* geode1 = new osg::Geode;
|
||||
stateSet = geode1->getOrCreateStateSet();
|
||||
stateSet->setRenderBinDetails(-7, "RenderBin");
|
||||
|
||||
path = TmpPath+"data/textures/inner_halo.png";
|
||||
|
@ -126,7 +147,7 @@ osg::Node* SDSun::build( std::string path, double dist, double sun_size )
|
|||
ihalo_tl->push_back(osg::Vec2(0, 1));
|
||||
ihalo_tl->push_back(osg::Vec2(1, 1));
|
||||
|
||||
osg::Geometry* geometry = new osg::Geometry;
|
||||
geometry = new osg::Geometry;
|
||||
geometry->setUseDisplayList(false);
|
||||
geometry->setVertexArray(ihalo_vl);
|
||||
geometry->setColorArray(ihalo_cl.get());
|
||||
|
@ -136,7 +157,7 @@ osg::Node* SDSun::build( std::string path, double dist, double sun_size )
|
|||
geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||
geode->addDrawable(geometry);
|
||||
|
||||
sun_transform->addChild( geode );
|
||||
sun_transform->addChild( geode1 );
|
||||
|
||||
osg::Geode* geode2 = new osg::Geode;
|
||||
stateSet = geode2->getOrCreateStateSet();
|
||||
|
|
Loading…
Reference in a new issue