如何获取原点处球体上顶点的 X、Y、Z 旋转?
嘿,我的游戏世界中有一个球体,我想在这个球体的每个顶点放置一个平面以进行调试。平面的方向应使其平放在球体上(垂直于法线)。球体位于原点,因此所有顶点都相对于原点。
如果我的想法是正确的,我应该能够使用顶点的位置和一些简单的三角学来做到这一点。我尝试了几种组合,但还没有感到高兴。我非常感谢对此的一些帮助。谢谢。
这是我的代码:
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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论