This is a little experiment used to dive into the basic functions of the beautiful 3D Engine ‘Papervision3D’. Location, Tweening and Shapes are provided by Papervision. But instead of rendering the results directly to the container sprite, it is passed through to a ConvolutionFilter and different ColorMatrixFilters. Credits for 3D shape-tweening goes to Mr.Doob. (A great source of information round about Papervision and Actionscript3, we highly recommend visiting).
The render frame
private function tick( event:Event ):void
{
output.lock();
source.lock();
source.draw( wrapper, half, null, null, null, true );
locationFilterMatrix[6] = Math.random() * .2 + .2;
locationFilterMatrix[8] = Math.random() * .2 + .2;
locationFilter.matrix = locationFilterMatrix;
source.applyFilter( source, bounds, origin, locationFilter );
output.draw( source, twice, null, null, null, true );
output.applyFilter( output, output.rect, origin, colorFilter );
source.unlock();
output.unlock();
camera.hover( 1, ( ( STAGE_W * 0.5 ) - mouseX ) * .005, ( ( STAGE_H * 0.5 ) - mouseY ) * .005 );
scene.renderCamera( camera );
}
The transitioning from one shape to another
private function form1():void
{
tweenToForm( target1, 7 );
Tweener.addTween( this, {delay: 6, onComplete: form2} );
}
private function form2():void
{
tweenToForm( target2, 7 );
Tweener.addTween( this, {delay: 6, onComplete: form3} );
}
//...
private function form4():void
{
tweenToRandom( 2500, 5000, 2, 4, 5 );
Tweener.addTween( this, {delay: 5, onComplete: form5} );
}