I was looking into the Cubes plugin, and for some reason I can’t seem to get a collision control to work with it. I have 4 voxels and a box that falls on them as a test. The box falls right through.
[java]
public void simpleInitApp() {
BulletAppState bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
CubesTestAssets.registerBlocks();
BlockTerrainControl blockTerrain = new BlockTerrainControl(CubesTestAssets.getSettings(this), new Vector3Int(1,1,1));
blockTerrain.setBlock(new Vector3Int(0, 0, 0), Block_Wood.class);
blockTerrain.setBlock(new Vector3Int(0, 0, 1), Block_Wood.class);
blockTerrain.setBlock(new Vector3Int(1, 0, 0), Block_Wood.class);
blockTerrain.setBlock(new Vector3Int(1, 0, 1), Block_Wood.class);
Node terrainNode = new Node();
terrainNode.addControl(blockTerrain);
Geometry geom = initBox();
geom.move(3, 10, 3);
RigidBodyControl blockPhys1 = new RigidBodyControl(0f);
RigidBodyControl blockPhys2 = new RigidBodyControl(2.0f);
terrainNode.addControl(blockPhys1);
geom.addControl(blockPhys2);
bulletAppState.getPhysicsSpace().addAll(terrainNode);
bulletAppState.getPhysicsSpace().add(blockPhys2);
rootNode.attachChild(terrainNode);
rootNode.attachChild(geom);
for(int x = 0; x < terrainNode.getNumControls(); x++){
System.out.println(terrainNode.getControl(x));
}
cam.setLocation(new Vector3f(-20, 20, 32));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
flyCam.setMoveSpeed(50);
}
private Geometry initBox(){
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
return(geom);
}[/java]
I’m sure it’s something obvious, but I sure can’t find it. Also, I’m not that experienced with physics in general, but shouldn’t enableDebug show the wireframes of the collidable objects? I guess it’s not because of the unshaded material.