Author Topic: How can i blit text in world objetcs?  (Read 9006 times)

Offline rodplamo

  • byte
  • *
  • Posts: 18
    • View Profile
How can i blit text in world objetcs?
« 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!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can i blit text in world objetcs?
« Reply #1 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?

Offline rodplamo

  • byte
  • *
  • Posts: 18
    • View Profile
Re: How can i blit text in world objetcs?
« Reply #2 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:

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!
« Last Edit: April 26, 2011, 12:20:06 pm by rodplamo »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can i blit text in world objetcs?
« Reply #3 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). You can then blit a text (for example out of a texture or char by char) at this position.

Offline rodplamo

  • byte
  • *
  • Posts: 18
    • View Profile
Re: How can i blit text in world objetcs?
« Reply #4 on: April 28, 2011, 09:31:55 am »

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

Offline rodplamo

  • byte
  • *
  • Posts: 18
    • View Profile
Re: How can i blit text in world objetcs?
« Reply #5 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?


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can i blit text in world objetcs?
« Reply #6 on: April 28, 2011, 12:52:03 pm »
It's the object's calculated (or set) center projected on screen. It should work.

Offline rodplamo

  • byte
  • *
  • Posts: 18
    • View Profile
Re: How can i blit text in world objetcs?
« Reply #7 on: May 04, 2011, 02:52:26 pm »
It works!! Thanks!!

Offline rodplamo

  • byte
  • *
  • Posts: 18
    • View Profile
Re: How can i blit text in world objetcs?
« Reply #8 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
« Last Edit: May 05, 2011, 09:42:18 am by rodplamo »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can i blit text in world objetcs?
« Reply #9 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?

Offline rodplamo

  • byte
  • *
  • Posts: 18
    • View Profile
Re: How can i blit text in world objetcs?
« Reply #10 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

Offline rodplamo

  • byte
  • *
  • Posts: 18
    • View Profile
Re: How can i blit text in world objetcs?
« Reply #11 on: May 06, 2011, 01:29:32 pm »
 i.e., i would text fixed on the object

Offline rodplamo

  • byte
  • *
  • Posts: 18
    • View Profile
Re: How can i blit text in world objetcs?
« Reply #12 on: May 11, 2011, 12:57:21 pm »
Can this problem be for the camera's FOV?? How can i solve it?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can i blit text in world objetcs?
« Reply #13 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...

Offline rodplamo

  • byte
  • *
  • Posts: 18
    • View Profile
Re: How can i blit text in world objetcs?
« Reply #14 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();