update class SDBackground

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5054 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 195bbc99533ae234fd5cf1f1db7bde970cc558e2
Former-commit-id: 2220f2eb1f9bdf689614768b572bbe38ae1ee0d5
This commit is contained in:
torcs-ng 2012-11-25 23:00:22 +00:00
parent 998a1fb8bd
commit 23ff26e3a5
3 changed files with 33 additions and 31 deletions

View file

@ -18,28 +18,25 @@
***************************************************************************/
#include <osg/MatrixTransform>
//#include <osg/Node>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgDB/Registry>
#include "OsgBackground.h"
#include "OsgScenery.h"
SDBackground::SDBackground(void)
{
type = 0;
sceneX = 0;
sceneY = 0;
m_background = new osg::Group;
}
SDBackground::~SDBackground(void)
{
}
osg::Node *SDBackground::build(int type, int grWrldX, int grWrldY, const std::string TrackPath)
osg::Node *SDBackground::build(bool type, int grWrldX, int grWrldY, const std::string TrackPath)
{
sceneX = grWrldX;
sceneY = grWrldY;
_sceneX = grWrldX;
_sceneY = grWrldY;
int land = type;
std::string strTmpPath = GetDataDir();
@ -47,11 +44,13 @@ osg::Node *SDBackground::build(int type, int grWrldX, int grWrldY, const std::st
strPath = strPath+strTmpPath+"data/textures";
strPath = strPath+TrackPath;
m_background = osgDB::readNodeFile(strPath);
osg::Node *m_background = osgDB::readNodeFile(strPath);
if (!type)
{
pre_transform = new osg::MatrixTransform;
_background_transform = new osg::MatrixTransform;
_background_transform->addChild( m_background );
}
}

View file

@ -26,7 +26,7 @@
#include <osg/LightSource>
#include <osg/Camera>
#include "OsgLoader.h"
//#include "OsgLoader.h"
#include "OsgMain.h"
#include "OsgScenery.h"
@ -46,8 +46,8 @@ SDScenery::SDScenery(void)
_bgtype = false;
_scenery = 0;
_background = 0;
_scenery = new osg::Group;
_background = new osg::Group;
//_spectators = 0;
//_trees = 0;
//_pits = 0;
@ -65,6 +65,7 @@ void SDScenery::LoadScene(tTrack *track)
{
void *hndl = grTrackHandle;
const char *acname;
char buf[256];
m_background = new SDBackground;
_scenery = new osg::Group;
@ -98,9 +99,6 @@ void SDScenery::LoadScene(tTrack *track)
std::string PathTmp = GetDataDir();
//filePathList.push_back(path_list[i]);
std::string PathTmp = GetDataDir();
//filePathList.push_back(path_list[i]);
if (grSkyDomeDistance > 0 && grTrack->skyversion > 0)
{
grBGSky = strcmp(GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKY, GR_ATT_BGSKY_DISABLED), GR_ATT_BGSKY_ENABLED) == 0;
@ -110,7 +108,7 @@ void SDScenery::LoadScene(tTrack *track)
std::string strPath = PathTmp;
sprintf(buf, "tracks/%s/%s", grTrack->category, grTrack->internalname);
strPath += buf;
_scenery = addkid(m_background->buid(grBGType, _grWrldX, _grWrldY, strPath));
_scenery->addChild(m_background->buid(grBGType, _grWrldX, _grWrldY, strPath));
}
}
@ -200,4 +198,4 @@ void SDScenery::ShutdownScene(void)
void SDScenery::SetTexturePaths(const char *pszPath)
{
m_strTexturePath = pszPath;
}
}

View file

@ -26,7 +26,6 @@
#include <raceman.h> // tSituation
#include "OsgLoader.h"
#include "OsgBackground.h"
class SDBackground;
//class SDSpectators;
@ -38,19 +37,23 @@ class SDScenery;
class SDBackground
{
private:
osg::ref_ptr<osg::Group> _background;
osg::MatrixTransform _background_transform;
osg::ref_ptr<osg::MatrixTransform> _background_transform;
double _centerX;
double _centerY;
double _sceneX;
double _sceneY;
bool _type;
public:
void SDBackground(void);
void ~SDBackground(void);
void build(bool type, int X, int Y, tTrack *track);
void reposition(_centerX, _centerY);
public:
// Constructor
SDBackground(void);
// Destructor
~SDBackground(void);
osg::Node *build(bool type, int X, int Y, const std::string strTrack);
void reposition(int X, int Y);
};
/*class SDSpectators
@ -88,6 +91,7 @@ private:
//SDSpectators *m_spectators;
//SDTrees *m_trees;
osg::ref_ptr<osg::Group> _scenery;
osg::ref_ptr<osg::Group> _background;
int _grWrldX;
int _grWrldY;
@ -119,17 +123,18 @@ public:
/* Destructor */
~SDScenery(void);
int LoadScene(tTrack *track);
void LoadScene(tTrack *track);
void CreatePit(tTrack *track);
//void addSpectators(SDSpectators->build(number, tTrack *track));
//void addTrees(SDTrees->build(tTrack *track));
void ShutdownScene(void);
//void
//osg::Node* getPreRoot() { return pre_root.get(); }
//osg::ref_ptr<osg::Group> getSDScenery { return _scenery };
//osg::Group getSDBackground { return SDBackground->getbackground; }
osg::Group getSceneroot { return _scenery; }
osg::Node* getSceneroot() { return _scenery.get(); }
};
#endif //_OSGSCENERY_H_