Packageorg.flintparticles.threeD.renderers
Classpublic class BitmapRenderer
InheritanceBitmapRenderer Inheritance SpriteRendererBase Inheritance flash.display.Sprite
Subclasses PixelRenderer

The BitmapRenderer is a native Flint 3D renderer that draws particles onto a single Bitmap display object. The particles are drawn face-on to the camera, with perspective applied to position and scale the particles.

The region of the projection plane drawn by this renderer must be defined in the canvas property of the BitmapRenderer. Particles outside this region are not drawn.

The image to be used for each particle is the particle's image property. This is a DisplayObject, but this DisplayObject is not used directly. Instead it is copied into the bitmap with the various properties of the particle applied, including 3D positioning and perspective relative to the renderer's camera position. Consequently each particle may be represented by the same DisplayObject instance and the SharedImage initializer can be used with this renderer.

The BitmapRenderer allows the use of BitmapFilters to modify the appearance of the bitmap. Every frame, under normal circumstances, the Bitmap used to display the particles is wiped clean before all the particles are redrawn. However, if one or more filters are added to the renderer, the filters are applied to the bitmap instead of wiping it clean. This enables various trail effects by using blur and other filters.

The BitmapRenderer has mouse events disabled for itself and any display objects in its display list. To enable mouse events for the renderer or its children set the mouseEnabled or mouseChildren properties to true.



Public Properties
 PropertyDefined By
  bitmapData : BitmapData
[read-only] The bitmap data of the renderer.
BitmapRenderer
  camera : Camera
The camera controls the view for the renderer
BitmapRenderer
  canvas : Rectangle
The canvas is the area within the renderer on which particles can be drawn.
BitmapRenderer
 Inheritedemitters : Vector.<Emitter>
The array of all emitters being rendered by this renderer.
SpriteRendererBase
  postFilters : Array
The array of all filters being applied before rendering.
BitmapRenderer
  preFilters : Array
The array of all filters being applied before rendering.
BitmapRenderer
  smoothing : Boolean
BitmapRenderer
  zSort : Boolean
Indicates whether the particles should be sorted in distance order for display.
BitmapRenderer
Protected Properties
 PropertyDefined By
 Inherited_particles : Array
SpriteRendererBase
  toDegrees : Number
BitmapRenderer
  ZERO_POINT : Point
[static]
BitmapRenderer
Public Methods
 MethodDefined By
  
BitmapRenderer(canvas:Rectangle, zSort:Boolean = true, smoothing:Boolean = false)
The constructor creates a BitmapRenderer.
BitmapRenderer
 Inherited
addEmitter(emitter:Emitter):void
Adds the emitter to the renderer.
SpriteRendererBase
  
addFilter(filter:BitmapFilter, postRender:Boolean = false):void
The addFilter method adds a BitmapFilter to the renderer.
BitmapRenderer
  
Clears any palette map that has been set for the renderer.
BitmapRenderer
 Inherited
removeEmitter(emitter:Emitter):void
Removes the emitter from the renderer.
SpriteRendererBase
  
removeFilter(filter:BitmapFilter):void
Removes a BitmapFilter object from the Renderer.
BitmapRenderer
  
setPaletteMap(red:Array = null, green:Array = null, blue:Array = null, alpha:Array = null):void
Sets a palette map for the renderer.
BitmapRenderer
Protected Methods
 MethodDefined By
 Inherited
addParticle(particle:Particle):void
The addParticle method is called when a particle is added to one of the emitters that is being rendered by this renderer.
SpriteRendererBase
  
Create the Bitmap and BitmapData objects
BitmapRenderer
  
drawParticle(particle:Particle3D):void
Used internally here and in derived classes to render a single particle.
BitmapRenderer
 Inherited
SpriteRendererBase
 Inherited
removeParticle(particle:Particle):void
The removeParticle method is called when a particle is removed from one of the emitters that is being rendered by this renderer.
SpriteRendererBase
  
renderParticles(particles:Array):void
[override] This method draws the particles in the bitmap image, positioning and scaling them according to their positions relative to the camera viewport.
BitmapRenderer
 Inherited
updateParticles(ev:Event):void
SpriteRendererBase
Property Detail
bitmapDataproperty
bitmapData:BitmapData  [read-only]

The bitmap data of the renderer.


Implementation
    public function get bitmapData():BitmapData
cameraproperty 
camera:Camera

The camera controls the view for the renderer


Implementation
    public function get camera():Camera
    public function set camera(value:Camera):void
canvasproperty 
canvas:Rectangle

The canvas is the area within the renderer on which particles can be drawn. Particles outside this area will not be drawn.


Implementation
    public function get canvas():Rectangle
    public function set canvas(value:Rectangle):void
postFiltersproperty 
postFilters:Array

The array of all filters being applied before rendering.


Implementation
    public function get postFilters():Array
    public function set postFilters(value:Array):void
preFiltersproperty 
preFilters:Array

The array of all filters being applied before rendering.


Implementation
    public function get preFilters():Array
    public function set preFilters(value:Array):void
smoothingproperty 
smoothing:Boolean


Implementation
    public function get smoothing():Boolean
    public function set smoothing(value:Boolean):void
toDegreesproperty 
protected var toDegrees:Number

ZERO_POINTproperty 
protected static var ZERO_POINT:Point

zSortproperty 
zSort:Boolean

Indicates whether the particles should be sorted in distance order for display.


Implementation
    public function get zSort():Boolean
    public function set zSort(value:Boolean):void
Constructor Detail
BitmapRenderer()Constructor
public function BitmapRenderer(canvas:Rectangle, zSort:Boolean = true, smoothing:Boolean = false)

The constructor creates a BitmapRenderer. After creation it should be added to the display list of a DisplayObjectContainer to place it on the stage.

Emitter's should be added to the renderer using the renderer's addEmitter method. The renderer displays all the particles created by the emitter's that have been added to it.

Parameters
canvas:Rectangle — The area within the renderer on which particles can be drawn. Particles outside this area will not be drawn.
 
zSort:Boolean (default = true) — Whether to sort the particles according to their z order when rendering them or not.
 
smoothing:Boolean (default = false) — Whether to use smoothing when scaling the Bitmap and, if the particles are represented by bitmaps, when drawing the particles. Smoothing removes pixelation when images are scaled and rotated, but it takes longer so it may slow down your particle system.

See also

org.flintparticles.twoD.emitters.Emitter.renderer
Method Detail
addFilter()method
public function addFilter(filter:BitmapFilter, postRender:Boolean = false):void

The addFilter method adds a BitmapFilter to the renderer. These filters are applied each frame, before or after the new particle positions are drawn, instead of wiping the display clear. Use of a blur filter, for example, will produce a trail behind each particle as the previous images blur and fade more each frame.

Parameters

filter:BitmapFilter — The filter to apply
 
postRender:Boolean (default = false) — If false, the filter is applied before drawing the particles in their new positions. If true the filter is applied after drawing the particles.

clearPaletteMap()method 
public function clearPaletteMap():void

Clears any palette map that has been set for the renderer.

createBitmap()method 
protected function createBitmap():void

Create the Bitmap and BitmapData objects

drawParticle()method 
protected function drawParticle(particle:Particle3D):void

Used internally here and in derived classes to render a single particle. Each particle is positioned and perspective scaling applied here.

Derived classes can modify the rendering of individual particles by overriding this method.

Parameters

particle:Particle3D — The particle to draw on the bitmap.

removeFilter()method 
public function removeFilter(filter:BitmapFilter):void

Removes a BitmapFilter object from the Renderer.

Parameters

filter:BitmapFilter — The BitmapFilter to remove

See also

addFilter()
renderParticles()method 
override protected function renderParticles(particles:Array):void

This method draws the particles in the bitmap image, positioning and scaling them according to their positions relative to the camera viewport.

This method is called internally by Flint and shouldn't need to be called by the user.

Parameters

particles:Array — The particles to be rendered.

setPaletteMap()method 
public function setPaletteMap(red:Array = null, green:Array = null, blue:Array = null, alpha:Array = null):void

Sets a palette map for the renderer. See the paletteMap method in flash's BitmapData object for information about how palette maps work. The palette map will be applied to the full canvas of the renderer after all filters have been applied and the particles have been drawn.

Parameters

red:Array (default = null)
 
green:Array (default = null)
 
blue:Array (default = null)
 
alpha:Array (default = null)