- fix bug with background on OsgGraph on long tracks as longday or nordschleife
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6715 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: fcb14d635b1da36759db083ba69e06ce5b0403ca Former-commit-id: d84a4c1c9ac1b9a6c687868218dffcdd770aa4ce
This commit is contained in:
parent
ed1c036534
commit
ad46563503
5 changed files with 48 additions and 19 deletions
|
@ -45,6 +45,7 @@ SDCars *cars = 0;
|
|||
SDScenery *scenery = 0;
|
||||
SDRender *render = 0;
|
||||
SDScreens *screens = 0;
|
||||
SDCamera *cam = 0;
|
||||
|
||||
SDHUD hud;
|
||||
|
||||
|
@ -220,6 +221,12 @@ int refresh(tSituation *s)
|
|||
}
|
||||
|
||||
cars->updateCars();
|
||||
cam = screens->getActiveView()->getCameras()->getSelectedCamera();
|
||||
osg::Vec3d eye = cam->getCameraPosition();
|
||||
double X = eye[0];
|
||||
double Y = eye[1];
|
||||
double Z = eye[2];
|
||||
scenery->reposition(X, Y, Z );
|
||||
render->UpdateSky(s->currentTime, s->accelTime);
|
||||
screens->update(s, &frameInfo);
|
||||
|
||||
|
@ -260,6 +267,7 @@ int initTrack(tTrack *track)
|
|||
|
||||
scenery = new SDScenery;
|
||||
render = new SDRender;
|
||||
//cam = new SDCamera;
|
||||
|
||||
scenery->LoadScene(track);
|
||||
render->Init(track);
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
#include "OsgScenery.h"
|
||||
|
||||
SDBackground::SDBackground(void) :
|
||||
_background(NULL)
|
||||
_background(NULL),
|
||||
_backgroundTransform(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -38,7 +39,7 @@ SDBackground::~SDBackground(void)
|
|||
}
|
||||
}
|
||||
|
||||
void SDBackground::build(bool type, int grWrldX, int grWrldY, int grWrldZ, const std::string& TrackPath)
|
||||
void SDBackground::build(bool type, int X, int Y, int Z, const std::string& TrackPath)
|
||||
{
|
||||
bool land = type;
|
||||
osgDB::Registry::instance()->clearObjectCache();
|
||||
|
@ -52,31 +53,43 @@ void SDBackground::build(bool type, int grWrldX, int grWrldY, int grWrldZ, const
|
|||
pathList.push_front(TrackPath);
|
||||
osgDB::Registry::instance()->setDataFilePathList(pathList);
|
||||
|
||||
osg::ref_ptr<osg::MatrixTransform> _background_transform = new osg::MatrixTransform;
|
||||
//osg::ref_ptr<osg::MatrixTransform> _background_transform = new osg::MatrixTransform;
|
||||
osg::Matrix mat( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
_backgroundTransform = new osg::MatrixTransform;
|
||||
|
||||
if (!land)
|
||||
{
|
||||
osg::ref_ptr<osg::Node> m_background = osgDB::readNodeFile("background-sky.ac");
|
||||
//_background_transform->setMatrix(mat);
|
||||
osg::Matrix t = osg::Matrix::translate(grWrldX /2, grWrldY /2, grWrldZ /2);
|
||||
mat = mat * t;
|
||||
_background_transform->setMatrix(mat);
|
||||
_background_transform->addChild( m_background.get() );
|
||||
_backgroundTransform->setMatrix(mat);
|
||||
_backgroundTransform->addChild( m_background.get() );
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::ref_ptr<osg::Node> m_background = osgDB::readNodeFile("land.ac");
|
||||
_background_transform->setMatrix(mat);
|
||||
_background_transform->addChild( m_background.get() );
|
||||
_backgroundTransform->setMatrix(mat);
|
||||
_backgroundTransform->addChild( m_background.get() );
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::StateSet> bgstate = _background_transform->getOrCreateStateSet();
|
||||
osg::ref_ptr<osg::StateSet> bgstate = _backgroundTransform->getOrCreateStateSet();
|
||||
bgstate->setRenderBinDetails(-1, "RenderBin");
|
||||
bgstate->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||
bgstate->setMode(GL_FOG, osg::StateAttribute::ON);
|
||||
|
||||
_background = new osg::Group;
|
||||
_background->addChild(_background_transform.get());
|
||||
_background->addChild(_backgroundTransform.get());
|
||||
}
|
||||
|
||||
void SDBackground::reposition(double X, double Y, double Z)
|
||||
{
|
||||
osg::Matrix T;
|
||||
osg::Matrix mat(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
T.makeTranslate(X, Y, Z);
|
||||
|
||||
_backgroundTransform->setMatrix(mat * T);
|
||||
}
|
||||
|
|
|
@ -250,6 +250,11 @@ bool SDScenery::LoadTrack(std::string& strTrack)
|
|||
return true;
|
||||
}
|
||||
|
||||
void SDScenery::reposition(double X, double Y, double Z)
|
||||
{
|
||||
m_background->reposition(X, Y, getWorldZ() / 2);
|
||||
}
|
||||
|
||||
void CreatePit(tTrack *track)
|
||||
{
|
||||
/*char buf[512];
|
||||
|
|
|
@ -38,7 +38,8 @@ class osgLoader;
|
|||
|
||||
class SDBackground
|
||||
{
|
||||
osg::ref_ptr<osg::Group> _background;
|
||||
osg::ref_ptr<osg::Group> _background;
|
||||
osg::ref_ptr < osg::MatrixTransform> _backgroundTransform;
|
||||
|
||||
bool _type;
|
||||
|
||||
|
@ -50,7 +51,7 @@ public:
|
|||
~SDBackground(void);
|
||||
|
||||
void build(bool type, int X, int Y, int Z, const std::string& strTrack);
|
||||
void reposition(int X, int Y);
|
||||
void reposition(double X, double Y, double Z);
|
||||
|
||||
osg::ref_ptr<osg::Group> getBackground() { return _background.get(); }
|
||||
};
|
||||
|
@ -89,10 +90,10 @@ public:
|
|||
osg::ref_ptr<osg::Group> getTrackLight() { return _osgtracklight.get(); }
|
||||
};*/
|
||||
|
||||
static int grWrldX=0;
|
||||
static int grWrldY=0;
|
||||
static int grWrldZ = 0;
|
||||
static int grWrldMaxSize=0;
|
||||
static double grWrldX = 0.0;
|
||||
static double grWrldY = 0.0;
|
||||
static double grWrldZ = 0.0;
|
||||
static double grWrldMaxSize = 0.0;
|
||||
|
||||
class SDScenery
|
||||
{
|
||||
|
@ -132,11 +133,12 @@ public:
|
|||
|
||||
void LoadScene(tTrack *track);
|
||||
void ShutdownScene(void);
|
||||
void reposition(double X, double Y, double Z);
|
||||
|
||||
inline static int getWorldX(){return grWrldX;}
|
||||
inline static int getWorldY(){return grWrldY;}
|
||||
inline static int getWorldZ(){return grWrldZ;}
|
||||
inline static int getWorldMaxSize(){return grWrldMaxSize;}
|
||||
inline static double getWorldX(){return grWrldX;}
|
||||
inline static double getWorldY(){return grWrldY;}
|
||||
inline static double getWorldZ(){return grWrldZ;}
|
||||
inline static double getWorldMaxSize(){return grWrldMaxSize;}
|
||||
bool getSpeedWay() { return _speedWay; }
|
||||
bool getSpeedWayLong() { return _speedWayLong; }
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ Camera * SDCamera::getGenericCamera()
|
|||
c->Posv = &eye._v;
|
||||
c->Upv = &up._v;
|
||||
c->Speedv = &speed._v;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue