问题描述
在我们的软件中,我们有一个基于鼠标移动的摄像机,并且在它的心脏有一个季度。
In our software we have a camera based on mouse movement, and a quarternion at its heart.
我们要从这个位置发射弹丸,我们可以做,但是我们要使用相机来瞄准。
We want to fire projectiles from this position, which we can do, however we want to use the camera to aim. The projectile takes a vector which it will add to its position each game frame.
我们如何从给定的摄像机/四元数中获取这样一个向量?
How do we acquire such a vector from a given camera/quaternion?
推荐答案
四元数不代表方向,它表示旋转。您可以定义一个向量,它指向您的相机最初指向的方向(例如(0,0,1)
),然后使用由四元数表示的旋转进行变换。
The quaternion doesn't represent a direction, it represents a rotation. You can define a vector that points in the direction that your camera is pointing initially (e.g. (0,0,1)
) and transform it using the rotation represented by the quaternion.
这篇关于四元相机和弹丸向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!