Playing with Fire

Thursday, March 26, 2009


This uses the BitmapEffectsLayer in papervision 2.0
Click and drag to rotate the 3D cube.

//start with a bitmap file material
var bfm:BitmapFileMaterial = new BitmapFileMaterial("imagePath", true);
bfm.doubleSided = true;

//next we add a bitmap effect layer
var bfx:BitmapEffectLayer = new BitmapEffectLayer(viewport, stage.width, stage.height);

//add the effect layer to the viewport
viewport.containerSprite.addLayer(bfx);

//create a materials list with all sides the same
var mlist:MaterialsList = new MaterialsList({all:bfm});

//bind the material list to a new 3D Cube
var cube:Cube = new Cube(mlist, 500, 500, 500, 2, 2, 2);

//add the cube to the effects layer
bfx.addDisplayObject3D(cube);

//now for the fire effect
var fire:BitmapFireEffect = new BitmapFireEffect(0, 1, .2, 1);
fire.smoke = 0;
fire.flameHeight = .5;
fire.fadeRate = .4;
fire.flameSpread = .5;
fire.smoke = 0;
fire.distortion = .4;

//you can also add a new flash blur filter (or any kind of flash filter) to the object
//bfx.addEffect(new BitmapLayerEffect(new BlurFilter(2, 2, 8)));

bfx.addEffect(fire);

//add the cube to the scene
scene.addChild(cube);

//Now render your scene!

0 comments:

Post a Comment