diff -r 920584a7938b lib/irrlicht/include/SceneParameters.h --- a/lib/irrlicht/include/SceneParameters.h Wed Jun 03 19:51:31 2009 +0200 +++ b/lib/irrlicht/include/SceneParameters.h Wed Jun 03 20:17:15 2009 +0200 @@ -129,6 +129,21 @@ deleting scene nodes for example */ const c8* const IRR_SCENE_MANAGER_IS_EDITOR = "IRR_Editor"; + //! Name of the parameter for changing the texture path of the built-in b3d loader. + /** Use it like this: + \code + SceneManager->getParameters()->setAttribute(scene::B3D_TEXTURE_PATH, "path/to/your/textures"); + \endcode + **/ + const c8* const B3D_TEXTURE_PATH = "B3D_TexturePath"; + + //! Name of the parameter for changing the texture path of the built-in obj loader. + /** Use it like this: + \code + SceneManager->getParameters()->setAttribute(scene::OBJ_TEXTURE_PATH, "path/to/your/textures"); + \endcode + **/ + const c8* const OBJ_TEXTURE_PATH = "OBJ_TexturePath"; } // end namespace scene } // end namespace irr diff -r 920584a7938b lib/irrlicht/source/Irrlicht/CB3DMeshFileLoader.cpp --- a/lib/irrlicht/source/Irrlicht/CB3DMeshFileLoader.cpp Wed Jun 03 19:51:31 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CB3DMeshFileLoader.cpp Wed Jun 03 20:17:15 2009 +0200 @@ -667,13 +667,28 @@ os::Printer::log("read ChunkTEXS"); #endif + core::stringc texturePath = + SceneManager->getParameters()->getAttributeAsString(B3D_TEXTURE_PATH); + while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) //this chunk repeats { Textures.push_back(SB3dTexture()); SB3dTexture& B3dTexture = Textures.getLast(); B3dTexture.TextureName=readString(); - B3dTexture.TextureName=stripPathFromString(B3DFile->getFileName(),true) + stripPathFromString(B3dTexture.TextureName,false); + if ( texturePath.size() ) + { + core::stringc texName = texturePath; + if ( texName.size() ) + texName += "/"; + texName += stripPathFromString(B3dTexture.TextureName, false); + B3dTexture.TextureName = texName; + } + else + { + B3dTexture.TextureName=stripPathFromString(B3DFile->getFileName(),true) + stripPathFromString(B3dTexture.TextureName,false); + } + #ifdef _B3D_READER_DEBUG os::Printer::log("read Texture", B3dTexture.TextureName.c_str()); #endif diff -r 920584a7938b lib/irrlicht/source/Irrlicht/COBJMeshFileLoader.cpp --- a/lib/irrlicht/source/Irrlicht/COBJMeshFileLoader.cpp Wed Jun 03 19:51:31 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/COBJMeshFileLoader.cpp Wed Jun 03 20:17:15 2009 +0200 @@ -2,7 +2,7 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h -#include "IrrCompileConfig.h" +#include "IrrCompileConfig.h" #ifdef _IRR_COMPILE_WITH_OBJ_LOADER_ #include "COBJMeshFileLoader.h" @@ -239,7 +239,7 @@ vertLocation = currMtl->Meshbuffer->Vertices.size() -1; currMtl->VertMap.insert(v, vertLocation); } - + faceCorners.push_back(vertLocation); // go to next vertex @@ -259,7 +259,7 @@ } break; - case '#': // comment + case '#': // comment default: break; } // end switch(bufPtr[0]) @@ -414,7 +414,15 @@ texname.replace('\\', '/'); video::ITexture * texture = 0; - if (FileSystem->existFile(texname)) + core::string textureFromTexPath( SceneManager->getParameters()->getAttributeAsString(OBJ_TEXTURE_PATH) ); + if ( textureFromTexPath.size() ) + { + textureFromTexPath += '/'; + textureFromTexPath += texname; + } + if ( FileSystem->existFile(textureFromTexPath) ) + texture = SceneManager->getVideoDriver()->getTexture( textureFromTexPath ); + else if (FileSystem->existFile(texname) ) texture = SceneManager->getVideoDriver()->getTexture(texname); else // try to read in the relative path, the .obj is loaded from