Sign in to follow this  

How to draw 3d text

This topic is 3032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, I want to draw x, y and z axis labels in my surface plot. I can draw these labels using the glut library. But the problem is that when the plot is rotated the labels are not getting rotated. I know the reason that these labels are drawn in 2d. So that`s why I want to draw 3d text so that the labels can also be rotated along with the plot. Thanks for your help, Regards, Srinu

Share this post


Link to post
Share on other sites
You could position your labels in 3D by specifying x,y,z coordinates (use your existing labels that you render in 2D). To make sure that they are facing in the correct direction so that they are readable, you want to billboard them: http://www.lighthouse3d.com/opengl/billboarding/

When you billboard an object you make sure that it is always facing the camera.

Share this post


Link to post
Share on other sites
Hi mmakrzem,
Thanks for your reply. I tied billboarding but it did not come useful to my requirement.
Actually What my exact requirement is that - I have a 3d plot and 3 axes (x, y and z). The divisions on these axes are drawn using glut. But when the plot is rotated the text divisions are not. I think glut draws text in 2d format. If it is 3d text then the divisions are also get rotated. So, basically I need the divisions should also get rotated along with the plot.


~Srinu

Share this post


Link to post
Share on other sites
You can obtain the 2D positions of the 3D objects, and draw the text at that position, using gluProject. Example:

GLdouble modelViewMatrix[16];
GLdouble projMatrix[16];
GLint viewport[4];
GLdouble winx, winy, winz;

glGetDoublev(GL_MODELVIEW_MATRIX, modelViewMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
glGetIntegerv(GL_VIEWPORT, viewport);

GLdouble winx, winy, winz;

gluProject(
x3d,
y3d,
z3d,
modelViewMatrix,
projMatrix,
viewport,
&winx,
&winy,
&winz
);

drawTextAt(winx, winy);


EDIT: Not sure what you want exactly, do you want the text _position_ to be rotated to correctly align with the 3D point, or do you want the actual text to be rotated, so that the text is a 3D object that you can move around and see from different directions?

Share this post


Link to post
Share on other sites
Hi Erik,
Thanks for the reply.
I am able to draw the text using the method you said. The text drawn in this way can be rotated? But I am not able to rotate the text.

TO all,
I am explaining my requirement once again with the image. Please look at the image at the following location.
http://upload.wikimedia.org/wikipedia/commons/archive/6/69/20070804225815!2D_Wavefunction_%282,2%29_Surface_Plot.png

I drawn the plot and axes same as in the above image. In this image the divisions or markings on the axes (0.0, 0.1, 0.2, 0.3, 0.4, etc....) can be rotated. Whereas in my image these can not be.
Simply, my requirement is that How to draw text which can be rotated? That is the actual text to be rotated, so that the text is a 3D object that we can move around and see from different directions.


Thanks,
Srinu

[Edited by - srinivaz111 on August 24, 2009 4:16:42 AM]

Share this post


Link to post
Share on other sites
But Nehe is only Windows !!

There is an easy to use library for rendering 3D text in OpenGL, FTGL:
http://sourceforge.net/projects/ftgl/

It supports texture fonts, vector fonts and 3D polygonal fonts. MIT license.
Requires FreeType.

Share this post


Link to post
Share on other sites

This topic is 3032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this