使用opengl进行真正的等角投影
Is there a simple way to have isometric projection?
I mean the true isometric projection, not the general orthogonal projection.
(Isometric projection happens only when projections of unit X, Y and Z vectors are equally long and angles between them are exactly 120 degrees.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试使用 gluLookAt
结果
我们可以绘制一个立方体检查平行线是否确实平行
Try using gluLookAt
Results in
We can draw a cube to check that parallel lines are indeed parallel
等角投影只是使用具有特定旋转角度的正投影。
您应该能够通过正交投影选择 8 个潜在方向中的任何一个,并获得模型的完美等距视图。 只需按照您引用的 Wiki 文章中的数学公式来设置视图矩阵,并为您的投影矩阵进行正交投影,就可以了。
An isometric projection is just a matter of using an orthographic projection with a specific rotation angle.
You should be able to choose any of the 8 potential orientations, with a orthographic projection, and get a perfect isometric view of your model. Just follow the math in your referenced Wiki article for setting up the view matrix, and do an orthographic projection for your projection matrix, and you're all set.
也许我不太正确地理解数学,但是你不能按照维基百科链接中的解释来定位你的相机并使用标准的正交投影吗?
即使不一样,投影堆栈也完全取决于您。
Maybe I'm not quite grokking the math correctly, but couldn't you just position your camera as it explains in that Wikipedia link and use a standard orthogonal projection?
Even if it's not the same, the projection stack is entirely up to you.
如果你不想使用 GLU,这里是使用 glOrtho 的基本框架
,
如果你想在 2d 和 2.5d 之间切换(这样你就可以绘制你的 UI),那么我有类似的函数来进入和离开 2d 模式,例如
If you do not want to use GLU, here is bare bones using glOrtho
and call something like this
should you want to toggle between 2d and 2.5d (so you can draw your UI) then I have similar functions to enter and leave 2d mode e.g.