[SOLVED] Crash while trying to add a body to the world

MindCalamity

15-09-2011 22:42:50

Hi, I'm trying to integrate NxOgre with the new framework I'm creating (based on the Advanced Ogre Framework by spacegaier), and I've partially achieved that, until I try to add a body to the world that is.

I'm initializing NxOgre like this:

void GameFramework::initPhysics(Ogre::SceneManager* mgr)
{
// Create the world.
mWorld = NxOgre::World::createWorld();

mWorld->getRemoteDebugger()->connect();

// Create the scene
NxOgre::SceneDescription scene_description;
scene_description.mGravity = NxOgre::Constants::MEAN_EARTH_GRAVITY;
scene_description.mUseHardware = false;

mScene = mWorld->createScene(scene_description);

// Set default material properties
mDefaultMaterial = mScene->getMaterial(0);
mDefaultMaterial->setRestitution(0.1f);
mDefaultMaterial->setDynamicFriction(0.9);
mDefaultMaterial->setStaticFriction(0.5);

// Plane creation
mScene->createSceneGeometry(NxOgre::PlaneGeometryDescription());

// Create the render system.
mRenderSystem = new Critter::RenderSystem(mScene, mgr);

mRenderSystem->setVisualisationMode(NxOgre::Enums::VisualDebugger_ShowAll);

mLog->logMessage("NxOgre Initialized");

// Setup a BodyDescription.
// Critter::BodyDescription bodyDescription;
// bodyDescription.mMass = 40.0f; // Set the mass to 40kg.

// Finally create the body.
// mBody = mRenderSystem->createBody(NxOgre::BoxDescription(1,1,1), NxOgre::Vec3(0,5,0), "cube.1m.mesh", bodyDescription);
}


Since I have multiple states, I have to call this function from the running application state, and pass that state's scene manager to the function for initializing NxOgre, now this code runs fine when the last 3 lines that define and add the body to the world are commented, but if I uncomment those lines, the application crashes, and what's really weird is, it crashes before that function is even called, before even the game state has been entered, it seems to crash while in the menu state, after loading the MyGUI layout there (again, I have no problems with those 3 lines commented).

Does anyone have any idea what could be causing the crash ?

Also, I've compiled the tutorials, and most of them run on the sample browser, but some crash (which I don't mind, as the one I'm trying to do here is running perfectly in the sample browser).

Here's a part of my createScene() function in the GameState if someone finds it necessary:

GameFramework::getSingletonPtr()->initPhysics(mSceneMgr);


////////////////////////////////////////////
// PHYSICS TEST
///////////////////////////////////////////

// create a floor mesh resource
MeshManager::getSingleton().createPlane("floor", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Plane(Vector3::UNIT_Y, 0), 1000, 1000, 1,1 , true, 1, 1, 1, Vector3::UNIT_Z);

// create a floor entity, give it a material, and place it at the origin
Entity* floor = mSceneMgr->createEntity("Floor", "floor");
floor->setMaterialName("Hex-floor");
floor->setCastShadows(false);
mSceneMgr->getRootSceneNode()->attachObject(floor);


I also tried putting the initPhysics() function after creating the floor resource and attaching it to a scene node, but to no avail...

And to erase any doubt of NxOgre not being initialized properly with the 3 lines commented - here's a screenshot:

betajaen

18-09-2011 08:32:45

I assume if you create a Box based Actor it will work.

Silly question. Did you copy "cube.1m.mesh" and material/texture into your resources directory?

MindCalamity

18-09-2011 11:46:39

Silly question. Did you copy "cube.1m.mesh" and material/texture into your resources directory?

Oh, you don't know just how stupid I fell right now....

I was so amazingly confident that I copied the mesh, that I didn't even bother to check... :oops:

Thanks betajaen :mrgreen:

betajaen

18-09-2011 11:57:19

Anytime. ;)