multiple markers (the neverend story)

11 views
Skip to first unread message

jpg

unread,
Dec 7, 2009, 7:39:34 AM12/7/09
to FLARToolKit userz
Hi I´m currently trying to have various collada objects load in
multiple markers and I saw eric aproach to this problem.

var objects:Array = [obj0, obj1, obj2]; // store all 3D objects for
display, by patternId
var markers:Array = new Array(); // store active FLARMarker
instances, by patternId
// ...
private function onMarkerAdded (evt:FLARMarkerEvent) :void {
objects[evt.marker.patternId].visible = true;
markers[evt.marker.patternId] = evt.marker; // need to access
transformation matrix later...
}

private function onMarkerRemoved (evt:FLARMarkerEvent) :void {
objects[evt.marker.patternId].visible = false;
markers[evt.marker.patternId] = null;
}

private function onEnterFrame (evt:Event) :void {
for (var i:int=0; i<objects.length; i++) {
if (objects[i].visible) {
objects[i].transform =
FLARPVGeomUtils.convertFLARMatrixToPVMatrix(markers
[i].transformMatrix);
}
}
}

I understand(or quite) the logic behind this aproach but there is one
part missing in the puzzle and it is how to handle the container... In
the basic collada example I´d use this:

// create a container for the model, that will accept matrix
transformations.
this.modelContainer = new DisplayObject3D();
this.modelContainer.addChild(model);
this.modelContainer.visible = false;
this.scene3D.addChild(this.modelContainer);

Do I need one container for each object? please I don´t expect the
code just a good explanation would be priceless. Couse I read about
flartoolkit, flarmanager documentation and lot of others things but I
still don´t get this part of the code.

thx

eric socolofsky

unread,
Dec 7, 2009, 12:20:55 PM12/7/09
to flartool...@googlegroups.com
yes, you'll want to have a container for each model, since you apply
the FLAR transformations to containers, not models.

you can create containers on the fly, in a MARKER_ADDED event
handler. then, you can hash them by FLARMarker, and retrieve them
using the FLARMarker (provided by a FLARMarkerEvent) as a key.
basically:

var containersByMarker:Dictionary = new Dictionary();
onMarkerAdded (evt:FLARMarkerEvent) {
this.containersByMarker[evt.marker] = new Sprite();
//...
}
onMarkerUpdated (evt:FLARMarkerEvent) {
var container:Sprite = this.containersByMarker[evt.marker];
//...
}

-eric

jpg

unread,
Dec 17, 2009, 8:01:22 AM12/17/09
to FLARToolKit userz
thx for your help eric. I finally managed to do it

Aare Laanesaar

unread,
Dec 25, 2009, 7:04:56 AM12/25/09
to FLARToolKit userz
Which way did you go then jpg ? Flarmanager or the ''ModelContainer"
way.

Neven El Said

unread,
Dec 25, 2009, 7:27:08 AM12/25/09
to flartool...@googlegroups.com
FlarManger
Reply all
Reply to author
Forward
0 new messages