• Advertisement

Archived

This topic is now archived and is closed to further replies.

a window in front of my camera

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

hi all, as you can see in the subject, i want a window infront of my camera so that where ever the camera rotates and goes it will stay at its place like as a person looking to the world from a frame (behind a window) how can i do this? i have loaded a 2d window from maya, as my camera goes back and forward it stays like a frame everything is ok, but when i rotate my camera i changes.. As a summary: I want a frame around my window what ever happens I want to see it the same way it was. what should i do?

Share this post


Link to post
Share on other sites
Advertisement
The solution is most likely in the order of your transformations. Try translating before you rotate the window.

Share this post


Link to post
Share on other sites
Load you identity matrix after drawing your scene and draw the frame after that.

PS: Are you using gluLookAt?

[edited by - Albatross on April 11, 2004 4:33:19 PM]

[edited by - Albatross on April 11, 2004 4:34:34 PM]

Share this post


Link to post
Share on other sites
Here''s my code...That works...

glClear(GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix;
glLoadIdentity;
glOrtho(0, Width, Height, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix;
glLoadIdentity;
// Draw frame, HUD whatever here...
glPopMatrix;
glMatrixMode(GL_PROJECTION);
glPopMatrix;
glMatrixMode(GL_MODELVIEW);
glEnable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you could find the angle that you''re looking at through the camera and then the distance that you want the window to be in front of the camera and do something like this:

windowX = distanceFromCamera * cosf(cameraAngle) + cameraX;
windowY = distanceFromCamera * sinf(cameraAngle) + cameraY;

then when you draw the window:

glPushMatrix();

glRotatef(cameraAngle, ...);
drawWindow(windowX, windowY);

glPopMatrix();

all thats pretty much doing is just rotating the window around the camera at a specified distance (distanceFromCamera) and then rotating the window so its always facing the camera with the glRotatef call.

Share this post


Link to post
Share on other sites
quote:

all thats pretty much doing is just rotating the window around the camera at a specified distance (distanceFromCamera) and then rotating the window so its always facing the camera with the glRotatef call.


what would that be good for? if its supposed to always be in the same position and orientation relative to the camera its in no way different than any hud displays or whatever. DONT do anything and just draw it with an identity matrix, because (no matter what glulookat or neat camera classes try to simulate) your view is ALWAYS in the same position and looking in exactly the same direction. only the world moves around you and obviously the windows is supposed not to move, so just dont apply any transformations at all.

Share this post


Link to post
Share on other sites

  • Advertisement