"Imagination is more important than knowledge." -Albert Einstein

Looping videos in Papervision3D

Posted: November 16th, 2009 | Author: admin | Filed under: papervision3D | No Comments »

I was working on an Augmented Reality bit this weekend which involved a looping video. Normally this is a harmless operation which involves a simple onStreamStatus event, that by passing a “NetStream.Play.Stop” triggers a _netStream.seek(0); function. But when I tried that in PV3d the video would not loop… it was pretty frustrating, but eventually I figured out that the VideoStreamMaterial class in the Papervision3D package stopped rendering upon a “NetStream.Play.Stop” event, but didn’t resume it on a “NetStream.Seek.Notify” event, which I had to manually add.



this is how the function looks like after the change:

private function onStreamStatus ( event:NetStatusEvent ):void
        {
            switch ( event.info.code )
            {
                case "NetStream.Play.Start":
                    animated = true;
                    break;
                case "NetStream.Unpause.Notify":
                    animated = true;   
                    break;
                case "NetStream.Seek.Notify":
                    animated = true;
                    break;
                case "NetStream.Play.Failed":
                    animated = false;
                    break;
                case "NetStream.Play.Stop":
                    animated = false;
                    break;
                case "NetStream.Play.StreamNotFound":
                    animated = false;
                    break;
                case "NetStream.Pause.Notify":
                    animated = false;
                    break;
            }          
        }

Bitmap division and animation with simple API

Posted: November 10th, 2009 | Author: admin | Filed under: Effects | No Comments »

I’m continuing my efforts to create an easy-to-use effect library. For now I’m concentrating on 2D matrix effects — the previous one was halfTone. This one is a devision of an image (or any displayObjects for that matter) into smaller segments.

here’s what it looks like (click to watch animation):
Picture 10

here is the code involved with using the effect:

devide = new Devide(_loadedBitmap, 12, 0x000000);
addChild(devide);
           
devide.swipeLeftToRight = 0;
           
seq = new TimelineLite({onComplete:restartTween});
seq.append(TweenLite.to(devide, 1, {swipeLeftToRight:1}));
seq.append(new TweenLite(devide, 1, {swipeRightToLeft:0}));
seq.append(new TweenLite(devide, 1, {swipeTopToBottom:1}));
seq.append(new TweenLite(devide, 1, {swipeBottomToTop:0}));

It is based on my previous work that I posted here.


Halftone effect with simple API

Posted: November 5th, 2009 | Author: admin | Filed under: Effects | No Comments »

I started working on an effect library with an easy-to-use API which will be easily attached to any tweening engine. I’m still working hard on the API and on how the whole thing is architectured, so I’m not going to include source code this time, but to give you a glimpse of how this is going to look, here’s an example of the Halftone effect which is going to be part of the Matrix2D package (it will include stuff like pixelate and explode effects).

the following effect is achieved simply by typing the following:

halfTone = new HalfTone(_loadedBitmap, 16);
addChild(halfTone);

but the fun part is animating the effect with a simple API. I’m using the new TweenLite v11, but any tween engine or really any other way (like controlling the swipe with the position of the mouse). here’s how I’m creating the different swipes in the example below:

halfTone.swipeLeftToRight = 0;
seq = new TimelineLite({onComplete:restartTween});
seq.append(new TweenLite(halfTone, 1, {swipeLeftToRight:1}));
seq.append(new TweenLite(halfTone, 1, {swipeRightToLeft:0}));
seq.append(new TweenLite(halfTone, 1, {swipeTopToBottom:1}),1);
seq.append(new TweenLite(halfTone, 1, {swipeBottomToTop:0}));
seq.append(new TweenLite(halfTone, 1, {swipeTLtoBR:1}),1);
seq.append(new TweenLite(halfTone, 1, {swipeTLtoBR:0}));

Picture 4

Special thanks to Joe Ferrari for helping me through the diagonal array math (still working on the BottomLeft to TopRight swipe)