Hello all,
I am working on building a simple JPCT map editor, I am trying to implement the same navigation style as Unreal Development Kit (or Blender, 3DSMax, Unity etc...).
Basically in these kits holding a mouse button and dragging makes the camera rotate in a cumulative way, so that for example you rotate 20 degrees on the X axis by moving the mouse up. The next time you drag the mouse, the rotation starts from the same point where it was left....
Currently I have a mouse listener that returns the delta x and delta y whenever the mouse is moved. In my World I am using the same camera code on the Wiki:
public void rotateView(int dx, int dy){
Matrix rot = world.getCamera().getBack();
if (dx!=0) {
camera.rotateAxis(camera.getYAxis(), dx / 500f);
}
if (dy!=0) {
rot.rotateX(dy / 500f);
}
}
Which work great I think for a continuous movement like in a FPS game, but currently whenever I click the mouse and drag the rotation starts from the center each time, so basically it jerks back into place at each mouse movement...
Can anyone give me a hint as to how i can implement this?
Thanks a lot!