Cannot load BSP mesh

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
agi_shi
Posts: 122
Joined: Mon Feb 26, 2007 12:46 am

Cannot load BSP mesh

Post by agi_shi »

Hello all! I just recently started using Irrlicht, as I plan on making a game that messes with your mind (everything has its own gravity + portals). My first example was just the CodeBlocks template for Irrlicht (I use code::blocks and mingw). It compiled and worked beautifully. Except for one thing - DirectX does not work (only software and OpenGL). It was not compiled into the pre-built lib. Either way, I was fine with OpenGL so I kept going.

Now I attempted to create a less basic program - load a BSP, make physics for it (using Newton), and allow the player to throw around boxes. With a twist though, depending on what keys you pressed (1/2/3/4/5/6) the gravity for each box you threw would be different (1 would be +x, 6 would be -z, etc.). Part of the "messing with your mind" concept.

The problem is, I recieve a NULL mesh for the BSP when I attempt to load it. As so:

Code: Select all

//device->getFileSystem()->addZipFileArchive("./Data/Map.pk3");
	scene::IAnimatedMesh *levelMesh = sceneMgr->getMesh("../Data/maps/Map.bsp");
	if (!levelMesh) return 12;
	scene::ISceneNode *levelNode = sceneMgr->addOctTreeSceneNode(levelMesh->getMesh(0));
First it just crashed. Debugged it, segfault on the last line. sceneMgr was fine, so it must be levelMesh. Check for nullness and guess what? IT'S NULL. ("Process returned 12")

First I thought it wasn't getting the data from the zip correctly. So I de-zipped it, and commented out that line (and changed the directory for the .BSP to reflect that). Nope, still crashed.

I went out and tried other demos that load BSP maps. They work fine. I compile them - same thing happens. So it's obviously not my code but the libs I'm using. I attempt to use the VC++ libs, but get a linker error (A LOT (LOT LOT) of useless characters)...

I went off to compile Irrlicht from source. Same thing.

I'm out of ideas... Anyone? Does anyone have working mingw libs? I'm not changing compilers just to be able to use Irrlicht. It should supposedly work!

What do I do?

Thanks in advance!

EDIT: I was going to try code::blocks with the visual C++ 2003 toolkit (and hope that everything would compile without any change), ONLY TO FIND THAT MICROSOFT REPLACED IT WITH VISUAL C++ 2005 EXPRESS. I don't want that bloaty piece of crap. I just want the compiler...
agi_shi
Posts: 122
Joined: Mon Feb 26, 2007 12:46 am

Post by agi_shi »

3 spam threads since I posted this. And that was what, half an hour ago?
datamagik
Posts: 26
Joined: Wed Feb 14, 2007 11:25 pm
Location: Bar Harbor, Maine USA

Post by datamagik »

The .BSP is located in the .PK3 file (which is really a .zip archive). After you've told the file system about the .PK3 just load the mesh "Map.BSP". Do not include the path to the directory the PK3 is in unless you have another separate BSP file in there with the same name.
agi_shi
Posts: 122
Joined: Mon Feb 26, 2007 12:46 am

Post by agi_shi »

datamagik wrote:The .BSP is located in the .PK3 file (which is really a .zip archive). After you've told the file system about the .PK3 just load the mesh "Map.BSP". Do not include the path to the directory the PK3 is in unless you have another separate BSP file in there with the same name.
Well, yeah. I know. I only did that after unzipping the PK3 with and external program to see if maybe Irrlicht wasn't reading it correctly. But it just won't load the BSP.

Even taking straight code from some Irrlicht demo won't work, it'll crash when it attemps to load a BSP. Or any format for that matter, I just tried a 3DS "room" from the Irrlicht folder and it crashed, too (returned 12 which means the mesh was NULL)...

Anyone know where to find a mirror with the VC++ 2003 Toolkit? I don't want that piece of a bloaty crap IDE that microsoft replaced it with.

EDIT: getMesh seems to always return NULL. I have a throwObject() function like this:

Code: Select all

void throwObject() {
    Body *cube = new Body;
    bodies.push_back(cube);

    cube->gravity = currGravity;

    cube->mesh = sceneMgr->getMesh("./Data/smallcube.3ds");
    cube->node = sceneMgr->addAnimatedMeshSceneNode(cube->mesh);
    cube->node->setMaterialTexture(0, driver->getTexture("./Data/crate.jpg"));
    cube->node->setMaterialFlag(EMF_LIGHTING, false);

    [...]
Same thing, crashes because cube->mesh == NULL. And no, it's not my directories. I tried everything, putting the data in the project directory, exe directory, elsewhere, etc.
agi_shi
Posts: 122
Joined: Mon Feb 26, 2007 12:46 am

Post by agi_shi »

So I found an FTP mirror of the toolkit, got it, installed it, and it fixed my DX9 + DX8 problem.

But this problem of the meshes not loading still persists. IT WON'T LOAD THE MESH. Just returns NULL.
datamagik
Posts: 26
Joined: Wed Feb 14, 2007 11:25 pm
Location: Bar Harbor, Maine USA

Post by datamagik »

Ok lets solve one problem at a time. Looking back at your original code problem I see you're referencing "./Data..." in the first instance and "../Data..." in the second.

Try building the demo app. Then try changing to your alternate mesh.

The call to load the archive simply tells the file system to look in there for meshes. When you reference the add mesh for the mesh that is in the PK3 do not include any path data. Also you may want to unzip it to make sure the BSP has the same name as the map. There are many cases where the name of the BSP is either slightly or completely different from the archive name.

As for the other issues you mention: for Windows development I found DevC++ and CODE::BLOCKS easier to work with and was able to do a clean build of the Irrlicht library in both of those. I can't address the DirectX issues because I use OpenGL for cross platform use.
agi_shi
Posts: 122
Joined: Mon Feb 26, 2007 12:46 am

Post by agi_shi »

datamagik wrote:Ok lets solve one problem at a time. Looking back at your original code problem I see you're referencing "./Data..." in the first instance and "../Data..." in the second.
Already tried, back slashes, front slash, ".."/".", everything that has to do with the directory.

Try building the demo app. Then try changing to your alternate mesh.
It's not my mesh. In fact it's one from the media folder of the SDK. Either way though, just taking the code from a demo/example program and compiling it, as is, and running it, I experience the SAME crash.

The call to load the archive simply tells the file system to look in there for meshes. When you reference the add mesh for the mesh that is in the PK3 do not include any path data. Also you may want to unzip it to make sure the BSP has the same name as the map. There are many cases where the name of the BSP is either slightly or completely different from the archive name.
I didn't add any path data other than "map/the_name.bsp". You see "data/" in front because I thought of that before, and unzipped the pack. So then I tried to load directly (because it was already unzipped), but it still didn't work. I've copied & pasted, renamed, and tried the name a thousand times. I'm sure I have the name of the BSP correctly.
As for the other issues you mention: for Windows development I found DevC++ and CODE::BLOCKS easier to work with and was able to do a clean build of the Irrlicht library in both of those. I can't address the DirectX issues because I use OpenGL for cross platform use.
Yeah, I could build Irrlicht from the ground up without any modification whatsoever. I didn't really care about the DX, I just want to load a mesh.
agi_shi
Posts: 122
Joined: Mon Feb 26, 2007 12:46 am

Post by agi_shi »

Hmm... Trying an absolute path works. Now I just gotta find out how to not use an absolute path.
rumpl
Posts: 3
Joined: Tue Feb 20, 2007 12:26 pm

Post by rumpl »

Where is the exec file? Where is the Data directory?
agi_shi
Posts: 122
Joined: Mon Feb 26, 2007 12:46 am

Post by agi_shi »

rumpl wrote:Where is the exec file? Where is the Data directory?
Ahh, it's the project settings that messed me up. When I run the .exe from the IDE it's home directory is in the project directory. When I run it directly, it's where it should've been.

So now access is "Data\\<bla>", with the data folder in the project directory. Thanks anyways guys!
Post Reply