Problem with objects (cylinder) without mass

Hi all,



I was fiddling around with the physics tutorials and got past most of them. Wanting to change something (to gain some hands-on experience) I tried adding a Cylinder and have it rolling down the slope i made (as a floor as detailed in the tutorials) but it keeps coming back with and error I cant get past.



My code:

        DynamicPhysicsNode whee = getPhysicsSpace().createDynamicNode();
        final Cylinder cyl = new Cylinder( "cyl",  16, 8, 1.0f, 1.0f);
        whee.attachChild(cyl);
        whee.generatePhysicsGeometry();
        whee.setMaterial(Material.IRON);
        whee.setModelBound(new BoundingSphere());
        whee.computeMass();
        whee.getLocalTranslation().set( 0, 8, 12.0f );



and the error it returns:
java.lang.IllegalStateException: no collision geometries have been added to this node yet - cannot compute mass!  :?

This is probably a real noob question (but we all gotta start somewhere right?) - i tried searching the forums but the only things I found were old posts about some problems with Cylinders?

In the end I want to make the cylinder the wheels of a car -- is this my best approach?

Thanks in advance for any answers  :)

generatePhysicsGeometry does not recognize the Cylinder as a shape, because the method is based on boundings and there is no cylinder bounding. You need to create a physical cylinder via createCylinder and adjust scale, translation and rotation yourself.

Thanks irrisor - that solved it!



To anyone who might stumble upon this in the future with the same problem here is code that works (whether it is "correct" or not I cant say… yet…):


        DynamicPhysicsNode whee = getPhysicsSpace().createDynamicNode();
        whee.createCylinder("wheel1");
        whee.generatePhysicsGeometry();
        whee.setMaterial(Material.IRON);
        whee.setModelBound(new BoundingSphere());
        whee.computeMass();
        whee.getLocalTranslation().set( 0, 8, 12.0f );



This forum is amazing hehe!