cant load pk3

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

cant load pk3

Post by roxaz »

i made a method:

Code: Select all

bool World::loadPK3()
{
	if(device->getFileSystem()->addZipFileArchive("media/map-20kdm2.pk3"))
	{
		return true;
	}
	else
	{
		return false;
	}
}
next, in main() object 'world' is created. this object creats pointers to driver, scene manager and device. everything works, but when i call loadPK3(), it fails to open pk3 file. directories match perfectly, i dont knw what to hook on. maybe there is some kind of exceptions class like in java? returned plain 'false' isnt enough to get rid of this...
pin3
Posts: 108
Joined: Fri Oct 06, 2006 8:50 pm
Contact:

Post by pin3 »

that won't load the map you also need this code:

scene::IAnimatedMesh* mesh = smgr->getMesh("map-20kdm2.bsp");
scene::ISceneNode* node = 0;
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

here it is:

Code: Select all

bool World::loadMap(const c8 *name, int s_x, int s_y, int s_z)
{
	mapMesh = smgr->getMesh("20kdm2.bsp");
	mapNode = 0;

	if (mapMesh)
		mapNode = smgr->addOctTreeSceneNode(mapMesh->getMesh(0));
	if (mapNode)
		mapNode->setPosition(vector3df(s_x, s_y, s_z));

	return true;
}
even if i make everything in one single method, it gives me this:

Code: Select all

Could not load mesh, because file could not be opened.: 20kdm2.bsp
and ot cant be opened because pk3 wasnt opened too
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

I was wondering myself whether:

Code: Select all

mapMesh = smgr->getMesh("20kdm2.bsp");
should be

Code: Select all

mapMesh = smgr->getMesh("maps/20kdm2.bsp"); 
but I think the zip file is flattened by default (paths are ignored).

Does this only happen when running from your IDE? If so, you ned to set the working folder in your project settings.
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

by default paths are ignored so i dont need full path. i gues i have to set working directory, but i dont know how to do so :oops:
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

roxaz wrote:by default paths are ignored so i dont need full path. i gues i have to set working directory, but i dont know how to do so :oops:
So, does this only happen when running from your IDE? If so, what IDE are you using?

In VS2005 Pro I right-click on the project, choose Properties, choose Debugging in the left pane and add $(TargetDir) in the Working Folder on the right.

Note: do this for running Release builds as well [Ctrl-F5]! Slightly confusing having to add settings to the Debugging pane when running without the debugger, but that's MS for you!

Tiny tip: if you select All Configurations in the Configuration drop-down box you can simultaneously set the working folder for Debug, Release, etc.
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

im using vc++ 2005 express v8. actualy i dont know if it happens only with vc++, i havent tried it on other IDE. however it doesnt work.

const c8 *currentDir = device->getFileSystem()->getWorkingDirectory(); might be useful, if i use this, i have to join const c8 *currentDir with const c8 *pkName. now there is another problem, strcat works with char only, tipecasting doesnt work...

edit:

i managed to get typecasting working but pk3 still isnt loading.. :/

Code: Select all

const c8 *name = "map.pk3";
const c8 *currentDir = device->getFileSystem()->getWorkingDirectory();
	const c8 *newDir = (const c8 *)strcat((char *)currentDir, (char *)name);
	if(device->getFileSystem()->addZipFileArchive(newDir))
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

whatever it is, its compilers error. i tried my code on dev-cpp, it worked perfect! cruel world... cant use dec-cpp - no support for directx, cant use vc++ - thx to Micro$ux developers and theur crazy compiler. any ideas what it could be with vc++?
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

Have you set the project paths in VS2005? dev-cpp must be setting the current folder to the exe before running - VS does not (as I mentioned above).

OK, when you compile with VS, does it work if you open the folder with the exe and run it? If so then its the project path thingy. :wink:
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

oh yessss!!!! i love you man! i would kiss you (Borat style) if you were here :D
Last edited by roxaz on Thu Jan 25, 2007 7:59 pm, edited 2 times in total.
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

:mrgreen:
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

ah one more thingy, i set working dir to C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\myProj\ and it still refuses to work. so what dir should be? \myProj\Debug? this is not working too
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

Follow my instructions and you should be OK. $(TargetDir) is a special VS identifier - it means "where the exe is" (if making an exe, of course).
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

big thanks :)
Post Reply