BspSceneManager and BspLevel

Problems building or running the engine, queries about how to use features etc.
say113
Gnoblar
Posts: 5
Joined: Sat Jan 08, 2005 5:59 pm
Location: Bristol, UK

BspSceneManager and BspLevel

Post by say113 »

Hey guys,

I am working on a project which has a bsp collision system. I have written the collision system, but I need the root node of the bsp tree, so I can parse it and extract the brush info from each subsequent node etc.

However, when I perform a call to getLevel() to obtain the BspLevel (from which I will then get the root node) I am returned a NULL pointer. The general ordering of the code is:

Code: Select all

BspSceneManager *mSceneMgr;
mSceneMgr = (BspSceneManager*)mRoot->getSceneManager(ST_INTERIOR);
mSceneMgr -> setWorldGeometry(q3Level);
BspLevel *tLevel = mSceneMgr -> getLevel();
A complete listing of the class is as follows:

http://www.cs.bris.ac.uk/home/ss2191/bsp.hh

I can load the map and the program runs, so I know its not to do with the problem with the loading of the map data. I inititally thought it could be to do with the casting..but I can't see how it couldn't work or how it could be done any other way.

I have spent hours on this thing and cannot for the life of me see why this is the case. I know it will be some sort of school boy error, as the code is simple. But I simply cannot see it. Hopefully a few fresh pair of eyes will spot it straight away :)

Thanks in advance all.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

setWorldGeometry sets up the internal mLevel, which gets returned by getLevel(). So the only thing I can think of is that your setWorldGeometry call is failing. You'll need to look at Ogre.log or debug it to find out why.
say113
Gnoblar
Posts: 5
Joined: Sat Jan 08, 2005 5:59 pm
Location: Bristol, UK

Post by say113 »

After a bit more probing around, I have found that if I use the following code directly:

Code: Select all

BspLevel *temp = BspResourceManager::getSingleton().load(q3Level);
then temp is not NULL, and I can go on to use it to get the root node data as required. However, when I pass the EXACT same q3 map file to setWorldGeometry, mLevel is not set and so remains NULL. This is very confusing :?.

I have tried both my own bsp map and the ogretestmap.bsp that is used within the reference application. Same result with both.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

mLevel must be being set in BspSceneManager otherwise it would fail catastrophically. mLevel is used all over the place (just search OgreBspSceneManager.cpp).

Please just use your debugger to figure it out.