convex hull collision shape is larger than model

Post Reply
Gickl
Posts: 33
Joined: Tue Jun 05, 2012 8:43 am

convex hull collision shape is larger than model

Post by Gickl »

Hi,

i'm using OpeneSceneGraph, .osg-models and the osgBullet-method btConvexHullCollisionShapeFromOSG(...). I have the problem, that all the convex hull shapes are larger than the models. but i 've no idea why...

if i use convex trimeshes instead the dynamic bodies always float above the ground. i've found out, that i can set the margin to zero. but then the bodies "bounce" i a strange way although there are no collisions...

does anybody know these problems? i don't know how to solve this and would be very happy if someone could help me!


thank you in advance,
Daniel
Attachments
the collision shapes (white wireframes) look like this
the collision shapes (white wireframes) look like this
shapes.png (45.82 KiB) Viewed 9507 times
if use convex trimeshes the wheels are floating above the ground
if use convex trimeshes the wheels are floating above the ground
mesh.png (21.37 KiB) Viewed 9507 times
Karrok
Posts: 65
Joined: Fri May 13, 2011 1:11 pm

Re: convex hull collision shape is larger than model

Post by Karrok »

use the halfextend of your cylinder collision shape to create a bullet cylinder.

ie: btCollisionShape * myCollisionShape = new btCylinderShape(osgbCollision::btCylinderCollisionShapeFromOSG( yourOsgCylinder)->getHalfExtentsWithoutMargin());

assuming your osg cylinder is the trimesh as shown in the picture.
Gickl
Posts: 33
Joined: Tue Jun 05, 2012 8:43 am

Re: convex hull collision shape is larger than model

Post by Gickl »

well, the white trimeshes are the whireframe models of the collision shapes that i get with osgNodeFromBtCollisionShape(...) for debug purposes. so the upper picture of my initial post shows the convex hull shapes that are too large and the lower one shows the convex trimeshes that float above the ground...

if i use cylinder shapes for the wheels, they always have a wrong orientation and wrong dimensions as shown in the picture below.
so your approach doesn't work, Karrok. but nevertheless thank you for now.
do i have to build the models originally with the correct orientation to solve this problem?

that the convex trimeshes are floating has probably to do with the margin of the shape as Paul Martz told me. and as i mentioned before setting the margin to zero prevents the floating. but then it comes to strange behaviour and unexpected bouncing. i've read something about the internal edge problem, could it have do with that?

and can anyone tell me, why my convex hull collision shapes are too large?
Attachments
cylinder.png
cylinder.png (38.51 KiB) Viewed 9483 times
Karrok
Posts: 65
Joined: Fri May 13, 2011 1:11 pm

Re: convex hull collision shape is larger than model

Post by Karrok »

the orientation is wrong because in your case you did not set it to suit your needs.

OSGBCOLLISION_EXPORT btCylinderShape* btCylinderCollisionShapeFromOSG( osg::Node* node, AXIS axis=Y );

from the osgb collisionShapes. Just adjust the last parameter to X or Z instead of the default Y axis it takes.
And it'll be fixed. So my approach does work, infact I've been using it myself for months. Try dig into the documentation a bit next time ? :)

Additionally, to get the debug wireframes you don't need to make osgnodes from your collisionnodes manually.
osgb has an implementation of the bullet debugdrawer available.
Gickl
Posts: 33
Joined: Tue Jun 05, 2012 8:43 am

Re: convex hull collision shape is larger than model

Post by Gickl »

ok, thank you. when i set the axis the cylinder shapes are correct. but they're made of only a few vertices. i think that has to do with the scaling of my objects, is that right? the wheels have a diameter of 50cm but the exported models have meter as unit, so the values are in the 0.-range...

the problem of strange behaviour and inexplainable bounces still occurs...could this also have to do with scaling? oder is this a problem of the internal edges?
Attachments
cylinder correct.png
cylinder correct.png (28.08 KiB) Viewed 9443 times
Karrok
Posts: 65
Joined: Fri May 13, 2011 1:11 pm

Re: convex hull collision shape is larger than model

Post by Karrok »

Nope, that has nothing to do with the scaling. Internally (in Bullet) but rather how osgBullet converts a bullet cylinder.

In osgNodeFromBtCollisionShape( const btCylinderShape * btCylinder, const btTransform& trans )

the detail ratio is set to .2f
You can change this to have the debug osg node more closely resemble a cylinder. However again, just using the bullet debugdrawer implementation from osgBullet will be a lot easier (and also it actually creates a cylinder from your cylinders :)
Gickl
Posts: 33
Joined: Tue Jun 05, 2012 8:43 am

Re: convex hull collision shape is larger than model

Post by Gickl »

ok, so the problem of the collision shapes is solved. Thanks!

But there's still the strange behaviour...
Post Reply