Using a Viewport as a Mask

Sunday, December 7th, 2008 | examples


source

package
{
	import flash.display.Bitmap;
	import flash.events.Event;
 
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;
 
	[SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")]
	public class ViewportAsMask extends BasicView
	{
		[Embed(source="assets/rover.jpg")]
		private var roverAsset:Class;
		private var rover:Bitmap;
		private var plane:Plane;
 
		public function ViewportAsMask()
		{
			rover = new roverAsset() as Bitmap;
			rover.mask = viewport;
			addChild(rover);
 
			var colorMaterial:ColorMaterial = new ColorMaterial(0xffffff);
			plane = new Plane(colorMaterial);
			plane.z = -500;
 
			scene.addChild(plane);
			startRendering();
		}
 
		override protected function onRenderTick(event:Event=null):void
		{
			plane.moveForward(500);
			plane.rotationY = -viewport.containerSprite.mouseX / 320 * 90;
			plane.moveBackward(500);			
 
			renderer.renderScene(scene, camera, viewport);
		}
	}
}

Tags: ,

  • Thanks Marcus!

    That's so funny, I was googeling for the exact same thing as you guys. Scary to stumble upon some other people that are all experimenting with FLAR toolkit, in a non related article.
    Gotta love the internet!

    Cheers!
  • Marcus
    Hey guys, Saqoosha posted a simple example on how to make a hole on his blog:
    http://saqoosha.net/en/2009/01/08/1676/
  • I'm trying to achieve that too, Marcus. I'm remembering an AR demo with some tanks driving out of a hole in the wall.
  • Marcus
    Is there an easy way to use masks inside of a 3D Scene? Like using a plane as mask? I'd like to use FLARToolKit and the marker shape should become a window.. like in the example of "General Electrics' Smart Grid" and I don't know how to do it :(
blog comments powered by Disqus

Search

Recommended Books

Speaking at FITC Toronto

 

December 2008
M T W T F S S
« Nov   Jan »
1234567
891011121314
15161718192021
22232425262728
293031  

Preferred Video Tutorial Resolution

  • 1024x768 (53%, 85 Votes)
  • 1280x1024 (15%, 24 Votes)
  • 1920x1080 (15%, 24 Votes)
  • 800x600 (13%, 20 Votes)
  • 480x320 (4%, 6 Votes)
  • 640x480 (0%, 2 Votes)

Total Voters: 160

Loading ... Loading ...