fix load3Dfile for cars & added directory drivers for skins
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5046 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 0e8b9b36d512163098755440f90ed1a2f75f6602 Former-commit-id: d9d6e2983feb7a3135fb5b658b763a46d5950f7e
This commit is contained in:
parent
d7b9f73927
commit
ba3edc6e83
6 changed files with 45 additions and 44 deletions
|
@ -40,6 +40,9 @@ osg::ref_ptr<osg::Node> SDCar::loadCar(tCarElt *car)
|
|||
const char *param;
|
||||
int lg;
|
||||
char path[256];
|
||||
|
||||
strncpy(car->_masterModel, GfParmGetStr(car->_carHandle, SECT_GROBJECTS, PRM_TEMPLATE, ""), MAX_NAME_LEN - 1);
|
||||
car->_masterModel[MAX_NAME_LEN - 1] = 0;
|
||||
// grssgLoaderOptions options;
|
||||
// sgVec3 lightPos;
|
||||
// int lightNum;
|
||||
|
@ -62,7 +65,7 @@ osg::ref_ptr<osg::Node> SDCar::loadCar(tCarElt *car)
|
|||
const bool bMasterModel = strlen(car->_masterModel) != 0;
|
||||
|
||||
GfOut("[gr] Init(%d) car %s for driver %s index %d\n", index, car->_carName, car->_modName, car->_driverIndex);
|
||||
|
||||
GfOut("[gr] Init(%d) car %s MasterModel name\n", index, car->_masterModel);
|
||||
|
||||
lg = 0;
|
||||
lg += snprintf(buf + lg, nMaxTexPathSize - lg, "%sdrivers/%s/%d/%s;",
|
||||
|
@ -121,13 +124,19 @@ osg::ref_ptr<osg::Node> SDCar::loadCar(tCarElt *car)
|
|||
//GfOut("HEHEHHEHEHEHHEHHEH %s\n",path);
|
||||
//carEntity = grssgCarLoadAC3D(param, NULL, index);
|
||||
std::string strPath = GetDataDir();
|
||||
if (bMasterModel)
|
||||
sprintf(buf, "cars/%s/%s.acc", car->_masterModel, car->_masterModel);
|
||||
else
|
||||
sprintf(buf, "cars/%s/%s.acc", car->_carName, car->_carName);
|
||||
|
||||
strPath+=buf;
|
||||
osgLoader loader;
|
||||
//GfOut("Chemin Textures : %s\n", m_strTexturePath.c_str());
|
||||
//loader.AddSearchPath(m_strTexturePath);
|
||||
//osg::Node *pCar = loader.Load3dFile("/usr/local/share/games/speed-dreams-2/cars/mp1-cavallo-tr06/mp1-cavallo-tr06-lod1.acc");
|
||||
osg::Node *pCar = loader.Load3dFile(strPath);
|
||||
std::string strTPath = GetDataDir();
|
||||
sprintf(buf, "drivers/%s/%d/", car->_modName, car->_driverIndex);
|
||||
strTPath += buf;
|
||||
GfOut("Chemin Textures : %s\n", strTPath.c_str());
|
||||
loader.AddSearchPath(strTPath);
|
||||
osg::Node *pCar = loader.Load3dFile(strPath, true);
|
||||
|
||||
osg::Vec3 p;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ osgLoader::~osgLoader(void)
|
|||
void osgLoader::AddSearchPath(std::string strPath)
|
||||
{
|
||||
|
||||
m_pOpt->getDatabasePathList().push_front(strPath);
|
||||
m_pOpt->getDatabasePathList().push_back(strPath);
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Image> osgLoader::LoadImageFile(std::string strFile)
|
||||
|
@ -32,10 +32,13 @@ osg::ref_ptr<osg::Image> osgLoader::LoadImageFile(std::string strFile)
|
|||
return Image;
|
||||
}
|
||||
|
||||
osg::Node *osgLoader::Load3dFile(std::string strFile)
|
||||
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 (ext == "acc" || ext == "ac")
|
||||
{
|
||||
//Use custom ACC file loader
|
||||
|
|
|
@ -8,7 +8,7 @@ public:
|
|||
osgLoader(void);
|
||||
~osgLoader(void);
|
||||
|
||||
osg::Node *Load3dFile(std::string strFile);
|
||||
osg::Node *Load3dFile(std::string strFile, bool car);
|
||||
osg::ref_ptr<osg::Image> LoadImageFile(std::string strFile);
|
||||
void AddSearchPath(std::string strPath);
|
||||
|
||||
|
|
|
@ -444,8 +444,6 @@ initView(int x, int y, int width, int height, int /* flag */, void *screen)
|
|||
grWinw = width;
|
||||
grWinh = height;
|
||||
|
||||
ratio = width/height;
|
||||
|
||||
fMouseRatioX = width / 640.0;
|
||||
fMouseRatioY = height / 480.0;
|
||||
|
||||
|
@ -467,7 +465,8 @@ initView(int x, int y, int width, int height, int /* flag */, void *screen)
|
|||
m_sceneViewer->getCamera()->setName("Cam one");
|
||||
m_sceneViewer->getCamera()->setViewport(new osg::Viewport(0, 0, grWinw, grWinh));
|
||||
m_sceneViewer->getCamera()->setGraphicsContext(gw.get());
|
||||
m_sceneViewer->getCamera()->setProjectionMatrixAsPerspective(67.5, static_cast<double>(ratio), 0.1, 12000.0);
|
||||
m_sceneViewer->getCamera()->setProjectionMatrixAsPerspective(67.5f, static_cast<double>(grWinw / grWinh), 0.2f, 9000.0f);
|
||||
//m_sceneViewer->setThreadingModel(osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext);
|
||||
m_sceneViewer->realize();
|
||||
|
||||
|
||||
|
@ -482,8 +481,8 @@ initView(int x, int y, int width, int height, int /* flag */, void *screen)
|
|||
GfuiAddKey(screen, GFUIK_HOME, "Zoom Maximum", (void*)GR_ZOOM_MAX, grSetZoom, NULL);
|
||||
GfuiAddKey(screen, '*', "Zoom Default", (void*)GR_ZOOM_DFLT, grSetZoom, NULL);*/
|
||||
|
||||
GfuiAddKey( 0, GFUIK_PAGEUP, "Select Previous Car", (void*)0, grPrevCar, NULL);
|
||||
GfuiAddKey( 0, GFUIK_PAGEDOWN, "Select Next Car", (void*)0, grNextCar, NULL);
|
||||
//GfuiAddKey( 0, GFUIK_PAGEUP, "Select Previous Car", (void*)0, grPrevCar, NULL);
|
||||
//GfuiAddKey( 0, GFUIK_PAGEDOWN, "Select Next Car", (void*)0, grNextCar, NULL);
|
||||
|
||||
/*GfuiAddKey(screen, GFUIK_F2, "Driver Views", (void*)0, grSelectCamera, NULL);
|
||||
GfuiAddKey(screen, GFUIK_F3, "Car Views", (void*)1, grSelectCamera, NULL);
|
||||
|
@ -538,7 +537,7 @@ refresh(tSituation *s)
|
|||
p[0] = car->_pos_X + car->_drvPos_x;
|
||||
p[1] = car->_pos_Y + car->_drvPos_y;
|
||||
p[2] = car->_pos_Z + car->_drvPos_z;
|
||||
// osgXformPnt3(p, car->_posMat);
|
||||
osgXformPnt3(p, car->_posMat);
|
||||
|
||||
eye[0] = p[0];
|
||||
eye[1] = p[1];
|
||||
|
@ -554,7 +553,7 @@ refresh(tSituation *s)
|
|||
P[0] = (car->_pos_X + 30.0 * cos(car->_glance + offset + car->_yaw));
|
||||
P[1] = (car->_pos_Y + 30.0 * sin(car->_glance + offset + car->_yaw));
|
||||
P[2] = car->_pos_Z + car->_yaw;
|
||||
//osgXformPnt3(P, car->_posMat);
|
||||
osgXformPnt3(P, car->_posMat);
|
||||
|
||||
center[0] = P[0];
|
||||
center[1] = P[1];
|
||||
|
@ -572,9 +571,7 @@ refresh(tSituation *s)
|
|||
|
||||
osg::Camera * camera = m_sceneViewer->getCamera();
|
||||
camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
|
||||
//camera->setProjectionMatrixAsPerspective(67.5, ratio, 1, 12000.0);
|
||||
camera->setViewMatrixAsLookAt( eye, center, osg::Vec3(0,0,1));
|
||||
|
||||
camera->setViewMatrixAsLookAt( eye, center, up);
|
||||
|
||||
cars.updateCars();
|
||||
|
||||
|
@ -807,9 +804,11 @@ initTrack(tTrack *track)
|
|||
return grLoadScene(track);
|
||||
}
|
||||
|
||||
int initCars(tSituation *s){
|
||||
int initCars(tSituation *s)
|
||||
{
|
||||
m_sceneroot->addChild(cars.loadCars(s));
|
||||
GfOut("All cars loaded\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,15 +34,5 @@ extern void osgXformPnt3( osg::Vec3 dst, const osg::Vec3 src, const osgMat4 mat
|
|||
|
||||
inline void osgXformPnt3( osg::Vec3 dst, const osgMat4 mat ) { osgXformPnt3 ( dst, dst, mat ); }
|
||||
|
||||
void osgXformPnt3(osg::Vec3 dst, const osg::Vec3 src, const osgMat4 mat);
|
||||
/*{
|
||||
float t0 = src[0];
|
||||
float t1 = src[1];
|
||||
float t2 = src[2];
|
||||
|
||||
dst[0] = t0*mat[0][0] + t1*mat[1][0] + t2*mat[2][0] + mat[3][0];
|
||||
dst[1] = t0*mat[0][1] + t1*mat[1][1] + t2*mat[2][1] + mat[3][1];
|
||||
dst[2] = t0*mat[0][2] + t1*mat[1][2] + t2*mat[2][2] + mat[3][2];
|
||||
}*/
|
||||
|
||||
#endif /* _OSGMATH_H_ */
|
||||
|
|
|
@ -261,7 +261,7 @@ bool LoadTrack(std::string strTrack)
|
|||
osgLoader loader;
|
||||
GfOut("Chemin Textures : %s\n", m_strTexturePath.c_str());
|
||||
loader.AddSearchPath(m_strTexturePath);
|
||||
osg::Node *pTrack = loader.Load3dFile(strTrack);
|
||||
osg::Node *pTrack = loader.Load3dFile(strTrack, false);
|
||||
|
||||
//osgDB::writeNodeFile(*pTrack,"mytrack.osg");
|
||||
|
||||
|
@ -301,7 +301,7 @@ bool LoadBackground(std::string strTrack)
|
|||
osgLoader loader;
|
||||
GfOut("Chemin Textures : %s\n", m_strTexturePath.c_str());
|
||||
loader.AddSearchPath(m_strTexturePath);
|
||||
osg::Node *m_background = loader.Load3dFile(strTrack);
|
||||
osg::Node *m_background = loader.Load3dFile(strTrack, false);
|
||||
|
||||
if (m_background)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue