rewrite to FLARManager

29 views
Skip to first unread message

CLRL

unread,
Oct 29, 2009, 9:03:02 PM10/29/09
to FLARToolKit userz
I made a geocaching puzzle project displaying 3D images made in
blender following the "gotoAndLearn" tutorials "Introduction to
Augmented Reality" and "Papervision3D Collada Basics". I used Flex 3.0
see ==> http://www.clrlworld.com/AR1/

After watching the new "Augmented Reality with FLARManager" and
successfully making the tutorial, now I'm trying to rewrite the Flex 3
project using Flash Builder 4 Beta and using FLARManager which is
supposed to be more stable, etc.

I get the images but they show only the wireframe. The .png file is in
the same folder as the .dae file.
How do I get the collada image to take the .png material?

This is what I got so far:

package
{
import com.transmote.flar.FLARManager;
import com.transmote.flar.marker.FLARMarker;
import com.transmote.flar.marker.FLARMarkerEvent;
import com.transmote.flar.utils.geom.FLARPVGeomUtils;

import flash.display.Sprite;
import flash.events.Event;

import org.libspark.flartoolkit.support.pv3d.FLARCamera3D;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.render.LazyRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.objects.parsers.Collada;
import org.papervision3d.lights.PointLight3D;

[SWF(width="640", height="480", frameRate="40",
backgroundColor="#00cc00")]

public class clrlMaAR extends Sprite
{
private var fm:FLARManager;
private var scene:Scene3D;
private var view:Viewport3D;
private var camera:FLARCamera3D;
private var lre:LazyRenderEngine;
private var con:DisplayObject3D;
private var marker:FLARMarker;
private var collada:Collada;

public function clrlMaAR()
{
initFLAR();
}

private function initFLAR():void
{
fm = new FLARManager("flarConfig.xml");
fm.flarCameraSource.useDefaultCamera = true;
fm.addEventListener(FLARMarkerEvent.MARKER_ADDED, onAdded);
fm.addEventListener(FLARMarkerEvent.MARKER_REMOVED, onRemoved);
fm.addEventListener(Event.INIT, init3D);

addChild(Sprite(fm.flarSource));
}

private function onAdded(e:FLARMarkerEvent):void
{
marker = e.marker;
}

private function onRemoved(e:FLARMarkerEvent):void
{
marker = null;
}

public function init3D(e:Event):void
{
scene = new Scene3D;
camera = new FLARCamera3D(fm.cameraParams);
camera.z = -30;
view = new Viewport3D(640, 480, true);
lre = new LazyRenderEngine(scene, camera, view);

var pl:PointLight3D = new PointLight3D();
pl.x = 1000;
pl.y = 1000;
pl.z = -1000;

collada = new Collada("c.dae");
collada.x = 0; // -160 brings it down to center of pattern (scale =
1)
collada.y = -120; //+100 moves to right to edge of paper
collada.z = 50; // +100 bring it closer - size of paper at +100
collada.rotationX = 180; // CW in left-right axis
collada.rotationY = -90; // CCW in vertical axis
collada.rotationZ = 90; // CW in front-back axis
collada.scale = 0.2;

con = new DisplayObject3D();
con.addChild(collada);

scene.addChild(con);
addChild(view);

addEventListener(Event.ENTER_FRAME, loop);
}

private function loop(e:Event):void
{
if (marker != null)
{
con.transform = FLARPVGeomUtils.convertFLARMatrixToPVMatrix
(marker.transformMatrix);
}
lre.render();
}

}
}

Thanks.
-cl

Makc

unread,
Oct 29, 2009, 9:08:05 PM10/29/09
to flartool...@googlegroups.com
note this line:

       import org.papervision3d.objects.parsers.Collada;

it doesnt have com.transmote.flar in it, does it?

CLRL

unread,
Oct 30, 2009, 4:19:29 PM10/30/09
to FLARToolKit userz
Thanks, but where am I supposed to be looking at?

FLARManager/dev/src/com/transmote/flar/ doesn't have (or I missed
them) any parsers or Collada in my library.
other libraries don't have "com.transmote.flar"
Am I missing a library?

I looked at "Inside FLARManager: Loading Collada Models" (http://
words.transmote.com/wp/flarmanager/inside-flarmanager/loading-collada-
models/)
and they don't seem to use any "com.transmote.flar", they use
"org.papervision3D.objects.parsers.DAE"

I'm confused - sorry...

eric socolofsky

unread,
Oct 30, 2009, 4:40:10 PM10/30/09
to flartool...@googlegroups.com
i think makc's point is that your question is not really about
FLARManager or FLARToolkit, it's about texturing models in papervision.
there may be some folks here who can help you, but you might have
better luck on the papervision forum.

-e

Pablo Lemos

unread,
Oct 30, 2009, 4:47:57 PM10/30/09
to flartool...@googlegroups.com
What is your doubt about collada?

I didnt understand. Maybe I can help you.

Pablo Cabana
(21) 9338-0388
Cabana Criação
(21) 2707-7020
www.cabanacriacao.com
Visite também o Cabanoblog:
www.cabanacriacao.com/blog

CLRL

unread,
Oct 31, 2009, 10:29:37 AM10/31/09
to FLARToolKit userz
With the program below I get the collada C.dae image with the proper
skin from C.png. No problems. No additional materials added. See the
link I mentioned before.

Since FLARManager is supposed to have some advantages in smoothness,
etc. I want to re-write the program using FLARManager
as I posted in the original post.
But, now I don't get the skin on the image, Only the wireframe.
The image is a simple 3D letter made in Blender.
I'm trying to figure out why and how to solve it.
------------------------------

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.parsers.Collada;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;

[SWF(width="640", height="480", frameRate="15",
backgroundColor="#FF0000")]

public class clrlar extends Sprite
{
[Embed(source="clrl.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;
private var collada:Collada;

public function clrlar()
{
setupFLAR();
setupCamera();
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 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);
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 collada:Collada = new Collada("c.dae");
collada.x = 20; // -160 brings it down to center of pattern (scale
= 1)
collada.y = -60; //+100 moves to right to edge of paper
collada.z = 10; // +100 bring it closer - size of paper at +100
collada.rotationX = 180; // CW in left-right axis
collada.rotationY = -90; // CCW in vertical axis
collada.rotationZ = 90; // CW in front-back axis
collada.scale = 0.2;
container.addChild(collada);


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

Thanks.
-cl
====================================================================

jbyrne2007

unread,
Oct 31, 2009, 1:48:28 PM10/31/09
to FLARToolKit userz
your problem lies with papervision not flar it might be best to post a
question on there forum about model texturing and smoothing, you could
look into papervision plugins like DAEMC2 which is alot smoother for
animations etc.
> > >>> it doesnt have com.transmote.flar in it, does it?- Hide quoted text -
>
> - Show quoted text -

chris

unread,
Nov 5, 2009, 5:43:55 PM11/5/09
to FLARToolKit userz
Maybe I'm not on the right track, but I think I actually had the same.
The thing they don't mention in the tutorial is to put the texture-
file together with the dae file. Then it works.

Good luck

CLRL

unread,
Nov 6, 2009, 10:23:12 AM11/6/09
to FLARToolKit userz
The .dag and the .png are together, just like in my original project.
It should take care of the material part of the image. Not a
Papervision3D problem since it works in the original (non- FLARManager
writeout).
It just don't work when I use FLARManager and no one seems to be able
to have an answer why...
:(
-cl

craig

unread,
Dec 7, 2009, 4:45:33 AM12/7/09
to FLARToolKit userz
Possibly a bit late, I've had this trouble myself with collada models
and recognising relative paths from when I exported them.

If you load in your material as a new material list

var materialList = new MaterialsList ();
bitmapFileMaterial = new BitmapFileMaterial ('path to your texture');
materialList.addMaterial(bitmapFileMaterial, "all");


Then pass this material onto your collada model when you load it in,
all should work fine:

var collada = new DAE();
this.collada.load('path to your model');
this.collada.scale = 150;



On Nov 6, 3:23 pm, CLRL <wb6...@gmail.com> wrote:
> The .dag and the .png are together, just like in my original project.
> It should take care of the material part of the image. Not a
> Papervision3D problem since it works in the original (non- FLARManager
> writeout).
> It just don't work when I use FLARManager and no one seems to be able
> to have an answer why...
> :(
> -cl
>
> On Nov 5, 2:43 pm, chris <cuytho...@gmail.com> wrote:
>
> > Maybe I'm not on the right track, but I think I actually had the same.
> > The thing they don't mention in the tutorial is to put the texture-
> > file together with the dae file. Then it works.
>
> > Good luck
>
> > On Oct 30, 2:03 am, CLRL <wb6...@gmail.com> wrote:
>
> > > I made a geocaching puzzle project displaying 3D images made in
> > > blender following the "gotoAndLearn" tutorials "Introduction to
> > > Augmented Reality" and "Papervision3D Collada Basics". I used Flex 3.0
> > > see ==>http://www.clrlworld.com/AR1/
>
> > > After watching the new "Augmented Reality with FLARManager" and
> > > successfully making the tutorial, now I'm trying torewritethe Flex 3

craig

unread,
Dec 7, 2009, 5:04:23 AM12/7/09
to FLARToolKit userz
Possibly a bit late, I've had this trouble myself with collada models
and recognising relative paths from when I exported them.

If you load in your material as a new material list

var materialList = new MaterialsList ();
bitmapFileMaterial = new BitmapFileMaterial ('path to your texture');
materialList.addMaterial(bitmapFileMaterial, "all");


Then pass this material onto your collada model when you load it in,
all should work fine:

var collada = new DAE();
this.collada.load('path to your model', materialList);
this.collada.scale = 150;


On Nov 6, 3:23 pm, CLRL <wb6...@gmail.com> wrote:
> The .dag and the .png are together, just like in my original project.
> It should take care of the material part of the image. Not a
> Papervision3D problem since it works in the original (non- FLARManager
> writeout).
> It just don't work when I use FLARManager and no one seems to be able
> to have an answer why...
> :(
> -cl
>
> On Nov 5, 2:43 pm, chris <cuytho...@gmail.com> wrote:
>
> > Maybe I'm not on the right track, but I think I actually had the same.
> > The thing they don't mention in the tutorial is to put the texture-
> > file together with the dae file. Then it works.
>
> > Good luck
>
> > On Oct 30, 2:03 am, CLRL <wb6...@gmail.com> wrote:
>
> > > I made a geocaching puzzle project displaying 3D images made in
> > > blender following the "gotoAndLearn" tutorials "Introduction to
> > > Augmented Reality" and "Papervision3D Collada Basics". I used Flex 3.0
> > > see ==>http://www.clrlworld.com/AR1/
>
> > > After watching the new "Augmented Reality with FLARManager" and
> > > successfully making the tutorial, now I'm trying torewritethe Flex 3

Benson Tan

unread,
Dec 7, 2009, 7:48:03 AM12/7/09
to flartool...@googlegroups.com
Thanks alot without your help, I will never have figure it out. Once again thanks.
--

Thanks
Benson
Reply all
Reply to author
Forward
0 new messages