Here's a routine that might be a little more pluggable.
This just gets you the selected object. It's up to you to figure how to move it about, based on the physics and layout of your world.
Code Select
private int selectAnyObjectAt( int mouseX, int mouseY){
SimpleVector ray=Interact2D.reproject2D3DWS(mCamera, mFrameBuffer, mouseX, mouseY).normalize();
Object[] res = mWorld.calcMinDistanceAndObject3D(mCamera.getPosition(), ray, 10000F);
if (res==null || res[1] == null || res[0] == (Object)Object3D.RAY_MISSES_BOX) {
Log.d("SELECTION", "You missed! x="+mouseX+" y="+mouseY);
selectedObject = null;
return -1;
}
Object3D obj = (Object3D)res[1];
Log.d("SELECTION", "x="+mouseX+" y="+mouseY+" id2="+obj.getID()+" name="+obj.getName());
selectedObject = obj;
return obj.getID();
}
This just gets you the selected object. It's up to you to figure how to move it about, based on the physics and layout of your world.