Get ready to eliminate 1000’s of lines of Papervision3D code. That’s right! By using CS4 you no longer need the Movie Material class, the DisplayObject3D class, the Video Stream Material class, and a plethora of Triangle/UV parsing and math classes. It’s just amazing…in CS4 it’s so simple!
Note: This discussion uses the code and results of two previous posts:
Placing video on the CS4 Super Prim developed in Chapter 3 of the book is very easy and only requires four steps.
- Step 1: Import the net and media classes in to the Super Prim Class (see the post on CS4 Super Primitive using Matrix3D – this is your starter code)
- Step 2: Declare the video, net Connection, and net Stream variables.
//net stream assets
private var myConnection : NetConnection;
private var myStream : NetStream;
private var myVideo : Video;
- Step 3: Incorporate the loadMyVideo() method discussed in the previous post on Adding Video to a Papervision3D Curved Plane
- Step 4: Create a bitmapData object and in the animation loop draw your video to that bitmapData object and attach the net stream to your video, as shown below:
//Draw Video into Bitmap
this.myVideo.attachNetStream ( this.myStream );
The results yield a video being played among the various prims contained in the super prim. At this point you change the video by changing the file name inside your net Stream method (myStream.play(“assets/eternity.flv”)), but the constructor function could be easily changed to receive a video string locater.
A Little Extra
Also in Chapter 4 of the book, we show you how to put your webcam video on a prim. Below is a shot of my Guinea Pig Don Pedro who jumped into the screen to get his web cam video on a sphere.
The code for this is included in the download above. But the explanation is in the book. To see the entire code download the source from the link above, or click the more button below: