0

I have, what I think is going to be a very obvious question to some so I'm hoping someone could quickly clean it up for me. I have an XNA app where I draw a grid of vertices and the camera is positioned 20.0f above it. If I place the camera at 0, -20, 0 and the target at 0, 0, 0 then the vertices don't appear. If I adjust the X or the Z axis a little bit to 0.1 then the vertices show. Why is this?

Thanks

4

1 回答 1

0

在没有看到您的代码的情况下,最可能的原因是您的视图矩阵的向上向量与您的相机正在寻找的方向平行。如果您的相机在 0,-20,0 并且您的目标是 0,0,0 并且您的向上向量是 0,1,0,那么就会发生这种平行情况。稍微偏移位置或目标可以消除这种平行情况。

当您运行 CreateLookAt() 时,幕后框架代码将向上矢量与相机正在寻找的方向(目标 - 位置)相交。如果被交叉的两个向量是平行的,它会返回一个零长度的向量结果,这会破坏视图矩阵。

道德:永远不要让你的向上矢量平行于相机的方向。

于 2013-06-11T13:22:49.760 回答