Away3D flash engine



Away3D architecture overview

2007.05.16


The main concept of Away3D is scene. Scene is a set of meshes, lights, cameras and other objects, with their position in space, that benefit to the final rendered image. Each object implements interfaces depending on its contribution to rendering. With use of containers the objects on scene may form a hierarchy.

Renderer is an object that is responsible for rendering a scene. Different renderers may be interested in different aspects of the scene, or render it in different ways.

The building bricks for rendering any scene are drawing primitives. Each drawing primitive has screen dimentions and distance to screen (z-order). The most common drawing primitive is triangle, complemented by segments, bitmaps and sprites. Some primitives, such as triangles and segments delegate their rendering to material, while others render themselves.

Ordinary renderer works the following way: it gather all the lighting info on the scene, gather all drawing primitives to be rendered, sort all primitives by their distance to screen and render them from the most distant to nearest. Optionally, custom filters can be applied to the set of primitives before rendering, such as RiddleFilter that breaks crossing drawing triangles and AnotherRivalFilter that fixes z-ordering anomalies.

The main difference between ordinary renderers is the way they store primitives for processing. BasicRenderer uses simple list for storing all primitives, VolumeBlockRenderer stores primitives from each object in separate list and QuadrantRenderer stores primitives in quadrant tree. Each storage type provides performance boost for some task and slows down on another.

Renderer's operations and info gathering are accomplished using traversers, one-time objects that perform certain operation on the whole scene. TickTraverser updates time for all objects on scene, LightTraverser gathers scene lighting sources. ProjectionTraverser projects objects into camera view and has two derivates, FindHitTraverser that traces mouse clicks and PrimitiveTraverser that gathers drawing primitives.

To contribute to the scene rendering, objects on the scene implement corresponding interfaces. Those may include ILightProvider meaning that object provides some light to the scene, IPrimitiveProvider meaning that object provides drawing primitives to the scene, ILODObject meaning that scene node may not be rendered depending on its distance to camera. Next follow up in this list will be IBlocker that will control occlution of one objects by another.

Main IPrimitiveProvider implementation is Mesh3D class that represents a set of faces and segments to be rendered, Sprite2D being another important one.

All the materials in Away3D implement IMaterial interface and optionally other interfaces. ITriangleMaterial is used to specify that material is capable of rendering triangles, ISegmentMaterial to specify that material is capable of rendering segments and IUVMaterial to specify that material is using texture coordinates for rendering.

The rendering context, such as lighting, culling and clipping, used while traversing objects and by primitives and materials for rendering, is stored in RenderSession object. Whenever possible, scene and object on scene should avoid changing their inner state while rendering, storing all the temporary data in session object.







.
Alexander Zadorozhny © 2007 (a*.z*@gmail.com)