0
我正在嘗試使用旋轉和平移來製作包含6個三角形的六角形。我不想多次進行翻譯調用,而是希望將三角形向下翻譯一次,並圍繞Z軸以60度旋轉六次(我的草圖可能有助於解釋:http://i.imgur.com/SrrXcA3.jpg)。重複drawTriangle()和rotate()方法六次後,我應該有一個六邊形。如何在OpenGL 2中圍繞(0,0,0)處的頂點旋轉三角形
目前我的代碼看起來是這樣的:
public void onDrawFrame(GL10 unused)
{
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); //start by clearing the screen for each frame
GLES20.glUseProgram(mPerVertexProgramHandle); //tell OpenGL to use the shader program we've compiled
//Get pointers to the program's variables. Instance variables so we can break apart code
mMVPMatrixHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "uMVPMatrix");
mPositionHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "aPosition");
mColorHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "aColor");
//Prepare the model matrix!
Matrix.setIdentityM(mModelMatrix, 0); //start modelMatrix as identity (no transformations)
Matrix.translateM(mModelMatrix, 0, 0.0f, -0.577350269f, 0.0f); //shift the triangle down the y axis by -0.577350269f so that its top point is at 0,0,0
drawTriangle(mModelMatrix); //draw the triangle with the given model matrix
Matrix.rotateM(mModelMatrix, 0, 60f, 0.0f, 0.0f, 1.0f);
drawTriangle(mModelMatrix);
}
這裏是我的問題:它出現在我的三角形不會繞着(0,0,0),而是將其圍成的三角形的中心旋轉(如圖所示在這張照片中:http://i.imgur.com/oiLFSCE.png)。
是否有可能圍繞(0,0,0)旋轉三角形,其頂點位於哪裏?