Oh My Bosh! Design Your Very Own Chris Bosh Paper-Robo in Augmented Reality – Adding Interactivity to Your AR Apps

Oh My Bosh! Design Your Very Own Chris Bosh Paper-Robo in Augmented Reality – Adding Interactivity to Your AR Apps

bosh_lbj

With Chris Bosh’s  contract with the Raptors expiring soon, there’s been a lot of talk of him being shopped around next season. Sources say that the Cleveland Cavaliers have targeted Bosh to play along side King James.

While I don’t want to see Chris leave Toronto, it wouldn’t surprise me to see him follow the path of other marquee players before him : Stoudemire (he was big back in the day), Carter, McGrady and Camby.

Where do you think Chris will go?

With this latest flar demo you can make your predictions by redesigning his jersey in AR, download the parts to your desktop, and print/assemble your own Paper-Robo! You can also upload your own custom skin to preview what the robo will look like in AR.

For anyone who designs a killer Bosh skin through this app or even better photoshop, please send them my way and I’ll post them here! I bet some of CB4’s twitter army could make some sick custom bots.

Here’s a link to the live demo to try yourself:

Bosh Demo

Direct your iphone here (don’t waste paper, if you can help it!!):

Download Bosh Marker

Download Bosh Paper-Robo Parts

CODE SNIPPETS:

Adding mouse events to collada models and manipulating materials

This functionality is simply an extension of the helloMouse3D example that ships with the Papervision3D libraries. The only difference here is that instead of manipulating the material of a Papervision3D primitive, you are manipulating the material of a 3D collada model.

One thing I discovered is that material lists for colladas are wonky, and in order to add interactivity to 3D models  you have to add listeners directly to the to the mesh associated with that material and only when the model has completely loaded. As you can see be the live demo, the focus of the mouse on the model sometimes gets lost. I suspect that this is due to the collada model I’m using which has been to hell and back to get it rendering properly in Papervision3D. I built the model 2 years ago in Sketchup when either Papervision 1.0 or 1.5 around! From Sketchup I exported it as a collada, and brought it into 3DS max to make a uv map. I exported from 3Ds max as a collada, only to import the result into Blender, to obtain a collada with settings the Papervision3d can render.

When I have time I will try the demo with a simpler collada to see if this loss of focus is still a problem. If you have any ideas why I’m losing focus on my model please let me know!

public function addMarker(marker : FLARMarker) : void
		{
			// store marker
			var markerList : Vector. = this.markersByPatternId[marker.patternId];
			markerList.push( marker );

			var container : DisplayObject3D = new DisplayObject3D( );
			robo = new Collada( FLARManager._GATEWAY + "/resources/models/myrobo4flippedblender.xml" );
			robo.scale = .07;
			robo.rotationX = 90;
			robo.rotationZ = 90;
			robo.z = robo.z - 100;
			robo.addEventListener( FileLoadEvent.LOAD_COMPLETE, daeCompleteHandler );
			container.addChild( robo );
			this.scene3D.addChild( container );

			// associate container with corresponding marker
			this.containersByMarker[marker] = container;

		}

		public function daeCompleteHandler(event : Event) : void
		{

			robo.getChildByName( "Model" ).addEventListener( InteractiveScene3DEvent.OBJECT_MOVE, handleMouseMove );
			robo.getChildByName( "Model" ).addEventListener( InteractiveScene3DEvent.OBJECT_PRESS, handleMouseDown );

			surface = new Sprite( );

			textureContainer = new Sprite( );

			__boshSkin = new boshSkin_mc( );

			__boshSkin.addChild( textureContainer );

			__boshSkin.addChild( surface );

			var mat : MovieMaterial = new MovieMaterial( __boshSkin );
			mat.interactive = true;
			mat.animated = true;
			mat.allowAutoResize = false;
			mat.updateBitmap( )
			robo.getChildByName( "Model" ).material = mat;
		}

public function handleMouseDown(e : InteractiveScene3DEvent) : void
		{
			//Start Drawing
			if(surface != null)
			{
				surface.graphics.beginFill( __activeColour, 1 );
				surface.graphics.drawCircle( vMouse.x, vMouse.y, 3 )
				surface.graphics.endFill( );
			}
		}

public function handleMouseMove(e : InteractiveScene3DEvent) : void
		{
			if(InteractiveSceneManager.MOUSE_IS_DOWN)
			{
				//Continue drawing when the mouse is down
				if(surface != null)
				{
					surface.graphics.beginFill( __activeColour, 1 );
					surface.graphics.drawCircle( vMouse.x, vMouse.y, 3 )
					surface.graphics.endFill( );
				}
			}
		}

Flash Player 10 JPEG encoding

A colleague at work pointed me towards a JPEG Async Encoder class that allows you to to merge large BitmapData objects to form a large JPEG, getting around Flash player 10 BitmapData size restrictions. I didn’t need to encode something beyond 4,095 x 4,095 for this particular demo, but it’s useful to know that there is a work around.

Flash Player 10 reading and writing files locally

This demo uses a some new features of Flash 10, reading and writing files locally between the browser and OS without the need to write any server side code.

Using the FileReference.load() method you can allow a user to select a file locally and load it directly into the Flash plugin without having to upload it to a server.

FLARManager v0.5 (for FLARToolkit)

This is my first demo to include the newest FLARManager update. Eric Socolofsky has updated his framework to include some new optimizations, one of which is adaptive thresholding, which allows markers to be detectable in low light conditions.

AR Musings…

Is the wow factor is still there AR apps? Most offerings simply involve displaying a model on a glyph, which captures the user’s attention for about 2 minutes. There are a few hoops to jump through, in order to get a user to interact with an AR app: you have to print out a marker, need a webcam or have to download a specific plugin to view AR content (not as big a deal these days with broadband connections). Also imagine all the sheets of paper used around the world for a website that promotes renewable energy resources! I’m not sure what the solution is for saving our trees, other than offering digital versions of as AR marker that could displayed on a mobile device…Alternately, AR websites could offer a keyboard shortcut that mimics a marker without having to print it out.

Here are some interesting examples of interactive AR apps that have popped up recently that have started to push AR beyond displaying simple models in 3d space:


Unic8’s use of  Bartek Drozdz‘s AS3Dmod library to bend primitives based on marker proximity and angle:

http://www.unic8.com/labs/flarmagnet-full-interactive-experience

The dev(s) at unic8 Studios have also done some interesting interactive AR demos with sound and light.

BMW Z4 3D paintbrush