fix segmentation fault on m_sceneroot
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5010 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 68edd707652540aea88a2ccfb0c42166d0dd9661 Former-commit-id: 6eb0b128f25717c4ee3121cc3a58c39f7c02dcc4
This commit is contained in:
parent
d2d59b1f78
commit
583453ec33
2 changed files with 21 additions and 9 deletions
|
@ -70,7 +70,7 @@ osg::Node *Load3dFile(std::string strFile);
|
||||||
bool LoadTrack(std::string strTrack);
|
bool LoadTrack(std::string strTrack);
|
||||||
|
|
||||||
std::string m_strTexturePath;
|
std::string m_strTexturePath;
|
||||||
osg::ref_ptr<osg::MatrixTransform> m_sceneroot;
|
osg::ref_ptr<osg::Group> m_sceneroot;
|
||||||
osg::ref_ptr<osg::Group> m_carroot;
|
osg::ref_ptr<osg::Group> m_carroot;
|
||||||
osg::ref_ptr<osgViewer::Viewer> m_sceneViewer;
|
osg::ref_ptr<osgViewer::Viewer> m_sceneViewer;
|
||||||
osg::Timer m_timer;
|
osg::Timer m_timer;
|
||||||
|
@ -172,10 +172,21 @@ void setViewer(osg::ref_ptr<osgViewer::Viewer> msV)
|
||||||
m_sceneViewer = msV;
|
m_sceneViewer = msV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setSceneRoot(osg::ref_ptr<osg::Group> root)
|
||||||
|
{
|
||||||
|
m_sceneroot = root;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClearScene(void)
|
||||||
|
{
|
||||||
|
m_sceneroot->removeChildren(0, m_sceneroot->getNumChildren());
|
||||||
|
}
|
||||||
|
|
||||||
bool LoadTrack(std::string strTrack)
|
bool LoadTrack(std::string strTrack)
|
||||||
{
|
{
|
||||||
GfOut("Chemin Track : %s\n", strTrack.c_str());
|
GfOut("Chemin Track : %s\n", strTrack.c_str());
|
||||||
osgLoader loader;
|
osgLoader loader;
|
||||||
|
//osg::ref_ptr<osg::Group> m_sceneroot = new osg::Group;
|
||||||
loader.AddSearchPath(m_strTexturePath);
|
loader.AddSearchPath(m_strTexturePath);
|
||||||
osg::Node *pTrack = loader.Load3dFile(strTrack);
|
osg::Node *pTrack = loader.Load3dFile(strTrack);
|
||||||
|
|
||||||
|
@ -220,6 +231,8 @@ grLoadScene(tTrack *track)
|
||||||
const char *acname;
|
const char *acname;
|
||||||
|
|
||||||
grTrack = track;
|
grTrack = track;
|
||||||
|
osg::ref_ptr<osg::Group> m_sceneroot = new osg::Group;
|
||||||
|
setSceneRoot(m_sceneroot);
|
||||||
//ssgEntity *desc;
|
//ssgEntity *desc;
|
||||||
|
|
||||||
/*if (maxTextureUnits == 0) {
|
/*if (maxTextureUnits == 0) {
|
||||||
|
@ -249,25 +262,20 @@ grLoadScene(tTrack *track)
|
||||||
|
|
||||||
std::string strTPath = GetDataDir();
|
std::string strTPath = GetDataDir();
|
||||||
sprintf(buf, "tracks/%s/%s;data/textures;data/img;.", grTrack->category, grTrack->internalname);
|
sprintf(buf, "tracks/%s/%s;data/textures;data/img;.", grTrack->category, grTrack->internalname);
|
||||||
//GfOut("strPath = %s\n", acname);
|
|
||||||
strTPath+=buf;
|
strTPath+=buf;
|
||||||
//strTPath+="tracks/speedway/milky-five";
|
|
||||||
SetTexturePaths(strTPath.c_str());
|
SetTexturePaths(strTPath.c_str());
|
||||||
|
|
||||||
//ssgTexturePath(buf);
|
|
||||||
//sprintf(buf, "tracks/%s/%s", grTrack->category, grTrack->internalname);
|
|
||||||
//ssgModelPath(buf);
|
|
||||||
|
|
||||||
std::string strPath = GetDataDir();
|
std::string strPath = GetDataDir();
|
||||||
sprintf(buf, "tracks/%s/%s", grTrack->category, grTrack->internalname);
|
sprintf(buf, "tracks/%s/%s", grTrack->category, grTrack->internalname);
|
||||||
strPath+=buf;
|
strPath+=buf;
|
||||||
//strPath+="tracks/speedway/milky-five";
|
|
||||||
strPath+="/";
|
strPath+="/";
|
||||||
strPath+=acname;
|
strPath+=acname;
|
||||||
//GetOSG()->ClearScene();
|
//ClearScene();
|
||||||
//osgBackground back;
|
//osgBackground back;
|
||||||
//GetOSG()->SetBackGround(back.CreateBackground(grTrack));
|
//GetOSG()->SetBackGround(back.CreateBackground(grTrack));
|
||||||
LoadTrack(strPath);
|
LoadTrack(strPath);
|
||||||
|
|
||||||
|
//GfOut("Track = %d\n", m_sceneroot);
|
||||||
//desc = grssgLoadAC3D(acname, NULL);
|
//desc = grssgLoadAC3D(acname, NULL);
|
||||||
//LandAnchor->addKid(desc);
|
//LandAnchor->addKid(desc);
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ extern int grWrldZ;
|
||||||
extern int grWrldMaxSize;
|
extern int grWrldMaxSize;
|
||||||
extern tTrack *grTrack;
|
extern tTrack *grTrack;
|
||||||
|
|
||||||
|
//extern osg::ref_ptr<osg::Group> m_sceneroot;
|
||||||
|
extern osg::ref_ptr<osg::Group> m_carroot;
|
||||||
/*extern ssgRoot *TheScene;
|
/*extern ssgRoot *TheScene;
|
||||||
extern ssgBranch *SunAnchor;
|
extern ssgBranch *SunAnchor;
|
||||||
extern ssgBranch *LandAnchor;
|
extern ssgBranch *LandAnchor;
|
||||||
|
@ -75,6 +77,8 @@ extern void grCustomizePits(void);
|
||||||
//extern void grDrawBackground(class cGrCamera *, class cGrBackgroundCam *bgCam);
|
//extern void grDrawBackground(class cGrCamera *, class cGrBackgroundCam *bgCam);
|
||||||
extern void grUpdateTime(tSituation *s);
|
extern void grUpdateTime(tSituation *s);
|
||||||
extern void setViewer(osg::ref_ptr<osgViewer::Viewer> msV);
|
extern void setViewer(osg::ref_ptr<osgViewer::Viewer> msV);
|
||||||
|
extern void ClearScene(void);
|
||||||
|
extern void setSceneRoot(osg::ref_ptr<osg::Group> root);
|
||||||
|
|
||||||
//TODO: What is this??? kilo
|
//TODO: What is this??? kilo
|
||||||
#ifdef GUIONS
|
#ifdef GUIONS
|
||||||
|
|
Loading…
Reference in a new issue