开发者

How to get X,Y,Z rotations of vertices on a sphere at the origin?

Hey, I have a sphere in my game world and i would like to place a plane at each vertex on this sphere for debugging purposes. The planes should be orientated so that they lie flat against the sphere (perpendicular to the normals). The sphere is located at the origin, so all the vertices are relative开发者_运维问答 to that.

If my thinking is correct, i should be able to do this using the positions of the vertices and some simple trigonometry. I have tried a few combinations but have had no joy yet. I would greatly appreciate some help on this. Thanks.

Here is my code:

float xRot = RADIANS_TO_DEGREES(sinf(vertex.x/PLANET_RADIUS));
float yRot = RADIANS_TO_DEGREES(cosf(vertex.y/PLANET_RADIUS));
glRotatef(xRot, 1.0, 0, 0);
glRotatef(yRot, 0, 1.0, 0);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜