Thanks for your quick reply. Much appreciated. This seems to be what I am looking for. I am now trying to make it work in practice, and am having a few problems. The values returned by this method do not make sense to me, I must be doing something wrong. As per the below picture, I have a plane (black), the translation vector for the next frame (red) and the ground (blue).
I have enabled COLLISION_CHECK_OTHER on the ground, with collision improvement. To check collision, I use the following code:
public float checkCollision(SimpleVector sv)
{
// sv is the opposite the plane movement
final int id = ground.checkForCollision(sv, 10);
if(id != Object3D.NO_OBJECT)
{
return ground.calcMinDistance(ground.getTransformedCenter(), sv);
}
return Object3D.NO_OBJECT;
}
In this scenario, the collision is never detected (id is always Object3D.NO_OBJECT even if I fly trough the sea). Also when I check values for the min distance, it varies between 1E12 (max float I guess) and figures between 50 and 200 depending on the areas I fly over but not depending on my altitude. I would like to remind that the ground is a set of Object3D laoded via 3DS and regrouped via the following code, but should still behave as an atomic object right?
private static Object3D loadModel(InputStream file, float scale) {
Object3D[] model = Loader.load3DS(file, scale);
Object3D o3d = new Object3D(0);
Object3D temp = null;
for (int i = 0; i < model.length; i++) {
temp = model[i];
temp.setCenter(SimpleVector.ORIGIN);
temp.rotateX((float)( -.5*Math.PI));
temp.rotateMesh();
temp.setRotationMatrix(new Matrix());
o3d = Object3D.mergeObjects(o3d, temp);
o3d.build();
}
return o3d;
}
Thanks for you patience
Nicolas