0

我不确定如何旋转我的对象。目前我有一个四边形,我希望能够以 45 度角查看它,我已经设置了我的模型视图投影矩阵。我知道我应该在着色器中而不是在实际代码中执行此操作,稍后我会更改它,但这里有一些代码。

    bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
p_Matrix = PVRTMat4::PerspectiveFovRH(PVRT_PI / 6, (float) PVRShellGet(prefWidth) / (float) PVRShellGet(prefHeight), 4.0f, 1000.0f, PVRTMat4::OGL, bRotate);
PVRTVec3 view_From(2, 2, 0);
v_Matrix = PVRTMat4::LookAtRH(view_From, view_At, view_Up) * PVRTMat4::RotationX(45);
cam_Pos = view_From;

PVRTMat4 modelView, world, mMVP;
world = PVRTMat4::Identity();
modelView = v_Matrix * world;
mMVP = p_Matrix * modelView;

if(PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen)) // If the screen is rotated
    mMVP = PVRTMat4::RotationZ(-1.57f);

/*
    Pass this matrix to the shader.
    The .m field of a PVRTMat4 contains the array of float used to
    communicate with OpenGL ES.
*/
glUniformMatrix4fv(m_ShaderProgram.auiLoc[eMVPMatrix], 1, GL_FALSE, mMVP.ptr());

我试过旋转 mMVP 矩阵,但它没有效果。并且还尝试旋转模型视图和 v_matrix(视图矩阵)。我使用了 SDK 提供的一个名为 PVRTMat4::RotationX(45); 的函数。

4

1 回答 1

0

您可以使用 PVRTMat4::scale(fx,fy,fz) 函数来获得您需要的 44 旋转矩阵。设置 fx=45 和 fy=0 和 fz=0。然后将返回的矩阵乘以 mMVP 矩阵。

于 2014-02-13T09:35:05.397 回答