Hi Desgraci, Set it up so the bitmap being passed to FLAR is half the width and half the height of the screen. This is how Rob's demo is set up: the capture bitmap is 400x300 but the stage is 800x600.
Also note that the View3D needs to point a little off center to get the ogre to line up with the marker. So set the y property of the View3D to half the stage height, but the x property to half the stage width minus 5. HTH, David Z -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of desgraci Sent: Tuesday, August 25, 2009 10:28 AM To: away3d.dev Subject: [away3d] Re: why doesnt show 3d model in AR? i rewrote the code so it looks almost identicall to the one that rob used, i used the same files in fact, but still not working, anyone got an idea of why this is not working? package { import away3d.containers.Scene3D; import away3d.containers.View3D; import away3d.core.base.Mesh; import away3d.core.render.BasicRenderer; import away3d.core.utils.Cast; import away3d.materials.BitmapMaterial; import away3d.primitives.Sphere; import away3d.loaders.Md2; import away3d.animators.data.AnimationSequence; import flash.display.BitmapData; import flash.display.Sprite; import flash.events.Event; import flash.filters.BlurFilter; import flash.media.Camera; import flash.media.Video; import flash.utils.ByteArray; import org.libspark.flartoolkit.core.FLARCode; import org.libspark.flartoolkit.core.param.FLARParam; import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData; import org.libspark.flartoolkit.core.transmat.FLARTransMatResult; import org.libspark.flartoolkit.detector.FLARSingleMarkerDetector; import org.libspark.flartoolkit.support.away3d_2.FLARBaseNode; import org.libspark.flartoolkit.support.away3d_2.FLARCamera3D; [SWF(width="640", height="480", frameRate="30", background="#AAAAFF")] public class FLARDemox extends Sprite { [Embed(source="../assets/FLAR-marker.pat",mimeType="application/ octet-stream")] private var pattern:Class; [Embed(source="../assets/camera_para.dat",mimeType="application/ octet-stream")] private var params:Class; //ogre MD2 animation [Embed(source="../assets/ogre.md2", mimeType='application/octet- stream')] private var Model:Class; //ogre texture [Embed(source="../assets/ogre.jpg")] private var Texture:Class; //marterial objects private var material:BitmapMaterial; //scene objects private var model:Mesh; //enterframe variables private var blurFilter:BlurFilter= new BlurFilter(10, 10,1); //, BitmapFilterQuality.LOW); public var update:Boolean = true; private var fparams:FLARParam; private var mpattern:FLARCode; private var vid:Video; private var cam:Camera; private var bmd:BitmapData; private var raster:FLARRgbRaster_BitmapData;//este es el parser de bitmap a FLAR private var detector:FLARSingleMarkerDetector;//detecta 1 marker se puede cambiar a multiples private var scene:Scene3D; private var camera:FLARCamera3D; private var container:FLARBaseNode; private var vp:View3D; private var bre:BasicRenderer; private var trans:FLARTransMatResult;//este posiciona los objetos private var bola:Sphere; public function FLARDemox() { setupFLAR(); setupCamera(); setupBitmap(); setupAWAY3D(); addEventListener(Event.ENTER_FRAME,loop); } private function setupFLAR():void { fparams=new FLARParam(); fparams.loadARParam(new params() as ByteArray); mpattern=new FLARCode(16,16); mpattern.loadARPatt(new pattern()); } private function setupCamera():void { vid=new Video(640,480); cam=Camera.getCamera(); cam.setMode(640,480,30); vid.attachCamera(cam); addChild(vid); } private function setupBitmap():void { bmd=new BitmapData(640,480);//lee por cuadro la imagen de la camra bmd.draw(vid);//la guarda en un bitmap raster=new FLARRgbRaster_BitmapData(bmd); detector=new FLARSingleMarkerDetector(fparams,mpattern,80); } private function setupAWAY3D():void { scene=new Scene3D(); camera=new FLARCamera3D(fparams); vp=new View3D({camera:camera,scene:scene}); addChild(vp); container=new FLARBaseNode(); material = new BitmapMaterial(Cast.bitmap(Texture)); model = Md2.parse(Model, {material:material}) as Mesh; model.scale(0.02); model.y += 45; model.play(new AnimationSequence("stand", true, true, 10)); container.addChild(model); scene.addChild(container); bre=new BasicRenderer(); trans=new FLARTransMatResult(); } private function loop(e:Event):void { bmd.draw(vid); if (update){ try { if (detector.detectMarkerLite(raster,80)&&detector.getConfidence() >0.1) { vp.visible = true; detector.getTransformMatrix(trans); container.setTransformMatrix(trans); }else{ vp.visible=false; } }catch(e:Error){ trace("Error: " + e.message); } vp.render(); } else { bmd.applyFilter(bmd, bmd.rect,bmd.rect.topLeft, blurFilter); } } } }
