2013-04-06 66 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