旋转走向在OpenGL路径路径、走向、OpenGL

2023-09-08 01:10:49 作者:失去了别回头放手了别挽留

我有关于如何旋转,在三维空间的物体麻烦,基于OpenGL旋转功能glRotatef(..)。

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.

我怎么会找角度,X,Y,Z所需要的glRotatef(...)函数,如果我知道我开始的点,在那里我完成点。

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.