在 Flash 中绘制透视建筑物(GTA1/2 风格)?
任何人都知道我如何用 3D 透视高度绘制建筑物,就像在原始 GTA 中一样: http://www.gtanetwork.it/gtaold/pics/screen/gta1_01.jpg 在 Flash 中?
我尝试使用 beginBitmapFill() 并绘制多边形,但纹理看起来不正确,因为它缺乏正确的深度。
有人有想法吗?不是在寻找完整的 3D 引擎,我只是希望建筑物具有深度,其他所有内容都将在同一平面上。
Anyone know how I could go about drawing buildings with 3d perspective height, like in the original GTAs: http://www.gtanetwork.it/gtaold/pics/screen/gta1_01.jpg in Flash?
I've tried using beginBitmapFill() and drawing the polygons but the texture doesn't look right because it lacks the correct depth.
Anyone have ideas? Not looking for a full 3D engine, I just want the buildings to have depth, everything else will be on the same plane.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您会看到,透视纹理映射是任何 3D 引擎的主要功能之一。这就是我们拥有它们的原因。 3D 点透视分配、用颜色填充多边形、甚至 z 缓冲都很容易 - 所有这些仍然很容易。
透视纹理映射更进一步...它涉及到纹理提供程序和转换器,并且转换器必须分割顶点(对于真正的透视),然后在位图上应用仿射变换,绘制每个顶点...如果您想用自定义(甚至是时间线......这将非常烦人)代码来制作它,那么这一切都很难维护。 3D 引擎提供了更多的功能(阴影也很好),并且非常容易维护。
我会推荐 PaperVision 3D,尽管您必须自己分割顶点(或者 AFAIK PV3D 不自动支持)。
在有人说这很容易通过 BitmapData 的自定义循环来完成之前,分配像素......事实并非如此。透视不是线性的 - 并且非线性循环在那里会非常慢。
You see, perspective texture mapping is one of the main features in any 3D engine. That's WHY we have them. It is easy to do the 3D point perspective allocation, as well as just filling polygons with colours, even z-buffering - all these are still quite easy.
Perspective texture mapping goes a little bit further... It involves having a texture provider and transformer, and the transformer has to split up the vertices (for real perspective), then apply affine transformations on the bitmap, draw each of them... That is all hard-to-maintain if you want to make it in custom (or timeline even... that would be VERY annoying) code. 3D engines provide much more features (shading would be nice too), and are VERY easy to maintain.
I would recommend PaperVision 3D, although you will have to split the vertices by yourself (or AFAIK PV3D doesn't support that automatically).
And before anybody says that this would be easy to do in just a custom loop-through a BitmapData, allocating the pixels... It isn't. Perspective isn't linear - and a non-linear loop would be very slow there.