Another archive question

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
BrianATSI
Posts: 23
Joined: Thu Jan 10, 2008 9:00 pm

Another archive question

Post 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++
Last edited by BrianATSI on Fri May 14, 2010 7:37 pm, edited 1 time in total.
BrianATSI
Posts: 23
Joined: Thu Jan 10, 2008 9:00 pm

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

Post 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.
BrianATSI
Posts: 23
Joined: Thu Jan 10, 2008 9:00 pm

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

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