在帮助其他用户提出有关响应触摸事件 Android教程的问题之后,我下载了源代码,并且对我所看到的内容感到非常困惑.该教程似乎无法决定是否要使用行向量或列向量,它看起来都混淆了我.
在Android Matrix页面上,他们声称他们的约定是列向量/列主要,这是OpenGL的典型.
我是对的,还是我缺少的东西?以下是它的相关部分:
首先通过乘以mProjMatrix*mVMatrix创建MVPMatrix.到现在为止还挺好.
// Set the camera position (View matrix)
Matrix.setLookAtM(mVMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
// Calculate the projection and view transformation
Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0)
Run Code Online (Sandbox Code Playgroud)
接下来他们在MVPMatrix的左侧附加一个旋转?这看起来有点奇怪.
// Create a rotation for the triangle
Matrix.setRotateM(mRotationMatrix, 0, mAngle, 0, 0, -1.0f);
// Combine the rotation matrix with the projection and camera view
Matrix.multiplyMM(mMVPMatrix, 0, mRotationMatrix, 0, mMVPMatrix, 0)
Run Code Online (Sandbox Code Playgroud)
以非转置顺序上传.
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
Run Code Online (Sandbox Code Playgroud)
最后在他们的着色器中,向量*矩阵乘法?
// the matrix must …Run Code Online (Sandbox Code Playgroud)