Archive for the 'Papervision 3D' Category

Papervision3D 1.5 (AS3) Official Release

Saturday, July 21st, 2007 by Torsten

So now it’s official. The latest release of Papervision3D comes with merged and cleaned code, new objects and materials, interactive materials and performance updates.

John Grden gives an overview of the change list:

  1. Optimized main render loop.
  2. Implemented ‘plugable’ face culler - 1 extra available at this time.
  3. Moved rendering from Face3D to materials, adjusted all current materials to override drawFace3D().
  4. New Materials : BitmapWire, BitmapColor, and CompositeMaterial (add multiple materials to this one single material).
  5. Moved all instances to their respective classes…fixed stars, vertices and DisplayObject3D to do so.
  6. Face normals are implemented.
  7. BitmapFileMaterial bug fixed - if used more than once, bitmap was displayed flat within the model’s body.
  8. Added progress events to BitmapFileMaterial and Collada objects
  9. Integrated InteractiveScene3D to 1.5
  10. Added Interactive materials for use with InteractiveScene3D - makes displayObjects that use an interactive material dispatch mouse events via InteractiveSceneManager.

Have a look at the Demo and Download Papervision3D 1.5

And now let’s have a closer look at it. Thanks papervision!

Flash: How to add Video texture in Papervision 3D

Sunday, April 15th, 2007 by Luis

I have received loads of requests asking how to diaplay a FLV as a texture in Papervision 3D using AS3.

The concept is very basic, you need to snapshot the video object where the video is running using BitmapData.draw(), and then set the result in the texture, and the rest is done by the 3D engine. ( See demo here)

papervideo

Notice in the code below a small hack by Chris Chen to be able to draw a media source in AS3 bypassing security errors.

Code Updated for latest Flash player and PV3D GreatWhite:

Actionscript:
  1. package com.lessrain.projects.luis.pv3dWhite.video3d
  2. {
  3.     import flash.display.BitmapData;
  4.     import flash.display.Sprite;
  5.     import flash.events.AsyncErrorEvent;
  6.     import flash.events.Event;
  7.     import flash.geom.Point;
  8.     import flash.geom.Rectangle;
  9.     import flash.media.Video;
  10.     import flash.net.NetConnection;
  11.     import flash.net.NetStream;
  12.     import flash.system.Security;
  13.  
  14.     import org.papervision3d.cameras.Camera3D;
  15.     import org.papervision3d.materials.BitmapMaterial;
  16.     import org.papervision3d.objects.DisplayObject3D;
  17.     import org.papervision3d.objects.primitives.Plane;
  18.     import org.papervision3d.render.BasicRenderEngine;
  19.     import org.papervision3d.scenes.Scene3D;
  20.     import org.papervision3d.view.Viewport3D;   
  21.  
  22.     /**
  23.      * @author Luis Martinez, Less Rain (luis@lessrain.com)
  24.      */
  25.     public class Video3D
  26.     {
  27.         private var _target : Sprite;
  28.         private var _container : Sprite;
  29.         private var _viewport : Viewport3D;
  30.         private var _renderer : BasicRenderEngine;
  31.         private var _scene3D : Scene3D;
  32.         private var _camera : Camera3D;
  33.         private var _rootNode : DisplayObject3D;
  34.         private var _connection : NetConnection;
  35.         private var _stream : NetStream;
  36.         private var _video : Video;
  37.         private var _videoWidth : Number = 320;
  38.         private var _videoHeight : Number = 240;
  39.         private var _videoTexture : BitmapData;
  40.         private var _planeTexture1 : BitmapData;
  41.         private var _planeTexture2 : BitmapData;
  42.         private var _srcRect1 : Rectangle;
  43.         private var _srcRect2 : Rectangle;
  44.         private var _basePoint : Point = new Point(0, 0);
  45.  
  46.         public function Video3D()
  47.         {
  48.             Security.loadPolicyFile("http://www.yourdomain.com/cross-domain.xml");
  49.         }
  50.  
  51.         public function initialize() : void
  52.         {
  53.             _srcRect1 = new Rectangle(0, 0, _videoWidth>> 1, _videoHeight);
  54.             _srcRect2 = new Rectangle(_videoWidth>> 1, 0, _videoWidth>> 1, _videoHeight);
  55.             _videoTexture = new BitmapData(_videoWidth, _videoHeight);
  56.             _planeTexture1 = new BitmapData(_videoWidth>> 1, _videoHeight);
  57.             _planeTexture2 = new BitmapData(_videoWidth>> 1, _videoHeight);
  58.            
  59.             initialize3D();
  60.             loadVideo();
  61.             createPlanes();
  62.            
  63.             _container.addEventListener(Event.ENTER_FRAME, loop3D);
  64.         }
  65.  
  66.         private function initialize3D() : void
  67.         {
  68.             _container = new Sprite();
  69.             _target.addChild(_container);
  70.             _viewport = new Viewport3D(990, 600, false, false);
  71.             _container.addChild(_viewport);
  72.             _renderer = new BasicRenderEngine();
  73.             _scene3D = new Scene3D();
  74.             _camera = new Camera3D();
  75.             _camera.zoom = 8;
  76.             _camera.focus = 200;
  77.             _rootNode = new DisplayObject3D();
  78.             _scene3D.addChild(_rootNode);
  79.         }
  80.  
  81.         private function loadVideo() : void
  82.         {
  83.  
  84.             var customClient : Object = new Object();
  85.  
  86.             customClient["onCuePoint"] = cuePointHandler;
  87.             customClient["onMetaData"] = metaDataHandler;
  88.            
  89.             _connection = new NetConnection();
  90.             _connection.connect(null);
  91.  
  92.             _stream = new NetStream(_connection);
  93.             _stream.checkPolicyFile = true;
  94.             _stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
  95.             _stream.client = customClient;
  96.             _video = new Video(_videoWidth, _videoHeight);
  97.             _video.attachNetStream(_stream);
  98.        
  99.             _stream.play('http://www.blog.lessrain.com/wp-content/upload/papervideo/myvideo.flv');
  100.         }
  101.  
  102.         private function cuePointHandler(infoObject_ : Object) : void
  103.         {
  104.         }
  105.  
  106.         private function metaDataHandler(infoObject_ : Object) : void
  107.         {
  108.         }
  109.  
  110.         private function asyncErrorHandler(event : AsyncErrorEvent) : void
  111.         {
  112.         }
  113.  
  114.         private function createPlanes() : void
  115.         {
  116.  
  117.             var material1 : BitmapMaterial = new BitmapMaterial(_planeTexture1);
  118.             material1.oneSide = false;
  119.             var plane1 : DisplayObject3D = _rootNode.addChild(new Plane(material1, _videoWidth>> 1, _videoHeight, 4, 4), "plane1");
  120.             plane1.x = -_videoWidth>> 2;
  121.             var material2 : BitmapMaterial = new BitmapMaterial(_planeTexture2);
  122.             material2.oneSide = false;
  123.             var plane2 : DisplayObject3D = _rootNode.addChild(new Plane(material2, _videoWidth>> 1, _videoHeight, 4, 4), "plane2");
  124.             plane2.z = _videoWidth>> 2;
  125.             plane2.rotationY = -90;
  126.         }
  127.  
  128.         private function loop3D(event_ : Event) : void
  129.         {
  130.    
  131.             _rootNode.rotationY += ((-_container.mouseX * 0.5) - _rootNode.rotationY) / 10;
  132.             _rootNode.rotationX += ((-_container.mouseY * 0.5) - _rootNode.rotationX) / 10;
  133.             _videoTexture.draw(_video);
  134.             _planeTexture1.copyPixels(_videoTexture, _srcRect1, _basePoint);
  135.             _planeTexture2.copyPixels(_videoTexture, _srcRect2, _basePoint);
  136.             _renderer.renderScene(_scene3D, _camera, _viewport);
  137.         }
  138.  
  139.         public function get target() : Sprite
  140.         {
  141.             return _target;
  142.         }
  143.  
  144.         public function set target(target_ : Sprite) : void
  145.         {
  146.             _target = target_;
  147.         }
  148.     }
  149. }


Some Bits and Pieces…

Sunday, March 25th, 2007 by Luis

The past two weeks loads of new things have happened around, I'm not talking about Adobe Apollo which it's public alpha release has been already covered for the whole week all over the place without interruption.

The week started in a new office with loads of work to do, new people coming in, and the discovery of a new (I mean 'new' for me) music band which maybe is not 'Avant garde enough' for some people, but caught my attention dramatically.

This week I had the opportunity to play for the first time with the Nintendo Wii . Yes, I'm aware that playing with the Wii is nothing specially new , but I'm coming from a place where important things are around this instead of the latest video game technology, so my delay in this matter is completely understandable.
I have been thinking for weeks to buy a new PS3 but after playing with the Nintendo Wii I have decided that my money is going to end up in Nintendo's pocket rather than Sony's bault.

In terms of work and 'Flashy stuff' as I wrote above, the release of Apollo public beta hasn't been in my priority list since I don't have time to play around with it. This does NOT mean that I consider Apollo a good tool or not, I just simply don't know and I don't need Apollo for my daily work yet (I would give it a try soon).

Three blog entries from 3 different blogs in my daily "must read because this guys can go bananas" list caught my attention last week when I think in 'Flashy stuff', all of them are related with flash and 3D:

Papervision 3D: PaperVideoRocky-Dudes

Sunday, March 4th, 2007 by Luis

New Tortilla recipe, just mix 100 grams of Paperdude with 250 grams of PaperVideo and leave them cook in Papervision 3D for 20 minutes, then you get the PaperRockyDudeTribute with tofu head.

You need the latest Adobe Flash plugin to see the demo.

PaperRockyVideo-Dude.

Click here to see the demo.

NOTE: If you use Firefox and you experience problems displaying the 3 videos of the demo at the same time, you can change http.max-persistent-connections-per-server settings in about:config.

Just for paperFun.

More Papervision and Video Links:

Related Papervision 3D stuff:

3D in Flash?

Friday, February 23rd, 2007 by Luis

Yes, well, as usual Papervision 3D topic, but so far until something else comes out, Papervision 3D is the best realistic option to generate and visualize 3D Flash content and 3D content in Flash.

Here some interesting views about PaperVision 3D and the future of 3D Flash content :

Papervision 3D: Going Bananas

Friday, February 16th, 2007 by Luis

Most of you already know the meaning of "going bananas" expression. If you don't know it, just take a closer look at this new Papervision 3D demo (3D Bumpmapping) by Ralph Hauwert.

Going Bananas means to go wild or crazy.

rhino

Related Posts:

Papervision 3D Demos

Wednesday, February 14th, 2007 by Luis

Check out this examples of some fantastic work done with Papervision3D.

Related Posts:

Papervision3D: PaperDude Demo

Thursday, February 8th, 2007 by Luis

This is not about performance or Collada or clipping issues in PV3D, this is just about Paperfun and imperfections.

The very first time I heard about Papervision 3D I thought about my first experience with 3D when I was a little kid, it wasn't related with computers at all, it was a very basic set of plane paper dolls similar to this.

Based on that old memories I decided to have a bit of Paperfun and crete the Paperdude.
Paperdude

Click here to see the demo.

UPDATE 20-02-2008 (Paperdude Second Generation):

Paperdude

Related Posts:

Papervision 3D: FLV spreading around walls

Thursday, January 25th, 2007 by Luis

Finally I had a little bit of time to play around with Papervision 3D, a fantastic 3d engine for Flash.

At the moment I couldn't play with the AS3 version because some conflicts I have between Flex builder and Eclipse, but so far the AS2 version of the engine is quite impressive.

I've been trying to spread a FLV around the walls of a cube, it took me around 15 minutes to do it, easy, clean and fantastic performance.

papervision 3D

Click here to see the demo.

Papervision 3D Links:

Other Flash 3D Engines and Links:

[UPDATE]: