Flar noob problems

63 views
Skip to first unread message

juri bryan

unread,
Feb 27, 2013, 5:53:40 AM2/27/13
to flartool...@googlegroups.com
Hi everyone.
First and for all I want to say that I just started using flar and that I assume that my questions are really easy to fix, but I can't find the answer.
I am following this tutorial to get my first "custom" AR going and I am running in to a few problems:http://www.gotoandlearn.com/play.php?id=105
everything works fine, my webcam gets triggered and all that works fine.
Just when I want to set up the 3D scene it all goes to hell.
It seams as though I can not put any parameters into the new camera or add my container to the scene... they always error.
I checked the tutorial 5 times and looked into the source code... but they all show it done this way so I do not know what I am doing wrong.
Any tips on how to solve this?
The red line error out.
Thanks a lot in advance!
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.alternativa3d.FLARCamera3D;

import org.libspark.flartoolkit.support.away3d.FLARBaseNode;

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 Test5 extends Sprite

{

[Embed(source="pat1.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 Test5()

{

setupFLAR()

setupCam();

setupBitmap();

setupPV3D();

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 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 = -1000;

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

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

var cube2:Cube = new Cube(ml, 30, 30, 30);

cube2.z = 50;

var cube3:Cube = new Cube(ml, 30, 30, 30);

cube3.z = 100;

container.addChild(cube1);

container.addChild(cube2);

container.addChild(cube3);

bre = new BasicRenderEngine();

trans = new FLARTransMatResult();

vp = new Viewport3D();

addChild(vp);


}

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){}

}


}

}

bismillah rawthar

unread,
Feb 27, 2013, 8:44:46 AM2/27/13
to flartool...@googlegroups.com
Replace

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

import org.libspark.flartoolkit.support.away3d.FLARBaseNode;


with

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

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

juri bryan

unread,
Feb 27, 2013, 9:59:26 AM2/27/13
to flartool...@googlegroups.com
Hi Bismillah rawthar,
thanks! The errors are gone now.
But when I run the program it does not pick up my pattern.
Any idea why that could be?
And ones again sorry for the stupid questions and thanks for you fast support!
Cheers,
Juri

juri bryan

unread,
Feb 27, 2013, 10:06:30 AM2/27/13
to flartool...@googlegroups.com
okay,
So I think it might be that I "quick fixed" a error that was showing up earlier.
I went back to the original FLARToolkit and now it is showing the same error again, so might be that it is that.
What am I doing wrong here?

private function setupFLAR():void

{

fparams = new FLARParam();

fparams.loadARParam(new params() as ByteArray);

mpattern = new FLARCode(16,16);

mpattern.loadARPatt(new pattern());

}

it says that I am trying to call a undefined method with a static type FLARParam...

any help is very much appreciated!

cheers,

Juri

Reply all
Reply to author
Forward
0 new messages