I’m trying to create a rigidbody with a GImpactCollisionShape in alpha5.
If i use jbullet it works, but with bullet native the rigidbody doesn’t seem to be created, or at least it doesn’t appear in the debug and it doesn’t influence the scene.
In effect, it is like if there were no physics.
This is a quick test case i’ve made:
import java.util.List;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.plugins.UrlLocator;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.collision.shapes.GImpactCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
public class TestGImpact extends SimpleApplication{
protected Geometry makeFloor() {
Box box=new Box(15,.2f,15);
Geometry floor=new Geometry("the Floor",box);
floor.setLocalTranslation(0,-4,-5);
Material mat1=new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
mat1.setColor("Color",ColorRGBA.Gray);
floor.setMaterial(mat1);
return floor;
}
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(200f);
assetManager.registerLocator("https://github.com/riccardobl/TestData/raw/master/assets/",UrlLocator.class);
// assetManager.registerLocator("/DEV/TestData/assets/",FileLocator.class);
BulletAppState bas=new BulletAppState();
bas.setDebugEnabled(true);
stateManager.attach(bas);
Spatial floor=makeFloor();
rootNode.attachChild(floor);
RigidBodyControl floor_phy=new RigidBodyControl(0);
floor.addControl(floor_phy);
bas.getPhysicsSpace().add(floor_phy);
Node suzanne=(Node)assetManager.loadModel("models/SuzanneOgre/Suzanne.scene");
suzanne.setLocalTranslation(0,2,0);
Material mat1=new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
mat1.setColor("Color",ColorRGBA.Red);
suzanne.setMaterial(mat1);
rootNode.attachChild(suzanne);
Geometry suzanne_geo=getGeometry(suzanne);
CollisionShape cs=new GImpactCollisionShape(suzanne_geo.getMesh());//new HullCollisionShape(suzanne_geo.getMesh());
RigidBodyControl suzanne_phy=new RigidBodyControl(cs,10f);
suzanne.addControl(suzanne_phy);
bas.getPhysicsSpace().add(suzanne_phy);
}
private Geometry getGeometry(Node suzanne) {
List<Spatial> children=suzanne.getChildren();
for(Spatial s:children){
if(s instanceof Geometry){
return (Geometry)s;
}else if(s instanceof Node){
Geometry g=getGeometry((Node)s);
if(g!=null)return g;
}
}
return null;
}
public static void main(String[] args) {
new TestGImpact().start();
}
}