sekocan's picture

Camera Rotation with Mouse

Hello,
I am new to OpenTK and I am trying to visualize a point cloud which I got from a laser scanner. Up to now, I am able to create a Matrix4.LookAt camera and view my points. I am now trying to rotate and maybe move my camera around my points. I am using the method described in this page: http://viewport3d.com/trackball.htm
It looks very nice but I have a problem. My code is something like this:

Matrix4 lookat = Matrix4.LookAt(2000, -2000, 1000, 0, 0, 0, 0, 0, 1);
Vector3 scale = new Vector3(4, 4, 4);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref lookat);
GL.Scale(scale);
GL.Rotate(angle, axis);

I am getting the angle and axis values as described in the link above.
I was updating this code in every frame, then I realized that I was creating the lookat matrix everytime, so my camera wasn't rotating of course. Then I moved the first line to the load event (by making the lookat variable global of course), but I still cant't rotate the view. I can see only a little movement and then the camera resets itself.

What I need to do, I guess, is after rotating the lookat matrix, I need to overwrite it on itself and continue, but I couldn't find how to do this after looking for it on Google for hours.

Can anyone help me?
Thanks.