DMF load problem - pls help!

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
wydesenej
Posts: 3
Joined: Sat Nov 10, 2007 11:22 am

DMF load problem - pls help!

Post 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!!
wydesenej
Posts: 3
Joined: Sat Nov 10, 2007 11:22 am

Post 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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Post Reply