开发者

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

开发者 https://www.devze.com 2023-01-03 15:44 出处:网络
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 (

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

精彩评论

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

关注公众号