I am using the Augmented Reality app for Android using Flash. For the application to work on my Android phone (nexus One), you must also activate the phone camera. So I need 2 layers, one for the background, which is the channel of my phoneโs camera, and the other on top of it, which in this case is from away3d.
Thus, to create a BitmapData object to store information about the last frame of the webcam, I can do this job.
If I use the papervision3D library and FLARToolkit, we install BitmapData using the following part of the code found from this video tutorial :
//import libraries import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData; import org.libspark.flartoolkit.detector.FLARSingleMarkerDetector; private function setupCamera():void { vid = new Video(640, 480); cam = Camera.getCamera(); cam.setMode(320, 240, 10); vid.attachCamera(cam); addChild(vid); } private function setupBitmap():void { bmd = new BitmapData(640, 480); bmd.draw(vid); raster = new FLARRgbRaster_BitmapData(bmd); detector = new FLARSingleMarkerDetector(fparams, mpattern, 80); } private function loop(e:Event):void { if(detector.detectMarkerLite(raster, 80) && detector.getConfidence() > 0.5) { vp.visible = true; detector.getTransformMatrix(trans); container.setTransformMatrix(trans); bre.renderScene(scene, camera, vp); } else{ vp.visible = false} } catch(e:Error){}}}}
However, to implement my Im application using the Away3D engine and FLARManager, the way to do this is very different, as I understand it. I am implementing the following code, but the only thing he thinks is just to show the Flash camera before the 3D view, and I canโt check if my application is working or not, because it does not show me any 3D object when I place the marker in front of the screen.
My code is:
//Setting Up Away3DLite Camera3D import com.transmote.flar.camera.FLARCamera_Away3DLite; private var camera3D:FLARCamera_Away3DLite; this.camera3D = new FLARCamera_Away3DLite(this.flarManager, new Rectangle(0, 0, this.stage.stageWidth, this.stage.stageHeight)); //Setting Up the bitmapData private function bitmap():void { c = Camera.getCamera(); c.setMode(320,240,10) this.v.attachCamera(c); addChild(this.v); bmd = new BitmapData(640,480); bmd.draw(this.v); }
Could you help me find out how I can combine these two?
I will be very grateful for any advice that I can get from you.
thanks