PDA

View Full Version : Moving Polygons With the camera



Aliorithm
04-08-2005, 10:16 AM
Dear All,
I am trying to make an animated tutorial program in OpenGL and i need to add a flat polygon to the bottom 1/4 of the screen which remains there even while the camera is moving and looking in different angles.

My next problem is trying to write 2D text on top of this flat polygon so users can read information on the 3D models in the top 3/4 of the screen.

Any Help would be much appreciated. Thank you!!!
ALI

dorbie
04-08-2005, 11:02 AM
You can place objects in eye space by drawing them when the viewing matrix is not on the modelview matrix stack.

So in pseudocode:


glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
glTranslatef(position_of_text_polygon_relative_to_ eye);
draw_polygon();
draw_text();
glPopmatrix();
glLoadMatrix(eye_animation_motion_matrix);
draw_scene_as_normal();This is just one example, you could also draw the text last, this would let you clear the zbuffer beforehand and not worry about 3D stuff intersecting vs near clip etc. but it wouldn't benefit from coarse zbuffer style optimizations on a lot of hardware. That would look like this:


glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
glLoadMatrix(eye_animation_motion_matrix);
draw_scene_as_normal();
glPopmatrix();
glClear(GL_DEPTH_BUFFER_BIT);
glTranslatef(position_of_text_polygon_relative_to_ eye);
draw_polygon();
draw_text();

SirKnight
04-08-2005, 05:17 PM
Originally posted by dorbie:
You can place objects in eye space by drawing them when the viewing matrix is not on the modelview matrix stack.Um...eye-space is where you are after the modeling and viewing transforms have taken place. If you apply ONLY a modelling transform, that's world space.

(obj. space)->[MODELING_XFRM]->(world space)->[VIEW XFRM]->(eye space)->[PROJECTION XFRM]->(clip space)->...

EDIT: Yeah I know you know this, probably just a typo like thing. :D

-SirKnight