Ok, so I read the last few hours, and I managed to get the mouse to drag the work along the x axis using the following matrix calculation, but no luck with the y axis: where newX = new mouse X coordinate previousX = coordinate of the X mouse on the last update position = mvMatrix camera position = model view matrix or “world matrix”
angle = 0.01*(newX-previousX); rM = mat4.create(); mat4.identity(rM); rM[0] = Math.cos(angle); rM[2] = Math.sin(angle); rM[8] = -Math.sin(angle); rM[10] = Math.cos(angle); mat4.multiplyVec3( rM, position, position )
* Please note that this uses the glMatrix library (http://code.google.com/p/glmatrix/)
And also in order to always stand in front of the position 0,0,0
mat4.lookAt( position, vec3.create([0, 0, 0]), vec3.create([position[0], position[1]+1, position[2]]), mvMatrix );
I got the matrix from http://en.wikipedia.org/wiki/Rotation_matrix. I used the matrix under "main rotations" and Ry
I am sure that this was done before, any help would be appreciated.
Cheers, Josh
source share