papervision3D video material

code :: the lupin cube

papervision3D video material - the lupin cube

 

my latest papervision3d project was a revamp of the video cube. this time around the rotation of the cube is static, not mouse driven, also i added some new filtering, and a different method of using a video texture that doesn’t throw an error message. the flv is from the best cartoon ever lupin the 3rd. this episode is called "buns, guns, and fun in the sun" 

check it out here.

and here's the as3 code:

package
 {
     import flash.display.*;
     import flash.events.*;
     import flash.media.*;
     import flash.net.*;
     import flash.text.*;
     import flash.filters.*;
 
     //filmed in papervision3d     
     import org.papervision3d.scenes.*;
     import org.papervision3d.objects.*;
     import org.papervision3d.cameras.*;
     import org.papervision3d.materials.*;
 
     [SWF(backgroundColor=0x333333)]
 
     public class main extends Sprite
     {
       // _______________________________________________________________________
       //                                                                  vars3D
         private var container : Sprite;
         private var scene     : MovieScene3D;
         private var camera    : Camera3D;
 
         private var planeObj  : DisplayObject3D;
         private var planeSize : int = 500;
         private var segment   : int = 2;
         private var material  : BitmapMaterial;
         private var bmpData   : BitmapData;
         private var connection: NetConnection;
         private var stream    : NetStream;
         private var video     : Video;
         private var label     : TextField;
 
         private var valx      : Number = 0;
         private var valy    : Number = 0;
         private var count     : uint = 0;
 
         static public const
             TEXTURE_W:int = 320,
             TEXTURE_H:int = 240;
 
         // _______________________________________________________________________
         //                                                             constructor
         public function main():void
         {
             stage.frameRate = 60;
             stage.quality   = "MEDIUM";
             stage.scaleMode = "noScale";
             stage.align = StageAlign.TOP_LEFT;
             this.addEventListener(Event.ENTER_FRAME, loop3D);
             this.stage.addEventListener(Event.RESIZE, onStageResize);
             label=new TextField();
             label.autoSize=TextFieldAutoSize.LEFT;
             label.x = 10;
             label.textColor=0xFFFFFF;
             label.selectable=false;
             addChild(label);
 
             init3D();
 
             connection=new NetConnection();
             connection.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
             connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler);
             connection.connect(null);
         }
         private function netStatusHandler(evt:NetStatusEvent):void {
             switch (evt.info.code) {
                 case "NetConnection.Connect.Success":
                     stream = new NetStream(connection);
 
                     stream.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);

                     stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncErrorHandler);
                     video = new Video();
                     video.attachNetStream(stream);
 
                     stream.play("lupinIII-s2e002-buns.guns.and.fun.in.the.sun.flv");
                     label.htmlText ="xero.nu presents... \n      lupin the 3d\n          buns guns and fun in the sun";
                      break;
                 case "NetStream.Play.StreamNotFound":
                     label.text="flv not found...";
                     break;
                 case "NetStream.Play.Stop":
			//loop video
                     stream.seek(0);
                     break;
             }
         }
         // _______________________________________________________________________
         //                                                          event handlers
         private function asyncErrorHandler(evt:AsyncErrorEvent):void {
         }
 
         private function securityErrorHandler(evt:SecurityErrorEvent):void {
             label.text="security error...";
         }
 
         // _______________________________________________________________________
         //                                                                  init3D
         private function init3D():void
         {
             this.container = new Sprite();
             addChild(this.container);
             this.container.x = this.stage.stageWidth  / 2;
             this.container.y = this.stage.stageHeight / 2;
 
             scene = new MovieScene3D( container );
 
             camera = new Camera3D();
             camera.z = -planeSize;
             camera.focus = 1000;
             camera.zoom = 1;
 
             bmpData = new BitmapData(TEXTURE_W,TEXTURE_H,false,0xff0000);
 
             material = new BitmapMaterial(bmpData);
             material.oneSide = true;
 
             planeObj = scene.addChild( new Cube( material, planeSize, planeSize, planeSize, segment, segment, segment) );
         }
 
         // _______________________________________________________________________
         //                                                                  loop3d
         private function loop3D( event:Event ):void
         {
             valx -= 0.2;
             valy -= 0.5;
             planeObj.rotationY = valx;
             planeObj.rotationX = 35;
 
             video.attachNetStream(null);
             bmpData.draw(video);
             video.attachNetStream(stream);
 
             var filters:Array = new Array;
             filters.push(new GlowFilter(0xFFFFFF, 1, 10, 10, 10, 1));
             filters.push(new DropShadowFilter(70, 55, 0x000000, 0.5, 9, 9, 1, BitmapFilterQuality.HIGH));
/*
             var blur:Number = 10*Math.sin( (++count/25) );
             if(blur > 0){
                 filters.push(new BlurFilter(blur,blur,BitmapFilterQuality.HIGH));
             }
*/
             planeObj.container.filters = filters;
 
             this.scene.renderCamera( camera );
         }
 
         // _______________________________________________________________________
         //                                                           onStageResize
         private function onStageResize(event:Event):void
         {
             this.container.x = this.stage.stageWidth  / 2;
             this.container.y = this.stage.stageHeight / 2;
         
     }
 }

p.s. happy birthday to me!