[Detritus 1.6] Resize body at run time

joarley

09-07-2010 16:55:44

Hi everybody,

I have a fisrt person camera collider and I'm using a sphere shape to represent the collision model. I create my body as follows:

Critter::Body* mCamBody = mRenderSystem->createBody(mSphereDesc, NxOgre::Vec3(0,0,0), "sphere.mesh", mBodyDesc);

In order to run some tests, I'd like to resize at run time my body by changing its radius in SphereDescription . I'm currently setting the radius like this:

mSphereDesc.mRadius = newRadius; But it causes no effect.

Can anyone help me out here?

Thanks

betajaen

09-07-2010 17:08:17

No it wouldn't. Those are just initial descriptions of what the shape should be like when created, and ignored/discarded afterwards.

You need to get the Shape pointer from the Body, cast it into a Sphere then change it that way.

NxOgre::Sphere* sphere = static_cast<NxOgre::Sphere*>(mBody->getShape(0));
sphere->setRadius(whatever_you_like);


You may need to wakeup the body after setting that. (mBody->wakeup());

joarley

09-07-2010 18:08:43

Solved. It worked like a charm.
And I didn't need the wakeup().

Thanks again.