I create a fixed plane and a fixed camera. And I put objects on the plane. With these codes, I can pick a specific object and remove it correctly. But, if I replace the codes doing remove with rotate or translate. Then it doesn't work.
Remove
public void pickChess() {
SimpleVector dir = Interact2D.reproject2D3DWS(cam, fb, (int)firstX, (int)firstY).normalize();
Object[] res = world.calcMinDistanceAndObject3D(cam.getPosition(), dir, 10000 /*or whatever*/);
if (res[1] != null) {
Object3D pickedObj = (Object3D)res[1];
RigidBody box = (RigidBody)pickedObj.getUserObject();
bodyList.remove(pickedObj.getUserObject());
dynamicWorld.removeRigidBody(box);
world.removeObject(pickedObj);
}
}
Rotate
public void pickChess() {
SimpleVector dir = Interact2D.reproject2D3DWS(cam, fb, (int)firstX, (int)firstY).normalize();
Object[] res = world.calcMinDistanceAndObject3D(cam.getPosition(), dir, 10000 /*or whatever*/);
if (res[1] != null) {
Object3D pickedObj = (Object3D)res[1];
pickedObj.rotateX(50);
}
}]
What happened? Thanks.
Gohome