(DirectX) 生成旋转矩阵以匹配向量
如何获取一个向量并生成一个矩阵,该矩阵将旋转网格以沿着该向量面对?
细节:
我希望我的播放器的模型能够旋转以面向相机所观察的方向。现在,它总是指向它开始的方向,而转动只是让镜头看向玩家的一侧。
我尝试过 D3DXMatrixYawPitchRoll,并取得了部分成功。然而,我注意到与完美对准的时间有些偏差,并且当我在偏航时尝试俯仰时,它出现了一些奇怪的不稳定问题。
How can I take a vector and generate a matrix that will rotate a mesh to face along that vector?
Specifics:
I want the model for my player to rotate to face the direction that the camera is looking. Right now, it always points in the direction it started in, and turning just makes the camera look at the player's side.
I have experimented with D3DXMatrixYawPitchRoll, with partial success. However, I noticed some drift in time from perfect alignment, and it had some strange wobbly issues when I tried pitching while yawing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它的工作方式几乎与我发布的答案完全相同:
旋转一个球体,使其极点朝向相机
主要的变化是“相机位置”改为“物体”原点”你做“对象原点”-“相机位置”。
It will work in almost exactly the same way as this answer I've posted:
Rotate a sphere so that its pole heads towards the camera
The main change is that instead of "camera position" - "object origin" you do "object origin" - "camera position".