How can i blit text in world objetcs?

Started by rodplamo, April 15, 2011, 12:41:36 PM

Previous topic - Next topic

rodplamo

Hi everyone,

I'm developing an augmented reality project, and jPCT-AE is very useful. But sometimes, i have problems to continue with my developing because i don't know how to do some things. In this case, after i've put some 3d objects in virtual world, i want blit text onto these objects, and although i suppose that i've to do projections of the objects, i really don't understand how i've to do this.

Can someone help me, please?

Thanks!

EgonOlsen

I'm not sure if i really understand what you want to do. What exactly does "blit text onto these objects" mean?

rodplamo

#2
Excuse me EgonOlsen, I was on holidays...

First, sorry for my bad english. I try to explain my problem one more time:

I´m developing an augmented reality browser for android, like Layar or Wikitude, and i've used jPCT for put objects in virtual world, depending of this real coordinates, obviously. And now, I want to know how can i put text on this objects, so the text and the object move at the same time, like if they are one object only.

I hope you understand me now.

Thanks!

EgonOlsen

You can get the 2d coordinates of an object's center by using this method: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Interact2D.html#projectCenter3D2D(com.threed.jpct.FrameBuffer, com.threed.jpct.Object3D). You can then blit a text (for example out of a texture or char by char) at this position.

rodplamo


Thanks, I'll try and i'll say you if this works =)

rodplamo


One question:

I don't try yet, but i'm thinking that if i move objects with "setOrigin", object's center will be (0,0,0), and if i use this, like you said, i get the 2d coordinates of an OBJECT'S CENTER. Do it works anyway?


EgonOlsen

It's the object's calculated (or set) center projected on screen. It should work.


rodplamo

#8
...but not all rigth...It works for one object alone, if I try to do this for two objects at the same time, it not works for any.

I do this in te onDrawFrame method and after the projectCenter3D2D and blitString (one form to blit that i found in the "bones" project) i do framebuffer.display()...what's the problem? :S

EgonOlsen

No idea. I guess you are doing something wrong somehow. I can't see the slightest relationship between blitting and the number of objects. Have you checked the results from the calls to projectCenter?

rodplamo

It works with 2 or more objects, i don't know what i done wrong later.

Anyway, it not works like i want, because text and object not seem one thing only.

Add images for explain that i say:
http://dl.dropbox.com/u/10042241/1.png
http://dl.dropbox.com/u/10042241/2.png
http://dl.dropbox.com/u/10042241/3.png

rodplamo

 i.e., i would text fixed on the object

rodplamo

Can this problem be for the camera's FOV?? How can i solve it?

EgonOlsen

Have you tried to blit some simple texture instead of the text? Are you doing some additional calculations on the value returned by projectCenter3D2D? I made myself a little test case and it seems to work just fine...

rodplamo

I not do additional calculations, only this:

SimpleVector svP = new SimpleVector();
svP = Interact2D.projectCenter3D2D(fb, object);
buttonFont.blitString(fb, "Prueba", (int) svP.x, (int) svP.y, 10, RGBColor.WHITE);
fb.display();