46
Support / Re: Mouse-drag camera rotation (UDK like)
« on: October 09, 2011, 02:39:26 pm »
Thank you Egon,
I implemented the code you wrote in this way:
However it works in the same way as the simpler code above. So if there is a cube in the scene it works fine if you point at the cube and drag, but if you point away and drag the camera jerks back to point at the cube....
If you think of Google Maps for instance? When you use the street view? And you are able to point anywhere in the screen and dragging the mouse gradually moves the camera/shifts the focus to reflect the mouse movement?
I am thinking that maybe you need to return the current rotation of the camera and add/sub struct from it instead of rotating the camera from scratch at each mouse drag.... But I couldnt find a method on Camera to return the rotation, only the axes?
Anyhow, thanks for your prompt help!
I implemented the code you wrote in this way:
Code: [Select]
public void rotateView(int dx, int dy){
if (dx !=0 || dy != 0){
SimpleVector line =new SimpleVector(dx, 0, dy);
Matrix m = line.normalize().getRotationMatrix();
m.rotateAxis(m.getXAxis(), (float) -Math.PI/2f);
camera.rotateAxis(m.invert3x3().getXAxis(), line.length() / 500f);
}
}
However it works in the same way as the simpler code above. So if there is a cube in the scene it works fine if you point at the cube and drag, but if you point away and drag the camera jerks back to point at the cube....
If you think of Google Maps for instance? When you use the street view? And you are able to point anywhere in the screen and dragging the mouse gradually moves the camera/shifts the focus to reflect the mouse movement?
I am thinking that maybe you need to return the current rotation of the camera and add/sub struct from it instead of rotating the camera from scratch at each mouse drag.... But I couldnt find a method on Camera to return the rotation, only the axes?
Anyhow, thanks for your prompt help!