2013-07-02 136 views

回答

1

我不認爲你想翻譯你的MVP矩陣,你想創建一個單位矩陣,翻譯它,然後乘以mMVPMatrix

3

以下代碼:

Matrix.setRotateM(mRotationMatrix, 0, mAngle, 0, 0, -1.0f); 
Matrix.multiplyMM(mMVPMatrix, 0, mRotationMatrix, 0, mMVPMatrix, 0); 

指:

mRotationMatrix <-- Create a rotation matrix of mAngle degrees around axis -Z 
mMVPMatrix <-- The product of mRotationMatrix and mMVPMatrix 

雖然以下:

Matrix.translate(mMVPMatrix,0,dx,dy,0); 

指:

mMVPMatrix <-- Translate mMVPMatrix of dx along X axis and dy along Y axis 

我認爲mMVPMatrix是一個透視投影(並且MVP的P通常表明這一點)。通常你不會翻譯已經投射的東西。請改爲:

Matrix.setIdentityM(mTranslationMatrix, 0); 
Matrix.translateM(mTranslationMatrix, 0, dx, dy, 0); 
Matrix.multiplyMM(mMVPMatrix, 0, mTranslationMatrix, 0, mMVPMatrix, 0);