- fix bug with srw-sector-p4 loaded wings

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

Former-commit-id: 9f4b96f112dd2cd466fdf22779e34a863ac56ccd
Former-commit-id: 8022443f05a2f582461260002bc800ec7b5ff0f5
This commit is contained in:
torcs-ng 2015-09-23 00:14:37 +00:00
parent dcc98ceb90
commit 22aed795ed
3 changed files with 21 additions and 20 deletions

View file

@ -270,23 +270,15 @@ osg::ref_ptr<osg::Node> SDCar::loadCar(tCarElt *car, bool tracktype, bool subcat
// Add the rearwings
for (int i = 1; i < nranges; i++)
{
osg::ref_ptr<osg::Node> pWing1 = new osg::Node;
osg::ref_ptr<osg::MatrixTransform> position = new osg::MatrixTransform;
osg::ref_ptr<osg::Node> pWing1_branch = new osg::Node;
snprintf(path, nMaxTexPathSize, "%s/%s/%d", SECT_GROBJECTS, LST_REARWING, i);
param = GfParmGetStr(handle, path, PRM_REARWINGMODEL, "");
strPath = tmp+param;
pWing1_branch = loader.Load3dFile(strPath, true);
GfLogInfo("Loading Wing animate %i - %s !\n", i, strPath.c_str());
tdble xpos = GfParmGetNum(handle, path, PRM_XPOS, NULL, 0.0);
tdble ypos = GfParmGetNum(handle, path, PRM_YPOS, NULL, 0.0);
tdble zpos = GfParmGetNum(handle, path, PRM_ZPOS, NULL, 0.0);
osg::Matrix pos = osg::Matrix::translate(xpos, ypos, zpos);
pWing1 = loader.Load3dFile(strPath, true);
position->addChild(pWing1.get());
pWing3->addChild(position.get());
pWing3->addChild(pWing1_branch.get());
strPath ="";
}
@ -414,6 +406,8 @@ osg::ref_ptr<osg::Node> SDCar::loadCar(tCarElt *car, bool tracktype, bool subcat
tdble zpos = GfParmGetNum(handle, buf, PRM_ZPOS, NULL, 0.0);
osg::Matrix pos = osg::Matrix::translate(xpos, ypos, zpos);
position->setMatrix(pos);
driver_path = tmp+param;
driver_branch = loader.Load3dFile(driver_path, true);
GfLogInfo("Loading Animated Driver %i - %s \n", i, driver_path.c_str());
@ -434,12 +428,14 @@ osg::ref_ptr<osg::Node> SDCar::loadCar(tCarElt *car, bool tracktype, bool subcat
#endif
}
gCar->addChild(pWing.get());
gCar->addChild(pWing3.get());
gCar->addChild(pCar.get());
gCar->addChild(pDriver.get());
gCar->addChild(pSteer.get());
if(_wing1)
gCar->addChild(pWing.get());
if(_wing3)
gCar->addChild(pWing3.get());
#else
osg::ref_ptr<osg::Group> gCar = new osg::Group;

View file

@ -54,14 +54,17 @@ osg::Node *osgLoader::Load3dFile(std::string strFile, bool car)
{
osg::Node *pNode = NULL;
std::string ext = osgDB::getFileExtension(strFile);
if (car)
m_ACCReader.SetCar(true);
/*if (car)
m_ACCReader2.SetCar(true);*/
if (ext == "acc")
{
/*if(car)
osgDB::ReaderWriter::ReadResult rr = m_ACCReader2.readNode(strFile, m_pOpt);
else*/
//Use custom ACC file loader
osgDB::ReaderWriter::ReadResult rr = m_ACCReader.readNode(strFile, m_pOpt);
GfOut("le test %d \n", rr.validNode());
GfOut("Object ACC load = %s - %d \n", strFile.c_str(), rr.validNode());
if (rr.validNode())
{
osg::Node *nod = rr.takeNode();

View file

@ -20,6 +20,7 @@
#include <osgDB/ReadFile>
#include "ReaderWriterACC.h"
//#include "ReaderWriterACC2.h"
class osgLoader
{
@ -34,4 +35,5 @@ public:
protected:
osg::ref_ptr<osgDB::ReaderWriter::Options> m_pOpt;
ReaderWriterACC m_ACCReader;
//ReaderWriterACC2 m_ACCReader2;
};