www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: rodplamo on April 15, 2011, 12:41:36 pm

Title: How can i blit text in world objetcs?
Post by: rodplamo on April 15, 2011, 12:41:36 pm
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!
Title: Re: How can i blit text in world objetcs?
Post by: EgonOlsen on April 15, 2011, 02:17:42 pm
I'm not sure if i really understand what you want to do. What exactly does "blit text onto these objects" mean?
Title: Re: How can i blit text in world objetcs?
Post by: rodplamo on April 26, 2011, 09:35:05 am
Excuse me EgonOlsen, I was on holidays...

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

Im 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!
Title: Re: How can i blit text in world objetcs?
Post by: EgonOlsen on April 26, 2011, 08:45:14 pm
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) (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.
Title: Re: How can i blit text in world objetcs?
Post by: rodplamo on April 28, 2011, 09:31:55 am

Thanks, I'll try and i'll say you if this works =)
Title: Re: How can i blit text in world objetcs?
Post by: rodplamo on April 28, 2011, 12:51:08 pm

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?

Title: Re: How can i blit text in world objetcs?
Post by: EgonOlsen on April 28, 2011, 12:52:03 pm
It's the object's calculated (or set) center projected on screen. It should work.
Title: Re: How can i blit text in world objetcs?
Post by: rodplamo on May 04, 2011, 02:52:26 pm
It works!! Thanks!!
Title: Re: How can i blit text in world objetcs?
Post by: rodplamo on May 04, 2011, 03:40:49 pm
...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
Title: Re: How can i blit text in world objetcs?
Post by: EgonOlsen on May 05, 2011, 04:40:20 pm
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?
Title: Re: How can i blit text in world objetcs?
Post by: rodplamo on May 06, 2011, 01:27:26 pm
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
Title: Re: How can i blit text in world objetcs?
Post by: rodplamo on May 06, 2011, 01:29:32 pm
 i.e., i would text fixed on the object
Title: Re: How can i blit text in world objetcs?
Post by: rodplamo on May 11, 2011, 12:57:21 pm
Can this problem be for the camera's FOV?? How can i solve it?
Title: Re: How can i blit text in world objetcs?
Post by: EgonOlsen on May 11, 2011, 09:57:26 pm
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...
Title: Re: How can i blit text in world objetcs?
Post by: rodplamo on May 12, 2011, 09:36:08 am
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();
Title: Re: How can i blit text in world objetcs?
Post by: EgonOlsen on May 12, 2011, 08:20:05 pm
Please try to blit a simple texture instead to see if the problem is caused by the blitString-method somehow (i doubt it, but you never know...).
Title: Re: How can i blit text in world objetcs?
Post by: rodplamo on May 13, 2011, 11:07:05 am
I don't know how do that you says...
Title: Re: How can i blit text in world objetcs?
Post by: EgonOlsen on May 15, 2011, 06:14:55 pm
Take any texture and blit it at these coordinates using the normal blit-methods in FrameBuffer.