Display Multiple Objects for 1 Marker

131 views
Skip to first unread message

Akeem Whitehead

unread,
Apr 9, 2012, 5:58:22 PM4/9/12
to FLARToolKit userz
Hello,

I’m trying to develop an application that will be able to handle user
input from the keyboard. My end goal is to be able to have several 3D
objects loaded in the background of the program (let’s say for
instance a cube, a pyramid, and a sphere), and initialize the program
to only show the cube on a single pattern file (let’s say I’m using
Pattern 3 for instance). I want to be type a character such as “2” or
“p” to display the pyramid instead of the cube on the same marker/
pattern, as well as be able to type “3” or “s” to display the sphere
instead of the previously displayed object.

My first question is to determine whether or not it is possible to
even insert user input from the keyboard; if so, where must I
implement this segment of code?

Thanks,

Shachar Oz

unread,
Apr 10, 2012, 2:24:15 AM4/10/12
to FLARToolKit userz
it is very simple and indeed possible.
these are your steps:
1- search the web for keyboard events in flash.
2- create an application that can get the right events.
3- create a simple flartoolkit application (i.e. here is a free source
code i wrote that allows easy embedding of 3d objects:
http://www.otherreality.org/projects/flashExamples/download/firstARapplication.rar).
4- use the code i wrote (a function called Display3DMaker.makeDae() )
to make the switch at the right time.
Note: make sure the scale of the object is adjusted.

makeDae (url:String, _scale:Number=1, _clickFunc:Function=null,
_bodyName:String=null, _extra:Object=null ):DisplayObject3D




On Apr 10, 12:58 am, Akeem Whitehead <whitehead.ak...@gmail.com>
wrote:
Message has been deleted
Message has been deleted

Akeem W.

unread,
Apr 18, 2012, 1:21:26 PM4/18/12
to FLARToolKit userz
Thanks Oz!

I have tried incorporating keyboard events into my code as can be seen
below; however, I have only been partially successful.

//
****************************************************************************
//Ride Marker
case 0:
if (rotateLeft == true) {
_theDisps[id]=Display3DMaker.makeDae('../database/media/daes/
scout.dae',0.25,null,"body",{rotX:90,x:0});
_theDisps[id].name = "helicopter";
Debugger.trace("Scout");
}
else if (rotateRight == true) {
_theDisps[id]=Display3DMaker.makeDae('../database/media/daes/
mario_testrun.dae',5,null,"body",{rotX:90,x:0});
_theDisps[id].name = "mario";
Debugger.trace("Mario");
}
else {
_theDisps[id] = Display3DMaker.makeDae('../database/media/daes/
cow.dae', 15, null, "body", { rotX:90 } ); //APW
_theDisps[id].name = "cow";
Debugger.trace("Cow");
}

break;
//
****************************************************************************

I have 3 objects that are to be visible or hidden based on the key
pressed. Within the switch case statement under case 0 (uses Ride
Marker), I have created Booleans rotateLeft and rotateRight (don't
actually rotate, but swap visible objects). The objects will not swap
when running the swf file. The debugger verifies that the keys are
being pressed. The Cow is the default model to be displayed. The
objects only display according if the i.e. the left key is pressed and
held down while opening the swf file, then the Scout model is
displayed. However, once the key is released, and other keys are
pressed, the model will not change and remains as the Scout.
The Booleans were created as such:

//
****************************************************************************
stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, stage_onKeyUp);

private var rotateLeft:Boolean;
private var rotateRight:Boolean;

private function stage_onKeyDown(e:KeyboardEvent):void {
if (e.keyCode == Keyboard.LEFT) {
rotateLeft = true;
} else if (e.keyCode == Keyboard.RIGHT) {
rotateRight = true;
}
}
//
****************************************************************************

What I need is the models to swap in real time, and that once a key is
pressed, it is considered held down until another key is pressed.

I'd appreciate the help!

Shachar Oz

unread,
Apr 19, 2012, 3:10:01 AM4/19/12
to FLARToolKit userz
Hey man,
What you have here is a typical flash issue and it is not related to
flartoolkit.
every time you call the displaymaker.makedae function it creates
another dae file. Which in turn adds more objects to your marker.
You should doo 2 things. First, remove the current object before
adding a new one. Then, make sure you do not add the same object
twice.

Akeem W.

unread,
Apr 23, 2012, 5:52:33 PM4/23/12
to FLARToolKit userz
Based on what you've proposed, I've been able to partially achieve my
objective. Using one marker, I can alternate through the various
3d .dae files; however, the desired .dae will update only after I
swipe my hand over the marker. In short, I have to physically
interfere the tracking of the marker to force a change of the .dae
file, otherwise, no change occurs. What I need is to be able to be
able (through code) momentarily tell the program to stop detecting the
marker, so the update can occur. Through this approach, I will not
have to physically interfere; however, I do not know where I should
implement this segment of code, nor what the code must be.

I've been able to reach my current milestone bmodifyingng the
_addDisplayObject and _removeDisplayObject functions, so I would
assume the answer lies within these two functions.

Do you have any proposed solutions?

ted dbahsee

unread,
Apr 23, 2012, 5:59:16 PM4/23/12
to flartool...@googlegroups.com
Unfortunately I'm still so new to all of this, i am setting up my work environment and trying to understand everything. im so new at this ive started  a few weeks ago on this venture, if you have any where i can learn online id appreciate some info  

Shachar Oz

unread,
Apr 28, 2012, 11:45:56 AM4/28/12
to FLARToolKit userz
I dont really understand why you need to hide the marker with your
hand. Doesnt sounds right. I believe the example code i wrote works
ok, doesnt it?

I would suggest investing your time investigating why the code doesnt
work. It would be much more efficient.

ted dbahsee

unread,
Apr 28, 2012, 12:12:17 PM4/28/12
to flartool...@googlegroups.com
can any of you gentlemen maybe assist me with inserting video clips into my ar code, im a total newb at this but dying to learn more about it all, any suggestions as sites or forums , groups etc  would be greatly appreciated

Daniel Ferenc Szak

unread,
Apr 28, 2012, 12:37:21 PM4/28/12
to flartool...@googlegroups.com

with all respect...

i think all of You "newbees" need to start with seeing how ALL THE TECHNOLOGIES work together, seriously...
It is a mix of an API of a 3d renderer (papervision or whatever) and a pattern recognition/matrix calculator (flar).  The sooner You realize these techs behind the "magic", the sooner You will encounter the answers to all of Your questions (You have to look in the RIGHT PLACE)...

Flar "only" helps You with one variable of the equation (namely a transformation matrix applied to a whole 3d scene), and it does not care how or with what You use it. You would still need to learn (and understand) PAPERVISION or the renderer of Your choice.

I know personally that there are a LOOOOOOOOT of material out there in  the wild about all kind of uses of pv3d, please make us a favor and do some searching...

just some cents of thought.

Happy coding,
daniel

ps: i am sure there are a lot of people who may answer Your question anyway, but if You do not understand the basics of what You are into, it wont be of any help..i am sure You understand.

ted dbahsee

unread,
Apr 28, 2012, 12:53:48 PM4/28/12
to flartool...@googlegroups.com
yes very much and i am actually working on learning ppv3 and all facets surrounding the AR tech   but i like messing around and tinkering with stuff anyways so this is why i ask

Daniel Ferenc Szak

unread,
Apr 28, 2012, 1:04:41 PM4/28/12
to flartool...@googlegroups.com

Ted, no offense ment.

You should look up the internest for "video in papervision", and i am sure You will encounter answers.

If the stuff You encounter does not help You, maybe all the stuff given to You here would not help You neither.

Again, keep up Your interest and happy coding
daniel

Sergio Daniel

unread,
Apr 28, 2012, 1:36:40 PM4/28/12
to flartool...@googlegroups.com, flartool...@googlegroups.com


Sergio Daniel Fernández González
Reply all
Reply to author
Forward
0 new messages