0

I'm fighting with the code, to make it rotate camera around the object. The code that I'm using is:

eyeX = (float) (obj.x + 500*Math.cos(Math.toRadians(angle))*Math.sin(Math.toRadians(angle))); eyeY = (float) (obj.y + 500*Math.sin(Math.toRadians(angle))*Math.sin(Math.toRadians(angle))); eyeZ = (float) (obj.z + 500*Math.cos(Math.toRadians(angle))); Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, obj.x, obj.y, obj.z, 0, 1, 0);

Where obj is the model I want to rotate the camera around, and angle is incremented by 1 with every draw. Can somebody shed a light to this problem, what I'm doing wrong?

4

1 回答 1

0

您想要实现什么精确的相机运动?如果您想在 XZ 平面上转动 obj 并保持恒定高度,您应该这样做:

eyeX = (float)(obj.x + 500*Math.cos(Math.toRadians(angle));

eyeY = (float)(y0); //恒定高度

eyeZ = (float)(obj.z + 500*Math.sin(Math.toRadians(angle));

此外,如果 y0 != 0,则 (0, 1, 0) 不是正确的“向上”向量,并且会扭曲您的视图。

于 2013-04-12T12:03:25.850 回答