[0.9] mesh shape for collision

ghiboz

16-05-2007 09:40:23

hi! I have a trimesh and for the moment I wish have as collision shape a box around my trimesh!
here is my code:

NxOgre::Body *body = pScene->createBody(pszFileName,
new NxOgre::CubeShape( 10, 10, 10 ),
NxOgre::Pose(pos + gain, rot),
pars);

Vector3 bodyMax = body->getEntity()->getBoundingBox().getMaximum();
Vector3 bodyMin = body->getEntity()->getBoundingBox().getMinimum();
Vector3 bodyDim = bodyMax - bodyMin;
body->addShape(new NxOgre::CubeShape(bodyDim.x, bodyDim.y, bodyDim.z));


but doesn't work, the body have as collision shape the box 10x10x10 and not the newest that I added (is biggest than 10x10x10)
how can I do??

last thing:
the mass in what measure unit is??

regards! :wink:

daedar

16-05-2007 10:02:10

From Sticky: Betajaen's quick guide to porting 0.6 code to NxOgre 0.9:

- Everything is in SI units; metres, kilograms and newtons.

betajaen

16-05-2007 10:06:44

But you don't have a tri-mesh; you have two cubes there.

Anyway, try:

Vector3 mMinimum = body->getEntity()->getBoundingBox().getMinimum();
Vector3 size;
size.x = Ogre::abs(Ogre::abs(mMinimum.x) + NxMath::abs(mMinimum.x));
size.y = Ogre::abs(Ogre::abs(mMinimum.y) + NxMath::abs(mMinimum.y));
size.z = Ogre::abs(Ogre::abs(mMinimum.z) + NxMath::abs(mMinimum.z));
body->addShape(new NxOgre::CubeShape(size.x, size.y, size.z));


Code is from NxOgre 0.6, BoundingBox shape.

Mass is measured in Kilograms and Density is measured in Kilograms per metre cubed.

ghiboz

16-05-2007 10:18:46

But you don't have a tri-mesh; you have two cubes there.

Anyway, try:

Vector3 mMinimum = body->getEntity()->getBoundingBox().getMinimum();
Vector3 size;
size.x = Ogre::abs(Ogre::abs(mMinimum.x) + NxMath::abs(mMinimum.x));
size.y = Ogre::abs(Ogre::abs(mMinimum.y) + NxMath::abs(mMinimum.y));
size.z = Ogre::abs(Ogre::abs(mMinimum.z) + NxMath::abs(mMinimum.z));
body->addShape(new NxOgre::CubeShape(size.x, size.y, size.z));


Code is from NxOgre 0.6, BoundingBox shape.

Mass is measured in Kilograms and Density is measured in Kilograms per metre cubed.


thanks, I tried, when i add a shape, the 3 pars are bigger (I don't understand the addition and the Ogre::abs that doesn't work), but when the body go down due the gravity, the collision is the original box 100x100x100.

thanks :wink: