Page 1 of 1

Another archive question

Posted: Fri May 14, 2010 7:24 pm
by BrianATSI
I am trying to load a mesh from a ZIP archive. It seems that the archive code doesn't apply the VIRTUAL working directory when searching for the file in the archive. In the archive it's "media/modelname/model.x" and the images are in the same directory. When I debug I never see the VIRTUAL working directory applied if I just pass in the file name "model.x" when using virtual directory "media/modelname". Is this a bug or as intended and I have to find another way of organizing my files?

I do the following:

Code: Select all

	//backup current working dirs and set to model's dir
	SceneManager->getFileSystem()->setFileListSystem ( io::FILESYSTEM_NATIVE );
	io::path npath = SceneManager->getFileSystem()->getWorkingDirectory();
	SceneManager->getFileSystem()->changeWorkingDirectoryTo(io::path(AnsiString(vsparams.MEDIA_PATH + modelName).c_str()));
	SceneManager->getFileSystem()->setFileListSystem ( io::FILESYSTEM_VIRTUAL );
	io::path vpath = SceneManager->getFileSystem()->getWorkingDirectory();
	SceneManager->getFileSystem()->changeWorkingDirectoryTo(io::path(AnsiString("media\\" + modelName).c_str()));
	
	// load mesh either from archive or natively
	scene::ISceneNode* node = SceneManager->addAnimatedMeshSceneNode(SceneManager->getMesh(modelPath.c_str()), SceneManager->addEmptySceneNode(0));

	// restore original working directories
	SceneManager->getFileSystem()->setFileListSystem ( io::FILESYSTEM_VIRTUAL );
	SceneManager->getFileSystem()->changeWorkingDirectoryTo(vpath);
	SceneManager->getFileSystem()->setFileListSystem ( io::FILESYSTEM_NATIVE );
	SceneManager->getFileSystem()->changeWorkingDirectoryTo(npath);
And yes this is a ported version of Irrlicht to CodeGear Builder C++

Posted: Fri May 14, 2010 7:32 pm
by BrianATSI
I forgot to mention... this code includes support if the model is in a native directory as well. That is why there are so many calls to setting the working directory.

Also, if I specify the entire VIRTUAL path of the model, the images don't load because the images in the mesh don't have relative path of the base working directory.

Posted: Fri May 14, 2010 10:04 pm
by hybrid
Hmm, I'm not really usre if this feature is implemented for all file system types. Is there a description somewhere what should happen? This feature came in from the q3 implementation IIRC.

Posted: Fri May 14, 2010 10:17 pm
by BrianATSI
It looks like for now the changeWorkingDirectoryTo(...) function only applies to FILESYSTEM_NATIVE, in the function it checks which filesystem is active but when a file is attempted to be opened in an archive the working directory is never applied to it.

So I would have to go through all my meshes and apply a relative path for the image materials in reference to the archives root. (which would be a pain in the butt)

Posted: Sat May 15, 2010 7:27 am
by hybrid
You can access the archive from anywhere you are, it's always located relative to the current working directory. So no need to care for it too much.