Jump to content
  • Advertisement
Sign in to follow this  
Wavesonics

GL cordinates and View Frustum

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

Ok so I'm loading in geometry from a BSP file, in my engine 3 units is about the height of a normal 6' wall, but the cordinate system in the file format, 128 units is about that height, so I was dividing all the cordinates by 64 to scale them down, but I lose too much precision for other things I need them for. So my idea was to increase the view port or do something with the View Frustum to make things looks smaller? I'm not entirely sure what to do... Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
What do you mean by losing precision for other things? What other things in particular are you referring to?

In any case, the main thing you'll need to do is set the near and far plane distances appropriately given the scale you're working with. It sounds like your scale is around 1 unit per meter, so set the near and far values accordingly (e.g. by using gluPerspective() or glFrustum()).

If after that you're still having problems, post back with more details.

Share this post


Link to post
Share on other sites
Thanks for the fast reply man!
Ok,
I'm not sure what would be appropriate values for this here.

This is what I had before:

gluPerspective(52.0f,(GLfloat)g_windowWidth/(GLfloat)g_windowHeight,0.1f,1000.0f);



I tried the near plane @ 1 an the far at 100 and it was real screwed up.

So what would be better values?
also the first argument, the angle, how should this relate to the near and far planes?

[EDIT]
As for what this is affecting, I am implementing a BSP tree, and when I divide the cords the bounding boxes get cut down for the nodes and leaves and such.

Here is the code setting up my view:

void OpenGLOps::SetUpProjection(int width, int height)
{
if (height == 0) // don't want a divide by zero
{
height = 1;
}

glViewport(0, 0, g_windowWidth, g_windowHeight); // reset the viewport to new dimensions
glMatrixMode(GL_PROJECTION); // set projection matrix current matrix
glLoadIdentity(); // reset projection matrix

// calculate aspect ratio of window
gluPerspective(60.0f,(GLfloat)g_windowWidth/(GLfloat)g_windowHeight,0.1f,100.0f);

glMatrixMode(GL_MODELVIEW); // set modelview matrix
glLoadIdentity(); // reset modelview matrix
}



[/EDIT]

[Edited by - Wavesonics on July 7, 2006 6:55:09 PM]

Share this post


Link to post
Share on other sites
I don't know that there's enough information there to answer your question exactly. Your field of view looks fine and is unlikely to be the cause of the problem. As for near and far, in general you should make the near plane as far away as is practical, and the far plane as close as possible. For the former that means putting the near plane as far out as you can without clipping away walls and such that you're standing right next to; for the latter, it means putting the near plane as close as you can without clipping away the farthest visible objects. Does that make sense?

If you have your near and far planes set optimally and you're still having problems, then it's most likely (I'm guessing) unrelated to the view frustum.

Again, we need more detail than 'real screwed up'. If you can, perhaps post a screenshot? That would certainly make things clearer.

Share this post


Link to post
Share on other sites
Well what I want to do is, make the GL cords basically look smaller. See more on the screen at once which should squish them making them smaller.

I want to just make things looks smaller, while they retain their cordinate values.

Share this post


Link to post
Share on other sites
Quote:
Original post by Wavesonics
Well what I want to do is, make the GL cords basically look smaller. See more on the screen at once which should squish them making them smaller.

I want to just make things looks smaller, while they retain their cordinate values.
'Big' and 'small' is all relative to OpenGL, for the most part. If you want to see more on screen, then back up the camera :-)

That sounds glib, but provided that your near and far values are set appropriately, adjusting the perceived size of onscreen objects is largely a matter of simply positioning the camera appropriately.

You could also change the field of view ('zoom' effect) or apply scaling via glScale(), but based on what you've said so far I'm guessing it's just a matter of setting up your camera correctly and using appropriate velocities for any camera motion.

Share this post


Link to post
Share on other sites
gluPerspective(60.0f,(GLfloat)g_windowWidth/(GLfloat)g_windowHeight,16.0f,3000.0f);

I changed it too that and things look pretty good. 16 is where the collision detection will contact at once it's implemented so it works out i think.

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!