做了几个基于Flash平台的3D的项目,一路走来收获颇多。Away3D作为一个开源的Flash3D引擎,在3D页游领域,无疑是当前OGRE在国内的地位。
翻译出了多年前做Away3D中国社区的时候翻译的一篇文章,以此记录这段难忘的经历!
什么是Away3D?(What is Away3D?)
Away3D是一个开源的,基于Flash平台的实时3D引擎.这个项目最初是由Alexander Zadorozhny和 Rob Bateman 在2007年开始的。没想到这一发就不可收拾。下面是一些Away3D重要的特性,在此呈现给大家。(译注:希望大家能够喜欢,哈哈)
Away3D is an open source, real time 3D engine for the Flash Platform. The project was started by Alexander Zadorozhny and Rob Bateman in 2007 and has been evolving non-stop ever since. Below is a list of some of the most important features of the Away3D engine.
100%开源(100% Open Source)
Away3D引擎基于Apache2.0协议开源,这表示你可以以任何目的免费使用(当然商用也是一样的)。Away3D现在由Away Foundation管理,并且受到Adobe支持,已经成为了Adobe Flash平台的官方API。
(译注:既然说到这里了,我们还是欣赏一下LOGO吧,虽然大家肯定不陌生,但是文档没有图,效果不是太好)
The Away3D engine is open source under the Apache 2.0 license, and is free to use for any purpose, including commercial projects. Away3D is now managed by The Away Foundation, and supported by Adobe systems as an official API for the Flash Platform.
雄厚的社区支持(A Massive Community)
(译注:Adobe既然把away3d纳入官方api,这当然是有原因的。并且,也表示away3d的后续发展应该会加速。 )
这个项目从来就没有像这样忙过(这是直译,我大概能感觉到意思,但是实在没搞懂他到底想表达什么)。在强大的Flash3D社区支持下,一群积极而NB的贡献者,一个热闹的论坛,数以百计的在线例子和教程。同时,你还可以找到一些扩展资源用来在Away3D库上使用和构建项目。你可以走“这里”进入我们的论坛,走“这里”访问我们的github源码库。
The project has never been so busy. With the largest online Flash 3D community, an active set of talented contributors, a buzzing forum, hundreds of examples and tutorials online, you will find extensive resources for using and building upon the Away3D library. Visit our forums here. Visit and watch our GitHub repositories here.
数以百计的例子和教程(Hundreds of Examples and Tutorials)
Away3D的每一次发布,都搭载了一系列可下载的例子源代码。也可以在我们的GitHub上找到。这些例子涵盖了从基础入门者到高级使用者的需求。 新的特性,最好的粒子效果等等。 并且提供了能够让你最快熟悉Away3D引擎的方案。Away3D社区同时还维护了一个教程的wiki页面。 力在为大家提供一个能够持续增涨并且包含多种多样的资源和材质包。
Every release of the Away3D library ships with a downloadable set of example sources that can also be found on GitHub. These examples cover usage of the engine from beginner to advanced levels, new features, best practices etc, and provide the fastest way of getting acquainted with the engine. The Away3D community also maintains a tutorials wiki, providing an ever growing set of complete and comprehensive resource material.
易于理解的API(Comprehensive API)
在众多有经验的FLASH程序员的努力下,Away3D库向大家提供了一套容易理解,使用简单的API。它灵活的设计思路绕开了Stage3D API的复杂,同时也得到了当下Flash社区想要的效率。最终,Away3D成为了一个能够简单且优雅地满足你需求的工具。
完整的文档和引用(Class说明)
完整的文档,请访问“引用”章节
Developed by experienced Flash programmers, the library maintains a comprehensive, easy to use API. It’s flexible design wraps the power of the Stage3D API in a way that bypasses the low level complexities, but retains the speed and efficiency so desired by today’s Flash community. As a result, Away3D offers the tools necessary to achieve what you require in as simple and elegant a way as possible.
Full Documentation and Reference
Fully documented. Visit the reference section.
GPU加速(GPU Acceleration)
这已经是Away3D第四次轮回了。现在它利用了Flash Player 11最新的Stage3D API.可以在PC和移动设备上完整地拥有3D GPU加速能力。这表示它已经有潜力去实现震惊的视角效果,额外的物理模拟和游戏逻辑运算,每帧上百万的三角面,以及每秒60帧的效率。
In it’s fourth incarnation, Away3D now takes advantage of Flash Player 11’s Stage3D API, enabling full 3D GPU acceleration for desktops and mobile devices. This offers the potential for stunning visual effects, extra processing for the likes of physics simulations and game logic, and scenes rendering up to a million triangles per frame, maintaining a steady 60fps performance.
强大的渲染能力(Powerful Rendering)
Away3D强大的材质系统使你不需要面对头痛的原始Shader代码就能够实现一些高级渲染效果模拟。模块化的设计方案使你可以整出(使用+联合+创建 = 整出)一大堆光照方法。比如phong着色(冯氏着色,即 双线性法线插值法。 具体的用Shader实现的话,就是把法线通过vs输出到ps,在ps中做法线 dot 光照方向的运算就可以了。 因为vs到ps的向量在光栅化阶段会进行插值,默认的就是双线性插值。 再说白了,就是 逐像素光照)。点光源光照,方向光光照,级联阴影(即 cascading shadow map。人称 CSM 就是它了。) 法线映射,高光映射,全局光照模拟,雾效和边缘光照。 太多太多了,枚举不完。
The powerful material system in Away3D allows advanced shading simulations without the headache of dealing with raw shader code, implementing a rich modular system that allows you to use, combine and create a large set of illumination methods such as phong shading, point and directional lighting, cascading shadows, normal and specular mapping, global illumination, fog and rimlighting effects and much, much more.
健壮的场景图(Robust Scenegraph)
Away3D渲染管线实现了一个高度优化的场景图,你可以很方便地创建出一个复杂的,嵌套的,且多关卡的场景。 它内建的裁剪和剔除算法能够确保GPU只接受你视野内需要渲染的物体。同时它也管理了CPU和GPU之间的负载平衡问题,以使我们在除场景渲染以外能够获得更好的效率。这也是一个健壮的渲染引擎所需具备的基本特征。
The rendering pipeline implements a highly optimised scenegraph that allows the setup of complex, nested, multi level scenes. Built in clipping and culling algorithms ensure that the GPU only receives what it needs to render the view. The balance between CPU and GPU calculations is carefully managed to get the best possible performance out of the scene, a fundamental aspect of any robust rendering engine.
后期处理效果(Post Processing Effects)
Away3D对GPU的利用当然不只是3D渲染。在那个可扩展的叫”filters”的包里,我们提供了各种各样的令人瞠目结舌的后期处理效果。当然,你可以在你的实时渲染的场景里添加和使用它们。比如 全屏泛光,模糊,景深,运动模糊等。
The library takes advantage of the GPU even beyond 3D rendering. In the extensible filters package, there are a variety of stunning post-processing effects that are applied to the scene in realtime, such as bloom, blur, depth of field and motion blur.
对效率和生产率的平衡(Balanced Performance and Productivity)
这个引擎的核心,以及它的扩展特性,都是基于效率思的。最终的API提供了最理想化的资源和场景元素的使用方式。同时也不妨碍生产率。Away3D最原始的设计是作为复杂的应用和游戏的支持者。而它本身的框架具备可扩展的特点,也能够确保一个应用程序开发的正常进行。
The engine’s core, as well as its extensive feature set is architected with performance in mind. The resulting API encourages optimal use of resources and scene elements, without getting in the way of productivity. Away3D is fundamentally designed to play a supporting role in complex applications and games, and the extensible nature of the framework ensures a robust application development approach.
可配置的交互性(Configurable Interactivity)
任何3D引擎都需要和它的使用者进行交互。Away3D提供了鼠标,触屏等交互方式。提供了GPU和CPU的两种拾取方式,以达到最好的效率。所有的事件都通过分法器方式进行处理,这使得在和3D对象交互时简直就是小菜一碟。
Any 3D engine needs to interact with its users. Away3D supports mouse & touch interactivity, with the option for either GPU or CPU-based picking systems to get the best performance. Events are handled in a familiar dispatcher-driven way, making interactive assignment on 3D objects a breeze.
物理(Physics)
Away3D无缝集成了它自己的物理库。AwayPhycis. 这个扩展使你可以用几行代码就为你的3D场景添加上物理支持。AwayPhysics 使用 Adobe XC APIs 进行加速。 并且基于NB的Bullet物理引擎。当然,那些API已经专门为Away3D封装过了,提供了一个优化的,最贴近Away3D的物理引擎实现。
Away3D integrates seamlessly with its own physics library, AwayPhysics. This addition enables full physics support on your 3D scenes with just a few lines of code. AwayPhysics is accelerated by Adobe XC APIs and is based on the popular Bullet Physics Engine. The API wrapper is specifically designed for Away3D, providing an optimized, closely coupled physics engine implementation.
动画支持(Animation Support)
Away3D提供了完全的骨骼动画,顶点动画,粒子动画和轨迹支持。当GPU加速可用的时候,动画系统会自动将其开启。尽可能降低CPU的开销。 骨骼动画使用了一个分层结构,根据顶点的骨骼权重进行蒙皮(简称:蒙皮骨骼动画). 顶点动画使用了基于关键帧插值的方式来实现。粒子动画则使用静态或者动态参数来调整一个粒子的行为。 更多……
Away3D enjoys full support for skeleton animation, vertex animation, particle animation and path animation. GPU acceleration is implemented in the animation systems whenever possible, keeping CPU use as low as possible. Skeleton animation uses a hierarchical rig arrangement, with weighted skinning on the verticies. Vertex animation uses frame-based interpolation of individual geometry poses. Particle animation can use static or dynamic parameters for adjusting particle behaviour. And more…
粒子系统(Particle Systems)
引擎提供了一个可以高度灵活配置的基于的GPU粒子系统 API。使你可以实现成千上万的令人激动的视角效果。
The engine supports a highly configurable GPU-based particle API providing the means for thousands of exciting visual effects.
Starling库集成(Starling Integration)
Away3D集成了Starling,使你可以很容易地同时使用这两个基于GPU加速的3D和2D库。由于两个库都是GPU加速的,所以这可能会导致一些资源限制问题。 但是对于Away3D来说,你不用担心这个问题。使用AWAY3D和Starling把你的2D和3D划分到不同的层,然后开发一个100%的GPU加速的图形程序吧。(其实,不是太懂他想说什么。上面说了会出现资源限制问题,后面又说AWAY3D不用担心。然后又继续说Away3D和Starling一起用。 看来,鸟文功力太浅啊。)
Away3D integrates effortlessly with the popular Starling API for 2D graphics, allowing both libraries to be used in the same project at the same time. As both libraries use the GPU for rendering, problem can arise from resource restrictions on the device. With Away3D, you won’t even have to think about these problems - layer your 2D and 3D content with Away3D and Starling and develop 100% GPU based graphics applications.
扩展的文件IO支持(Extensive File I/O Support)
Away3D并不会忽略除3D以外的内容。工作流永远是一个中心话题。 我们不仅支持大量的文件格式,如DXF,AC3D,COLLADA,MAX3DS,MD2,MD5,OBJ。 并且,我们也开发出了我们自己的强大的,简洁的AWD格式。以及相应的3D工具插件。 在你开发你的3D程序的时候,你就会发现AWD格式将会是一个珍贵的资源。
Away3D is not isolated from the rest of the 3D world. Workflow has always been a central topic and not only do we support a wide variety of file formats such as DXF, AC3D, Collada, Max3DS, MD2, MD5, OBJ, but we have also developed our own powerful and compact AWD format. With plugins for several 3D authoring environments, you will find the AWD format to be an invaluable resource when developing content for your Away3D applications.
Prefab3D 兄弟应用(Prefab3D Companion App)
哈哈,对工作流的支持并没有在这里停下,Prefab3D兄弟应用提供了一些常见的工作流需要的任务,并且使用非常简单。它有着一个非常易于理解的IDE,能够让你快速调整你的资源并在AWAY3D里使用。
Workflow support doesn’t stop there. The Prefab3D companion application accelerates common workflow tasks in an easy to use, comprehensive IDE for quickly adapting your content for use within Away3D. Prefab3D.
旧版本支持(Legacy Support)
当前的Away3D 4.x版本是基于Flash Player 11的Stage3D API构建的,以便能够利用当前PC和移动设备上的图形处理器。但是,如果你需要使用旧版本的FLASH PLAYER进行3D应用程序开发,你可以很方便地切换到老的引擎版本。开发团队在努力地维护多个版本的API。因此,你可以找到多个Away3D版本之间的共性,并且能够以此容易地在各个版本的API之间转换。
更多,更多,更多
立体渲染,3D声效,OOXX工具,数据序列化,敬请期待……
The current version of Away3D 4.x is built on the Flash Player 11’s Stage3D API to make the most of current cutting edge graphics processors on desktop and mobile systems. However, If you need to develop 3D applications for older versions of the Flash Player, you can easily switch to use previous versions of the engine. The development team have made an effort to maintain API’s across versions, so you will find similarities when using any of the Away3D versions available, helping to ease the transition.
And much, much more.
Stereoscopic rendering, 3D sound, extrusion tools, data serialisation, and the list goes on…
最后,贴几张用Away3D做的项目图片