FlarToolKit not working

52 views
Skip to first unread message

juri bryan

unread,
Feb 28, 2013, 4:42:13 AM2/28/13
to flartool...@googlegroups.com
Hi everyone,
I am still desperately trying to get my first Augmented reality test up and running...
I have no idea where I am going wrong and what is happening when I compile the code.
There are no errors shown in my code, but the cube is just not appearing on my marker.
I tried a custom one( the pattern got created with the ARToolKit marker generator) and with one of the patterns from the FlarManager resources.
There is just nothing happening.
Any ideas and tips are more then welcome! seeing that I just don't know what to do anymore...
Cheers,
Juri

package

{

import flash.display.BitmapData;

import flash.display.Sprite;

import flash.events.Event;

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.pv3d.FLARBaseNode;

import org.libspark.flartoolkit.support.pv3d.FLARCamera3D;

import org.papervision3d.lights.PointLight3D;

import org.papervision3d.materials.shadematerials.FlatShadeMaterial;

import org.papervision3d.materials.utils.MaterialsList;

import org.papervision3d.objects.primitives.Cube;

import org.papervision3d.render.BasicRenderEngine;

import org.papervision3d.scenes.Scene3D;

import org.papervision3d.view.Viewport3D;

public class AR_02 extends Sprite

{

[Embed(source="patt001.pat", mimeType="application/octet-stream")]

private var pattern:Class;

[Embed(source="camera_para.dat", mimeType="application/octet-stream")]

private var params:Class;


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;

private var detector:FLARSingleMarkerDetector;

private var scene:Scene3D;

private var camera:FLARCamera3D;

private var container:FLARBaseNode;

private var vp:Viewport3D;

private var bre:BasicRenderEngine;

private var trans:FLARTransMatResult;

public function AR_02()

{

setupFlear();

setupCam();

setupBitmap();

setupPV3D();

addEventListener(Event.ENTER_FRAME, loop);

}

private function setupFlear():void

{

fparams = new FLARParam();

fparams.loadARParam(params() as ByteArray);

mpattern = new FLARCode(16,16);

mpattern.loadARPatt(new pattern());

}

private function setupCam():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);

bmd.draw(vid);

raster = new FLARRgbRaster_BitmapData(bmd);

detector = new FLARSingleMarkerDetector(fparams, mpattern, 80);

}

private function setupPV3D():void

{

scene= new Scene3D();

camera= new FLARCamera3D(fparams);

container= new FLARBaseNode();

scene.addChild(container);

var pl:PointLight3D = new PointLight3D();

pl.x = 1000;

pl.y = 1000;

pl.z= -10000;

var ml:MaterialsList = new MaterialsList({all: new FlatShadeMaterial(pl)});

var cube1:Cube = new Cube(ml,300,300,300);

container.addChild(cube1);

bre= new BasicRenderEngine();

trans = new FLARTransMatResult();

vp= new Viewport3D();

addChild(vid);

}

private function loop(e:Event):void

{

bmd.draw(vid);

try

{

if(detector.detectMarkerLite(raster, 80) && detector.getConfidence() > 0.5)

{

detector.getTransformMatrix(trans);

container.setTransformMatrix(trans);

bre.renderScene(scene, camera, vp);

}

}

catch(e:Error){}

}


}

} 
Reply all
Reply to author
Forward
0 new messages