在 OpenGL 中向路径旋转 [英] Rotating Towards Path in OpenGL

查看:23
本文介绍了在 OpenGL 中向路径旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在如何根据 OpenGL 旋转函数 glRotatef(..) 在 3D 空间中旋转对象时遇到问题.

I am having trouble on how to rotate an object in 3D space, based on the OpenGL rotate function glRotatef(..).

glRotatef ( angle , x , y , z )

我的对象在 3D 空间中从一个点移动到另一个点.我希望我的对象沿它行进的方向旋转.

My object is traveling from one point to another in 3D space. I want my object to rotate in the direction it is traveling.

如果我知道我的起点和终点,我将如何找到 glRotatef(...) 函数所需的角度、x、y、z.

How would I find the angle, x, y, z that is needed for the glRotatef(...) function if I know the point where I am starting and the point where I am finishing.

推荐答案

gluLookAt 函数正是您在这里需要的.无需手动计算轴和角度.

The gluLookAt function is exactly what you need here. It will save you from calculating the axis and angle manually.

这篇关于在 OpenGL 中向路径旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆