flartoolkit away3d object movement

188 views
Skip to first unread message

Kevin Phytagoras

unread,
May 26, 2013, 6:18:40 AM5/26/13
to flartool...@googlegroups.com
Hello Guys, now im creating an augmented reality project that can make the object move around my monitor. 
The problem is i dont know how to move my object. 
Here's what i already try 

var collada3:Collada = new Collada();
collada3.scaling = 10;
Vector3D.Y_AXIS;
var model3:ObjectContainer3D = collada3.parseGeometry(Charmesh) as ObjectContainer3D;
model3.materialLibrary.getMaterial("FF_FF_FF_mario1").material = new BitmapMaterial(Cast.bitmap(Charmap));
model3.mouseEnabled = false;
model3.rotationY = 180;
model3.x = 0;
model3.y = 0;
model3.z = 0;
for (var i:int = 0; i < 10; i++)
{
model3.x + 100;
trace(model3.y);

}
this.modelAnimator3 = model3.animationLibrary.getAnimation("default").animator as BonesAnimator;

My object doesn't move an inch by this way. Any suggestion ? Any help is accepted. Thank you

Daniel Ferenc Szak

unread,
May 26, 2013, 6:25:01 AM5/26/13
to flartool...@googlegroups.com

What exact movement are You expecting?

If it is along the x axis - if You do change position in a for loop, You'll have that done before there is any frame update and probably should use some sort of animation/onenterframe loop instead.

If it is the bones animation Your model has, i have no experience with that :s but if Your model does not auto-animate You probably have to call a start() of some sort on the bones animator object.

Happy coding!

--
 
---
You received this message because you are subscribed to the Google Groups "FLARToolKit userz" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flartoolkit-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kevin Phytagoras

unread,
May 26, 2013, 7:31:30 AM5/26/13
to flartool...@googlegroups.com
along x axis. I try use the for but i dont understand what you mean.
can you please give me an example ?
sorry if its such a bother

Daniel Ferenc Szak

unread,
May 27, 2013, 4:12:18 AM5/27/13
to flartool...@googlegroups.com
Kevin,

try this article, step 13 is the "main loop" that drives the animation - but if You do not understand the difference between the for loop and frame based animations, i would recommend to read the whole stuff!

You should drop the for loop in favor of the enterframe handler for animation.
Here are some other hints:

//for (var i:int = 0; i < 10; i++)
//{
// You do not make a value assign here...
// model3.x + 100;
// ...try instead
model3.x += 100;
// ...although You change the x value now, You trace the y - that does not change over the time...
// trace(model3.y);
trace(model3.x);
//}

I hope this helps.

Happy coding!

Kevin Phytagoras

unread,
Jun 17, 2013, 8:30:49 AM6/17/13
to flartool...@googlegroups.com
Thanks for your response. I already solved the problem. I modify my code to this 

var collada:Collada = new Collada();
collada.scaling = 1;
model = collada.parseGeometry(Charmesh) as ObjectContainer3D;
model.materialLibrary.getMaterial("FF_FF_FF_mario1").material = new BitmapMaterial(Cast.bitmap(Charmap));
model.mouseEnabled = false;
model.rotationY = 180;
model.rotationX = -90;
model.x = 0;
model.y = 0;
model.z = 0;
this.modelAnimator = model.animationLibrary.getAnimation("default").animator as BonesAnimator;


and to move my object on this

private function onEnterFrame (evt:Event) :void {
// apply the FLARToolkit transformation matrix to the Cube.
if (this.activeMarker) {
this.modelContainer.transform = AwayGeomUtils.convertMatrixToAwayMatrix(this.activeMarker.transformMatrix);
model.y -= 10;
}
// update the animation and Away3D view.
if (this.modelAnimator) {
this.modelAnimator.update(getTimer() * .0005);
}
this.view.render();
}

My problem before is i dont execute my code to mvoe object everytime the object is rendered. I only executed it once.

Anyway thank you very much for your response SZFD. I hope it will not bother you if i ask again sometime. :D Thanks you again.

Daniel Ferenc Szak

unread,
Jun 17, 2013, 10:46:39 AM6/17/13
to flartool...@googlegroups.com
Good afternoon,

How do You set up the listener on the enterframe event?
Definitely would be nice to see more code of Yours to be of any help...
With the onEnterframe listener You would move Your object (depending on Your Frames Per Seconds setting) 24-60 times x 10 units on the Y axis...meaning that if these are pixels, at 60 fps You move Your object 600 pixels, and that in two seconds it would simply by out of the viewport...
(this is just another issue that maybe You have - sincerely i didn´t quite understood Your last email/problem)


--

Kevin Phytagoras

unread,
Jun 18, 2013, 2:53:40 AM6/18/13
to flartool...@googlegroups.com
Here my full code http://pastebin.com/gKvdytum

And no, the object not move out of the window, It move just perfectly like i want. I dont know why, maybe my window is big ?

My problem right now is, when i use a detailed model, my program getting laggy. When i use a low poly one that i make in blender, it wont appear. My object is DAE format and my engine Away3D. When im googling, i try to make it in blender, export it as FBX, then convert it to DAE using FBX converter, i get RangeError: Error #1125: The index 0 is out of range 0.

Daniel Ferenc Szak

unread,
Jun 18, 2013, 4:22:58 AM6/18/13
to flartool...@googlegroups.com
Good morning Kevin,

i didn´t quite get Your problem with the movement - is it working as expected now? I can´t see anything wrong at first look in Your code...

About the model exported from blender - i'm definitely sure that the FBX is not needed, being both DAE and Blender opensource and playing well together. The problem should be with Your export settings since one model works, Yours is not.
I found this article on Blender -> Away3D, hope it helps!

Cheers,
daniel.

--
Reply all
Reply to author
Forward
0 new messages