NxOgre Critter::mBody = mRenderSystem->createBody exception

lordmonkey

06-04-2011 23:19:00

Although tutorials compiled correctly and everything is running fine I have a problem with my application
I get an unhandled exception like this
http://img845.imageshack.us/f/unledd.png/

and here is my piece of code
//NxOgre::WorldDescription worldDesc;
mNxWorld = NxOgre::World::createWorld(); //("time-controller:ogre, log:yes");

NxOgre::SceneDescription sceneDesc;
sceneDesc.mGravity = NxOgre::Constants::MEAN_EARTH_GRAVITY;
//sceneDesc.mName = "NxScene1";
//mNxScene = new NxOgre::Scene;
mNxScene = mNxWorld->createScene(sceneDesc);

mNxScene->getMaterial(0)->setStaticFriction(0.5);
mNxScene->getMaterial(0)->setDynamicFriction(0.5);
mNxScene->getMaterial(0)->setRestitution(0.1);

mRenderSystem = new Critter::RenderSystem(mNxScene, mSceneMgr);

// 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);


exception is pointing at last line of my code :/ and the same piece of code works fine in tutorials ...

betajaen

07-04-2011 07:35:53

Have you created the Ogre Root and SceneManager first?

lordmonkey

07-04-2011 12:37:50

I didn't do it but they are both created by the OgreWizard (which I used to create this project).

I tried to use different combinations of createBody ( with different descriptions etc) but still does not work.

I have even reinstalled physx, redownloaded critter and nxogre and rebuilt them and still nothing. And the code in your tutorials is still working :/

betajaen

07-04-2011 13:36:17

You need to have that code called after the SceneManager and Root have been created. If you trace your application, you may find that the Root or SceneManager pointers are null or invalid, if that's the case then the order is wrong.

lordmonkey

07-04-2011 14:26:48

Thank you very much that was the case... although :
when I moved this code to other part of my program, now I get other exception : access violation in memcpy.asm :/
http://img156.imageshack.us/f/unledt.png/

EDIT:
I think it might be problem with some warnings I get building Critter :
1>NxOgreDebug.lib(NxOgreDebug.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in OgreMain_d.lib(OgreMain_d.dll); second definition ignored
1>NxOgreDebug.lib(NxOgreDebug.dll) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
1> Critter.vcxproj -> C:\env_vars\critter\build\vc10\\DebugStatic\CritterDebugStatic.lib


I was trying to find solution on the web but cannot find one :/

lordmonkey

11-04-2011 14:04:20

Sry for bumping but anyone has any idea how to fix this ?

betajaen

11-04-2011 14:21:55

I really don't know. But that warning isn't the source of the problem.

Like I said, the order of initialization is important. All crashes in C++ happen because of a null or invalid pointer, so it's likely your order is incorrect.