PDA

View Full Version : Rotation around screen center



admirandis
12-26-2012, 11:56 PM
Hi guys,
I'm trying to write an arcball which rotates around the window center (z=0). Unfortunatly I also want to be able to move my objects with this arcball; i.e. rotate, translate scale.
My problem is that I can't figure out how to handle the rotation with the translation. Currently I'm doing this:



// Apply "arcball"-modifications to OpenGL.
GL.Translate(windowCenterVector);
GL.MultMatrix(ref rotationMatrix);
GL.Scale(this.scale, this.scale, this.scale);
GL.Translate(-windowCenterVector);
GL.Translate(this.translation);


Unforunatly the last translation which applies the arcball offset is affected by the rotation. I tried to transform it with the inverse of the rotation matrix but so I changed the rotation center...

If someone might be able to explain this to me it would be great!

I created a sample-project with OpenTK so if someone want's to checkout the full code: http://go4x.de/share/WindowsFormsApplication1.zip

Greetings - Thomas