Jump to content
  • Advertisement
Sign in to follow this  
Deckards

HUD with 3D object

This topic is 4913 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

I want to render the 3 world axis at a corner of the window. How can I render a 3D object in the foreground (with glOrtho) ? Do I have to render the 3 axis to a texture and then render this texture as a 2D transparent GL_QUAD?

Share this post


Link to post
Share on other sites
Advertisement
You can simply render the object in the last stage of your rendering function, disabling depth testing to make sure the axis are drawn on top of everything.

Share this post


Link to post
Share on other sites
Yes you can. You can position it like any other 3d object. In fact, an easy way to make it follow the camera is to call a glLoadIdentity first. Then just move down the z a couple units position and draw your object accordingly. Because of the reset, it won't matter where the camera is because you reset the view first. You don't even have to go Ortho if you don't want to.

Share this post


Link to post
Share on other sites
perhaps

draw normal scene

set ortho
glClear( depth buffer )
draw axis

or

set ortho
glDepthRange(0.0,0.01)
draw axis

Share this post


Link to post
Share on other sites
The problem is that I need to rotate the 3 axis according to the camera orientation.
I think I have to compute the view matrix manually without gluLookAt to discard the camera position

Share this post


Link to post
Share on other sites
I managed to render the axis in the lower right part of the screen by altering the viewport size.
At the end of the rendering:

const int AXES_VIEWPORT_SIZE = 50;
glDisable(GL_DEPTH_TEST);
glViewport(0, 0, AXES_VIEWPORT_SIZE, AXES_VIEWPORT_SIZE);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

//draw the axis

//set back the viewport to normal


The problem now is that I don't know how to rotate the axis without translating them so that they stay at the same location in the small viewport.

Share this post


Link to post
Share on other sites
Quote:
Original post by Deckards
The problem now is that I don't know how to rotate the axis without translating them so that they stay at the same location in the small viewport.


Just multiply by the same matrix from your camera except with the translation part (indices 12,13, and 14 in the array) set to 0.

Share this post


Link to post
Share on other sites
You should be able to do it easily. If you call a glLoadIdentity first, then translate to the position(lower left or whatever), then rotate according to the same angles as you camera(not using gluLookAt rather glRotatef), don't try to use LookAt, just rotate and draw like anything else.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!