I have a touchRotationMatrix that I do the following:
Matrix.setIdentityM(identity, 0);
Matrix.rotateM(identity, 0, x, 0,1,0);
Matrix.multiplyMV(v, 0, identity, 0, v, 0)
Matrix.rotateM(identity, 0, y, 1,0,0);
Matrix.rotateM(identity, 0, y, v[0],v[1],v[2]);
Matrix.multiplyMM(touchRotationMatrix, 0, identity, 0, touchRotationMatrix, 0);
X and Y are the normalized rotation deltas.
This is applied to my model matrix like so:
Matrix.multiplyMM(mModelMatrix, 0, mModelMatrix, 0,touchRotationMatrix,0);
The problem here is that any rotation that I do is on its own axes.
Let me illustrate why I don't want this:
If I rotate from left to right, it's like turning your head which is good. If I rotate up first, then rotate from left to right, I end up looking at the floor or the ceiling. This makes sense because it is rotating on its axes.
My question is, how do I make it that the x rotation isn't happening on its own axes?
I hope I am clear, any guidance or help would be very much appreciated! Thanks!
PS I'm not an expert in OpenGL nor in LinearAlgebra.
Not so clear but either
Matrix.setRotateM(identity, 0, y, 1,0,0);
Matrix.multiplyMM(touchRotationMatrix, 0, identity, 0, touchRotationMatrix, 0);
Matrix.rotateM(touchRotationMatrix, 0, x, 0,1,0);
or
Matrix.setRotateM(identity, 0, x, 0,1,0);
Matrix.multiplyMM(touchRotationMatrix, 0, identity, 0, touchRotationMatrix, 0);
Matrix.rotateM(touchRotationMatrix, 0, y, 1,0,0);
might work as you expect.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.