Create an object using a key

limdor

06-03-2008 15:34:29

I try to create a sphere when I press the space key but a excepcion in NxOgre_d.dll is throwed.
I have attach this piece of code in createScene and it runs but when I put it in processUnbufferedKeyInput(const FrameEvent& evt) then don't work

Does anybody know why?


if( mKeyboard->isKeyDown(KC_SPACE) && mTimeUntilNextToggle <= 0 )
{
NxOgre::Body * b;
SphereShape * s = new SphereShape(2);
b = mScene->createBody("sphere.2m.mesh", s, mCamera->getPosition(), "mass: 420");
//b->setLinearVelocity(mCamera->getDirection()*50);
mTimeUntilNextToggle = 2;
}

betajaen

06-03-2008 16:04:21

Can you trace the error? I bet it's a NULL pointer.

limdor

06-03-2008 16:12:39

The error happens when in createBody()::Body::Actor::scene->getActors()->has(identifier)

Then, when it calls has(identifier) when throw the exception

How can I solution this error?

limdor

06-03-2008 16:24:53

Thank you, I have fixed the error. In createScene() metod i redefine mScene.

An stupid error, I put NxOgre::Scene * mScene = ....
then the variable it was local indeed global

betajaen

06-03-2008 17:22:43

Yep, I thought it was either mScene or mCamera being NULL or random. In nearly all cases I find - if it's a crash it's a pointer problem.