2013-04-06 74 views
0

所有更改四的旋转的目的,中心在OpenGL ES 2.0

使用代码低于我四移动位置。但是,我不希望发生这种情况,我所追求的只是旋转中心的移动。

有没有人有任何想法?

注意,如果我在旋转前放置一个翻译功能,它没有任何效果。

任何帮助,将不胜感激。谢谢。

Matrix.setIdentityM(mRotationMatrix, 0); 

Matrix.setRotateM(mRotationMatrix, 0, 45, 0, 0, 0.1f); 

Matrix.translateM(mRotationMatrix, 0, quadCenterX, quadCenterY, 0f); 

// Combine the rotation matrix with the projection and camera view 
Matrix.multiplyMM(mvpMatrix2, 0, mvpMatrix, 0, mRotationMatrix, 0); 

回答

3

要绕不同的旋转中心:

Matrix.setIdentityM(mRotationMatrix, 0); 

Matrix.translateM(mRotationMatrix, 0, quadCenterX, quadCenterY, 0f); 
Matrix.rotateM(mRotationMatrix, 0, 45, 0, 0, 0.1f); 
Matrix.translateM(mRotationMatrix, 0, -quadCenterX, -quadCenterY, 0f); 

请注意,你必须使用rotateM而不是setRotateM,作为setRotateM覆盖以前的矩阵。

+0

太谢谢你了@ I47 - 我已经一遍又一遍地了这么久,这只是因为我用setRotateM而非rotateM - 你注意到的第一个!它的工作原理:-)所以再次,谢谢! – Zippy 2013-04-06 19:51:17