PDA

View Full Version : How to draw and rotate 2d text in 3d space?



MicroBotox
09-21-2010, 10:03 AM
Hi

Please help do draw a street name on a street in 3d view.
The street name is 2d text.
How to do it?
My specific questions are
1.Should the text be drawn in 2d or 3d projection?
2.I calculated the direction vector of a street line and then transfered it to the angle in which z axis should be rotated in order to put the text on the street, but I dont know how to draw and then rotate it correctly.

MicroBotox
09-23-2010, 02:01 AM
No suggestions? :( :(
I forgot to mention that street names are dynamic (I can't prepare them ahead and use texture fonts).


P.S. Should I post this in the advanced forum?

Thanks

RefleX
09-23-2010, 03:33 AM
2d text are drawn as quads using a texture containing the characters of the font. So 2d text are actually 3d. All your normal transformations should work the same for your text as it should with your models.

1. I think it should be used with a 3d projection, but should be scaled accordingly.

2. Well this depends on what you actually want the end result to look like, which is still unclear to me. Maybe some screenshots, or reference pics will help us get a better picture of what you trying.

Why can't you create dynamic names using a font texture? It's not like you changing the font, you changing the order your quads are drawn, and to what character their co-ordinates are aligned to on the font texture. Also can you please post some code?

MicroBotox
09-23-2010, 06:21 AM
Hi

I can't post source code since I didn't implement it yet...
What I want to do is like in this attached screen shot from Google Earth.If you can see street names there displayed on the streets. (Please click on the image to see it bigger)

http://yfrog.com/0ygearthclipj

I don't expect to get here ready source code, since I think I know how to do each thing separately.I just don't know how to put things together to create such an effect:
1.Which type of font to use? (it's bitmap or texture font?other?)
2.How to draw it(in which projection)?
3.How to render and rotate in z axis?
All examples I saw so far - text is always drawn assuming there is no depth.

Thanks

RefleX
09-26-2010, 08:16 AM
It sounds as if you not experienced with graphics programming, or have a very small picture of what it's about. So it's not a matter of giving you a simple answer since you need help in more than one area. Maybe you could ask someone that has the experience to do it for you.

MicroBotox
09-27-2010, 10:28 AM
Solved it myself. Thanks anyway.


It sounds as if you not experienced with graphics programming, or have a very small picture of what it's about. So it's not a matter of giving you a simple answer since you need help in more than one area. Maybe you could ask someone that has the experience to do it for you.

^Ummmm,that was a bit harsh. But it motivated me even more,so thanks. Actually my all questions could be answered in 2 short sentences....

jonlee107
11-09-2010, 06:47 AM
hey MicroBotox,

Glad you were able to solve it. Do you mind sharing any pointers or suggestions on how to accomplish what you were doing?

MicroBotox
11-09-2010, 11:56 PM
Hi

Of course.So in 2 sentences...:

1.Draw your text into texture and then put it on quads and render it as usual 3D geometry.
2.I used FTGL(http://sourceforge.net/projects/ftgl/), it shortens a work significantly

jonlee107
11-10-2010, 06:57 AM
Hey MicroBotox,

Thanks for the reply. I did look into FTGL since I read that was one of the easiest ways to do fonts/text for OpenGL. However I am currently having trouble getting the library to work. What language are you using to do this? I'm working with VB.NET in VS2010. Any pointers to lead me in the right direction would be greatly appreciated.

MicroBotox
11-10-2010, 11:59 PM
I'm using plain Win32 C/C++ with Borland Developer Studio and I'm not familiar with VB.NET

Maybe repost your question as a new topic with subject something like "FTGL and VB.NET" so it will take attention of people who are familiar with it and they'll help you.

jonlee107
11-12-2010, 10:11 AM
Thanks! Will do.