Turnball trackball in OpenGL

I am having problems implementing trackball rotation on OpenGL. When I rotate my cube using the trackball rotated 90 degrees to the right along the X axis (dragging the mouse from left to right on the screen), and then try to rotate it by dragging my mouse from top to bottom, I expect the cube to rotate along my perspective of the y axis. Instead, it rotates along the y axis along the y axis after rotation, spinning to the side of my perspective.

Can someone show me what I can do wrong?

+5
source share
3 answers

It looks like you are not using quaternions to represent rotation. If you're Google for Arcball Graphics Graphics, you can find the code from Ken Shoemakes in Graphic Gems IV.

, , .

+5

+1 Arcball. .

: Arcball, Gavin Bell, . Glut, .

NeHe, . Bell 3D- , :

+3

. , OpenGL
0   1   2   3
4   5   6   7
8   9   10 11
12 13 14 15

3 , . :

(0, 4, 8), x.
(1, 5, 9) y, (3, 6, 10) z.
?.... , , , - ..... , , . ;).

OpenGL ES:

        Matrix.rotateM(Settings.anchorMatrix, 0, rX, Settings.anchorMatrix[0], Settings.anchorMatrix[4], Settings.anchorMatrix[8]);
        Matrix.rotateM(Settings.anchorMatrix, 0, rY, Settings.anchorMatrix[1], Settings.anchorMatrix[5], Settings.anchorMatrix[9]);
        Matrix.rotateM(Settings.anchorMatrix, 0, rZ, Settings.anchorMatrix[2], Settings.anchorMatrix[6], Settings.anchorMatrix[10]);

anchorMatrix , . Android OpenGL ES .

0

All Articles