布尔囧囧

导航

 

原文链接:http://www.javaeye.com/articles/1225

1984年欧洲的玩家被一款当时发布的游 Knight Lore 震惊了。这款2d游戏居然相当真实的模拟了3d环境,而当时游戏的发布平台是 ZX Spectrum, 48K的内存。这个技术就是isometric perspective(等角投影) 。后来大菠萝、最终幻想等游戏均采用了这种投影技术。点击在新窗口中浏览此图片
等角投影是指在一定范围内,投影面上任何点上两个微分线段组成的角度投影前后保持不变的一类投影。任何点上二微分线段组成的角度投影前后保持不变的一类投影。是角度和形状保持正确的投影,也称正形投影。这种投影类型不同于真3D常见的透视投影,并不以物体对摄像头的远近关系而对其缩放,x,y和z轴的投影角度均为120度。但是出于计算机渲染像素图像图形的特性,和开发方便,很多游戏实际上使用的是二等角投影。
由等角坐标变换到屏幕坐标可以参考这个公式:
点击在新窗口中浏览此图片
由屏幕坐标变换到等角坐标:
点击在新窗口中浏览此图片
以下文章摘自http://www.compuphase.com/axometr.htm:
The figure below shows a cube in the isometric projection as defined by ISO 5456-3.The first object from the left in the figure is the cube unadorned; the second object is the same cube with angles and measures annotated around it. The third and fourth graphics are the top and side views of the perspective scene and they give the camera position that fits the perspective view. The camera position is what you would feed into a 3D renderer (or ray tracer) to create the sprites or tiles for the isometric projection.
点击在新窗口中浏览此图片
Computer games with isometric maps are often tile-based. To make tiles match, the game designer must take into account how diagonal lines are plotted in discrete steps (Bresenham and all that). As it turns out, a line at 30 degrees (sine is 0.5) produces steps that are too irregular. A line at an angle where the tangent is 0.5 does have a nice regular pattern: two steps to the right, one step up. Thus, the isometric projection used by most games tilt the x- and z-axes with approximately 27 degrees (the exact angle is "arctangent(0.5)"). By the way, because the tangent of the angle of the rhombus is 0.5, the rhombus is twice as wide as it is high. This is why many sources mention a 1:2 scale for isometric perspectives. (To make the edges of the rhombuses match, the width of the rhombus should be a multiple of four pixels and the height should be one pixel less than ½ width. In other words, the height:width ratio of a rhombus is usually not exactly 1:2, but rather near 1:2.1. This makes no difference for the principles of the isometric perspective.)
Again, the figure below shows what this isometric projection looks like.
点击在新窗口中浏览此图片
Flash游戏采用等角投影的有PlayFish的餐厅(需要FQ):

 

作者:菩提树下的杨过
出处:http://yjmyzz.cnblogs.com 
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
 
分类: 18.Others
posted on 2015-08-14 19:50  布尔囧囧  阅读(245)  评论(0编辑  收藏  举报