Use rotateM() of Matrix to rotate matrix from SurfaceTexture but corrupt the video output

拜拜、爱过 提交于 2019-11-29 07:33:57

fadden's rotation matrix about the z-axis needs to be followed by the correct translation to bring it back on-screen, so to speak. I've tested all 3 rotations below on SurfaceTexture video:

ROTATE 90

Matrix.rotateM(mTmpMatrix, 0, 90, 0, 0, 1);
Matrix.translateM(mTmpMatrix, 0, 0, -1, 0);

ROTATE 180

Matrix.rotateM(mTmpMatrix, 0, 180, 0, 0, 1);
Matrix.translateM(mTmpMatrix, 0, -1, -1, 0);

ROTATE 270

Matrix.rotateM(mTmpMatrix, 0, 270, 0, 0, 1);
Matrix.translateM(mTmpMatrix, 0, -1, 0, 0);

You're rotating about the X axis:

Matrix.rotateM(mTmpMatrix, 0, 270, 1f, 0, 0);

By convention that runs from left to right. The axis acts like an axle; by flipping it 270 degrees, you're rotating the plane so you're viewing it edge-on, and it's effectively vanishing. I think what you're seeing is essentially uninitialized data, and if you call glClear() you'll see the background color instead.

Try rotating about the Z axis, which is a line pointing out of the screen:

Matrix.rotateM(mTmpMatrix, 0, 270, 0, 0, 1);

(It might also be interesting to experiment with a rotation of about 15 degrees about the X axis just to see how that looks. When fiddling with matrices it's often useful to start with small values.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!