HUD with 3D object

Started by
8 comments, last by kburkhart84 19 years, 2 months ago
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?
The Sands of Time Are Running Low
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.
But I wouldn't be able to position it relative to the window corner
The Sands of Time Are Running Low
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.


perhaps

draw normal scene

set ortho
glClear( depth buffer )
draw axis

or

set ortho
glDepthRange(0.0,0.01)
draw axis
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
The Sands of Time Are Running Low
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.
The Sands of Time Are Running Low
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.
I can't do that because the orientation of the axis depend on both the position & orientation of the camera.
The Sands of Time Are Running Low
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.


This topic is closed to new replies.

Advertisement