Trouble with SimplexCollisionShape() collision

Based on Jmonkey documentation (http://hub.jmonkeyengine.org/javadoc/com/jme3/bullet/collision/shapes/SimplexCollisionShape.html ), the Jmonkey wiki (https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:physics#create_a_collisionshape) and forum posts I was under the impression that SimplexCollisionShape() generated collision shapes for points, lines, triangles and quadrilaterals.

However when I tryed to use it with a triangle the debug visualization would not show the collision shape other then a single point and it was only creating collision for this single point.

Further testing revealed that SimplexCollisionShape() was only making single point collision for lines and quads as well. Additional searching of the forum indicated I am not the only one who has encountered this issue (http://hub.jmonkeyengine.org/forum/topic/collision-not-working-after-adding-rigidbodycontrols-to-a-node/).

I am not sure if I am simple not using SimplexCollisionShape() correctly or if SimplexCollisionShape() is badly documented and/or broken. Any help would be great.

A test app:
[java]
package Project;

import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.collision.shapes.SimplexCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;

public class Main extends SimpleApplication {

private BulletAppState bulletAppState;

Node PhysicsPoint;
Node PhysicsLine;
Node PhysicsTriangle;
Node PhysicsQuad;

public static void main(String[] args) {
    Main app = new Main();
    app.start();
}

@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(10f);
    
    //bullet setup
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    bulletAppState.setDebugEnabled(true); //show collision shapes
    
    //add a point collision shape at (-3, 2, 0)
    PhysicsPoint = new Node("PointNode");
    PhysicsPoint.addControl(new RigidBodyControl(new SimplexCollisionShape(new Vector3f(0f, 0f, 0f)), 1));
    PhysicsPoint.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-3f, 2, 0));
    rootNode.attachChild(PhysicsPoint);
    bulletAppState.getPhysicsSpace().add(PhysicsPoint);
    
    //add a line collision shape parallel to the z axis with a length of 1 world unit at (-1, 2, 0)
    PhysicsLine = new Node("LineNode");
    PhysicsLine.addControl(new RigidBodyControl(new SimplexCollisionShape(new Vector3f(0f, 0f, -0.5f), new Vector3f(0f, 0f, 0.5f)), 1));
    PhysicsLine.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-1f, 2, 0));
    rootNode.attachChild(PhysicsLine);
    bulletAppState.getPhysicsSpace().add(PhysicsLine);
    
    //add a equilateral triangle collision shape with its base parallel to the x axis, its sides equal to 1 world unit, and its position at (1, 2, 0)
    PhysicsTriangle = new Node("TriangleNode");
    PhysicsTriangle.addControl(new RigidBodyControl(new SimplexCollisionShape(new Vector3f(-0.5f, 0f, ((3^(1/2))/2)/2), new Vector3f(0f, 0f, -1*(((3^(1/2))/2)/2)), new Vector3f(0.5f, 0f, ((3^(1/2))/2)/2)), 0.5f));
    PhysicsTriangle.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1f, 2, 0));
    rootNode.attachChild(PhysicsTriangle);
    bulletAppState.getPhysicsSpace().add(PhysicsTriangle);
    
    //add a square collision shape with its sides equal to 1 world unit and its position at (3, 2, 0)
    PhysicsQuad = new Node("QuadNode");
    PhysicsQuad.addControl(new RigidBodyControl(new SimplexCollisionShape(new Vector3f(-0.5f, 0f, 0.5f), new Vector3f(-0.5f, 0f, -0.5f), new Vector3f(0.5f, 0f, -0.5f), new Vector3f(0.5f, 0f, 0.5f)), 1));
    PhysicsQuad.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3f, 2, 0));
    rootNode.attachChild(PhysicsQuad);
    bulletAppState.getPhysicsSpace().add(PhysicsQuad);
    
    //add an obstacle for the point to collide with
    Node PhysicsObstacle1 = new Node("Obstacle1");
    PhysicsObstacle1.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(0.5f, 0.1f, 0.5f)), 0));
    PhysicsObstacle1.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-3f, -1.25f, 0));
    rootNode.attachChild(PhysicsObstacle1);
    bulletAppState.getPhysicsSpace().add(PhysicsObstacle1);
    
    //add obstacles for the line, triangle and quad to collide with
    Node PhysicsObstacle2 = new Node("Obstacle2");
    PhysicsObstacle2.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(3f, 0.1f, 0.25f)), 0));
    PhysicsObstacle2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1f, -1.25f, -0.5f));
    rootNode.attachChild(PhysicsObstacle2);
    bulletAppState.getPhysicsSpace().add(PhysicsObstacle2);
    
    Node PhysicsObstacle3 = new Node("Obstacle3");
    PhysicsObstacle3.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(3f, 0.1f, 0.25f)), 0));
    PhysicsObstacle3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1f, -1.25f, 0.5f));
    rootNode.attachChild(PhysicsObstacle3);
    bulletAppState.getPhysicsSpace().add(PhysicsObstacle3);
}

@Override
public void simpleUpdate(float tpf) {
    //reset the point, line, triangle and quad collision to their original positions every 3 seconds
    if((System.currentTimeMillis()/1000) % 3 == 0) {
        PhysicsPoint.getControl(RigidBodyControl.class).setLinearVelocity(Vector3f.ZERO);
        PhysicsPoint.getControl(RigidBodyControl.class).setAngularVelocity(Vector3f.ZERO);
        PhysicsPoint.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-3f, 2, 0));

        PhysicsLine.getControl(RigidBodyControl.class).setLinearVelocity(Vector3f.ZERO);
        PhysicsLine.getControl(RigidBodyControl.class).setAngularVelocity(Vector3f.ZERO);
        PhysicsLine.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-1f, 2, 0));
        
        PhysicsTriangle.getControl(RigidBodyControl.class).setLinearVelocity(Vector3f.ZERO);
        PhysicsTriangle.getControl(RigidBodyControl.class).setAngularVelocity(Vector3f.ZERO);
        PhysicsTriangle.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1f, 2, 0));
        
        PhysicsQuad.getControl(RigidBodyControl.class).setLinearVelocity(Vector3f.ZERO);
        PhysicsQuad.getControl(RigidBodyControl.class).setAngularVelocity(Vector3f.ZERO);
        PhysicsQuad.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3f, 2, 0));
    }
}

}
[/java]

Do you want a hullcollision shape by any chance?

Hi Empire Phoenix thanks for the reply. Yes I am aware of hullcollision shape and am using it for some of my project.

What I am trying to do with SimplexCollisionShape is create several custom triangle collision shapes and then attach them together with CompoundCollisionShape to from a collision shape that is a little more complicated then the default Box/Sphere/Cylinder non-mesh collision shapes but does not have the limitations of other mesh-accurate collision shapes (hullcollision is convex shape only and other mesh-accurate shapes will not collide with each other etc…).

Well there is the experimental gimpact mesh collision shape, it supports dynamic,
Or you could just use your logic but with hulls out of 3 points, in a compound, might work as well.