CylinderCollisionShapes for tree-like objects

Hi All,

I´m having trouble getting CylinderCollisionShape to work.
I thought it was an apropriate collision shape to add to trees like this

[java]CylinderCollisionShape treeShape = new CylinderCollisionShape(new Vector3f(5f, 15f, 5f), 1);
RigidBodyControl treeBody = new RigidBodyControl(treeShape, 0);
tree.addControl(treeBody);
bulletAppState.getPhysicsSpace().add(tree);[/java]

but the collision shape does not overlap with the trunk of the tree (but apparently a bit in front of it)… the problem i think, is that I don´t now how to deal with halfExtends or the axis… is there some more information about how to do this properly?

thanks

Ok! so it’s fixed, my shapes collide nicely with my trees (which turned out to have a faulty mesh)… but i’d stull like to know more about the halfextends system, for instance, what does vector i’m giving the collision shape represent?

From the javadoc

[java] /**
* Creates a cylinder shape around the given axis from the given halfextents
* @param halfExtents the halfextents to use
* @param axis (0=X,1=Y,2=Z)
*/ [/java]

So an axis of 1, points upwards in the Y direction. And then the width/height/depth is given as halfExtents * 2

1 Like