Jump to content
  • Advertisement
Sign in to follow this  
beebs1

Strange Camera Problem

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

Hiya,

I've got a skybox working with OpenGL, but I'm having a strange problem. When I set the camera looking front, back, left or right the skybox draws properly. If I set the camera looking straight up or down however, the skybox isn't drawn. I've got a feeling this is because OpenGL can't decide how to orient the camera, but I'm not sure.

The code I'm using to set the camera is:

gluLookAt(
0.0f, 0.0f, 0.0f, // Position
0.0f, -1.0f, 0.0f, // Look At
0.0f, 1.0f, 0.0f); // Up


Given the the 'up' and 'look at' vectors are opposites, I guess there could be any number of ways of orienting the camera.. possibly.

Can anyone help with this?

Many thanks!

Share this post


Link to post
Share on other sites
Advertisement
Your Up and Look-at vectors should be perpendicular. Try a Look-at of (0, -1, 0) and an Up of (0, 0, 1).

Share this post


Link to post
Share on other sites
Thanks, that works :)

My mistake - I thought the up vector was relative to the scene, not the camera. Is it expected to recalculate this every frame?

Share this post


Link to post
Share on other sites
Yes - Up defines the "upwards" direction from the perspective of the viewer (camera). You could rotate the Up vector (so long as it remains perpendicular to Look-at) to accomplish a "roll" effect (in the traditional pitch/yaw/roll sense of the word).

Share this post


Link to post
Share on other sites

Yes - Up defines the "upwards" direction from the perspective of the viewer (camera). You could rotate the Up vector (so long as it remains perpendicular to Look-at) to accomplish a "roll" effect (in the traditional pitch/yaw/roll sense of the word).


He is using gluLookAt, which will orthonormalized his camera axes for him in the generated matrix, however, (0, -1, 0) x (0, 1, 0) is obviously (0, 0, 0). So yes, the Up vector supplied to gluLookAt cannot be parallel to the vector formed by (lookAt - eyePosition).

Share this post


Link to post
Share on other sites
Ah, good to know. I haven't touched OpenGL in many years, and my freshest memory of building view matrices is from doing it by hand where you need to ensure the vectors are normalized and orthogonal :-)

(Shows how often I write graphics code, heh!)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!