Page 1 of 1

DMF load problem - pls help!

Posted: Sat Nov 10, 2007 12:37 pm
by wydesenej
Hi,
i have OS linux. When i trying to load dmf with texture than:

Code:

Code: Select all

smgr->getParameters()->setAttribute(DMF_TEXTURE_PATH,"./texture/");
smgr->getParameters()->setAttribute(DMF_USE_MATERIALS_DIRS, false);

IAnimatedMeshSceneNode *anms = smgr->addAnimatedMeshSceneNode(smgr->getMesh("./data/room.dmf"));
Error when i trying to run compiled file:

Code: Select all

Could not open file of texture: ./texture/\system.bmp
Could not open file of texture: ./texture/\Floor02.jpg
Could not open file of texture: ./texture/\Floor04.jpg
Could not open file of texture: ./texture/\Water01.jpg
Could not open file of texture: ./texture/\Roof03.jpg
Loaded mesh: ./data/room.dmf
Mesh was loaded, but to texture path was added "\". This is file system problem , but i dont have any idea to fix it.

PLEASE HELP!!

Posted: Sat Nov 10, 2007 12:57 pm
by wydesenej
Ok, i fix it.

Problem is in the file /irrlicht/source/CDMFLoader.cpp.

find this part of code:

Code: Select all

for (i=0; i<header.numMaterials; i++)
	{
		String path;
        path = "";
        if ( !SceneMgr->getParameters()->existsAttribute(DMF_TEXTURE_PATH) )
		{
			//get the right path for textures
			StringList filepath = SubdivideString(String(file->getFileName()),"\\");
			StringList filepath1 = SubdivideString(String(file->getFileName()),"/");
			if(filepath1.size()>filepath.size())
			{
				filepath.clear();
				filepath=filepath1;
			}

			for (int j=0; j<(int)(filepath.size()-1); j++)
				path = path + filepath[j] + String("\\");
        }
        else
			path = path +
				String( SceneMgr->getParameters()->getAttributeAsString(DMF_TEXTURE_PATH)) +  String("\\");
The probles in two String("\\").
fix code (all String("\\") are commented):

Code: Select all

for (i=0; i<header.numMaterials; i++)
	{
		String path;
        path = "";
        if ( !SceneMgr->getParameters()->existsAttribute(DMF_TEXTURE_PATH) )
		{
			//get the right path for textures
			StringList filepath = SubdivideString(String(file->getFileName()),"\\");
			StringList filepath1 = SubdivideString(String(file->getFileName()),"/");
			if(filepath1.size()>filepath.size())
			{
				filepath.clear();
				filepath=filepath1;
			}

			for (int j=0; j<(int)(filepath.size()-1); j++)
				path = path + filepath[j] /*+ String("\\")*/;
        }
        else
			path = path +
				String( SceneMgr->getParameters()->getAttributeAsString(DMF_TEXTURE_PATH)) /*+ String("\\")*/;
Now you must recompile irrlicht engine and replace old header files and libraryes.

IMPORTANT!!!

now you must write:

./data/textures/dir/

NO ./data/textures/dir

Posted: Sat Nov 10, 2007 1:20 pm
by hybrid
First of all: Stop crossposting. One posting is enough, even if you'Re proud or desperate of it.
Second: Should it be enough to change setAttribute(DMF_TEXTURE_PATH,"./texture/") to setAttribute(DMF_TEXTURE_PATH,"./texture") in your code? I agree that in that case the code should honor the last delimiter and replace it (or handle it somehow), but your code seems to replace one problem with another.