Hello everyone,
I have a strange problem: Why the thin “BoxCollisionShape” box cannot to be laid flat on the “HullCollisionShape” plane?
1. The “HullCollisionShape” plane:
public void setConvexRigidBody(Spatial spatial) {
List<Vector3f> list = new ArrayList<Vector3f>();
list.add(new Vector3f(0f, 0.1f, -2f));
list.add(new Vector3f(0f, 0.1f, 2f));
list.add(new Vector3f(-5f, 0.1f, 0f));
list.add(new Vector3f(0f, 0.2f, -2f));
list.add(new Vector3f(0f, 0.2f, 2f));
list.add(new Vector3f(-5f, 0.2f, 0f));
HullCollisionShape hullPiece = new HullCollisionShape(getPointsData(list));
hullPiece.setMargin(0.0f);
RigidBodyControl rigid = new RigidBodyControl(hullPiece, 0);
spatial.addControl(rigid);
bulletAppState.getPhysicsSpace().add(rigid);
}
protected float[] getPointsData(List<Vector3f> dataList) {
float[] data = new float[dataList.size()*3];
for (int i = 0; i < dataList.size(); i++) {
data[i*3+0] = dataList.get(i).x;
data[i*3+1] = dataList.get(i).y;
data[i*3+2] = dataList.get(i).z;
}
return data;
}
2. The thin “BoxCollisionShape” box:
public void setBoxRigidBody(Spatial spatial) {
RigidBodyControl rigid = new RigidBodyControl(1f);
CollisionShape boxShape = CollisionShapeFactory.createBoxShape(spatial);
rigid.setCollisionShape(boxShape);
spatial.addControl(rigid);
bulletAppState.getPhysicsSpace().add(rigid);
}
This is contradictory! Physical engine suggests to use a positive margin (zero margin might introduce problems), but in this case, positive margin introduced problems.
In fact, I have to create BoxShape with positive margin, so I wonder how to solve this problem when using the positive margin to create BoxShape.
https://pybullet.org/Bullet/phpBB3/viewtopic.php?f=9&t=13053
Thanks!