Creating object with ConeCollisionShape

This example loads a simple Cone model that was created and exported with Blender to an Ogre mesh. Then it uses the ConeCollisionShape from the bullet library as a collision shape.

public void makeTri(Vector3f loc) {
        // load model and set material
        Spatial cone = assetManager.loadModel("Models/Cone.mesh.xml");
        cone.setMaterial(stone_mat);
 
        // set scale and location
        cone.scale(0.5f, 0.5f, 0.5f);
        cone.setLocalTranslation(loc);
 
        // create a CollisionShape
        ConeCollisionShape shape = new ConeCollisionShape(0.5f, 0.5f);
 
        // create a PhysicsControl
        tri_phy = new RigidBodyControl(shape, 1f);
 
        // add the control to the Spatial.
        cone.addControl(tri_phy);
 
        // add the control to the physicsSpace object.
        bulletAppState.getPhysicsSpace().add(tri_phy);
 
        // attach the Spatial to the rootNode
        rootNode.attachChild(cone);
}
Navigation
Print/export
Toolbox