Some little problems with nx(Ogre)

rUmbl3

09-05-2006 16:52:28

Hi,
first of all i want to to thank you betajaen for this really cool novodex wrapper .. its really fun to work with it (I hope you finish your book soon .. you got some pretty cool stuff in it).
But i got a problem:

My Programm crashes everytime i want to add a force to my cuboid body.
I can't really post much code, cause its spread over severall classes but here are my body creation and the addForce call when a specific key is pressed (hope this helps a little bit)


body = scene->createBody("box","abrams.mesh",new nxOgre::cubeShape(Vector3(10,7,17),Vector3(0,0,0)),100.0f, Vector3(0,10,0));

// When key "W" is pressed:
body->addForce(Vector3(150,0,0));

The Scene/World setup is done as it is explained in the first tutorials so just ->hasFloor and ->hasGravity plus some Debug lines ..

betajaen

09-05-2006 19:32:20

That is all pretty much normal code there.

If the body->addForce is in a separate method from your scene setup, are you sure that the body is the actual pointer to the body rather random memory (which would cause a crash)?

Secondarily, just a silly question you are compiling this as release right?

rUmbl3

09-05-2006 21:50:18

Yes, i am compiling this as release .. because debug just gives me plenty errors (~400 but VC stops counting, it get some errors with syntax of some nx headers)
I am just giving the body pointer to a function which creates the body, then give this pointer to the class which handles all the input .. if you then press a key (like WASD) it should add a force to the body ..

betajaen

09-05-2006 22:48:12

Yep, Debug is really that iffy. Unless Aegia release a debug version of PhysX, I don't think there will be ever a debug version of NxOgre.

But your setup sounds good.

What happens if you add some force just after the body has been created; Does it crash then?

magura

10-05-2006 01:33:40

might be barking up the wrong tree here, but you cannot use body as a variable name, as it's a type in NxO.

betajaen

10-05-2006 09:33:27

might be barking up the wrong tree here, but you cannot use body as a variable name, as it's a type in NxO.

It is! Good spotting.

rUmbl3

10-05-2006 16:40:35

might be barking up the wrong tree here, but you cannot use body as a variable name, as it's a type in NxO.
hm .. that shouldn't be a problem as i am not using the namespace nxOgre by default .. so the compiler shouldn't recognize it as nxOgre type ..

okay the creation of the body is now in the main function ..

/* Create our tank */
nxOgre::body *mTankBody = mScene->createBody("Tank","abrams.mesh",new nxOgre::cubeShape(Vector3(10,7,17),Vector3(0,0,0)),100.0f, Vector3(0,10,0));
SceneNode *mCamNode = mTankBody->mNode->createChildSceneNode(mTankBody->mNode->getPosition());
mTankBody->mEntity->setMaterialName("Chenilles");
mCamNode->attachObject(mCamera);
/* Create the scene */
createScene(mCamera, mTankNode, mScene, mTankBody);

mTankBody->addForce(Vector3(150.0,0.0,0.0));


its not crashing anymore but now its doing nothing .. i tried to add a force of 150 every frame like i did it in the last line of the code .. but there is no effect on the body

betajaen

10-05-2006 18:53:36

That could be down to the weight of it; try increasing the force to say 1500..

rUmbl3

10-05-2006 20:02:12

I even tried 15000 and it didn't moved at all ..

betajaen

10-05-2006 20:05:57

Try 1000000, the cube shape is fairly large, and the density is quite high so it's going to be very heavy.

rUmbl3

10-05-2006 21:02:55

ah sorry .. know its working :)
many many thanks ...
but now i got one more question: how do you get the mass of an object and what unit is the value you give the addForce function in this vector (Newton?)

betajaen

11-05-2006 00:26:08

No worries. But your body is really heavy, I'd consider lowering the density a bit.

Getting the mass. It should be in one of the NxActor functions, I haven't wrapped it, you can access the PhysX actor via mBody->mActor->

As for the unit; I can't remember if it's Newton's or not, the PhysX SDK should be able to tell you though.

SmokingRope

15-02-2007 02:11:31

This thread is all important. Although one should be able to infer that mass would be the product of density and volume it hadn't clicked untill i had this same issue.