Archived

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

Paddeh

Draw distance

Recommended Posts

Paddeh    122
how would i go about extending the default draw distance? my game world is kinda big, and i wish to prevent it from cutting off teh other side of my world (it stops rendering it)

Share this post


Link to post
Share on other sites
Lunatic Raven    122
If your world is that huge, it would be best for it to cut of some of it. Places on your world that are not seen, shouldn''t be drawn to increase frame rates. Since it cuts off in the distance, some clever use of fog or something can give you the illusion that it doesn''t, and then only draw the current stuff that is visible. I hope that makes sense.

Share this post


Link to post
Share on other sites
Paddeh    122
thanks for the help, however, im not quite sure if i understand either of those methods :/ anything simpler?

basicly i''ve got a skybox with a world in the middle of it, if i move to one corner of my skybox the other corner gets cut off when i look towards it.

Share this post


Link to post
Share on other sites
NewDeal    134
Look for the function zedzeek mentioned (its very likely there somewhere ). Increase the far parameter to whatever distance you need.

Share this post


Link to post
Share on other sites
Paddeh    122
that function seems to be inafective, what sort of values should i be putting in? (i know it depends on the size of my world) but should there be any negative values or what?
this is wahst wrong exactly
http://www.tvsclan.f2s.com/paddy/problem copy.jpg


Edited by - Paddeh on November 9, 2001 11:59:15 AM

Share this post


Link to post
Share on other sites
Krayzeenbk    122
Ok here''s what you do.
When drawing your world, you normally first rotate and then translate around your camera (some use the function LookAt() I believe, but I just do it manually).
When drawing your skybox, you only rotate, and not translate around the camera. That way the skybox (and in my case, sky sphere) travels with the camera through the game world and is never clipped unless it''s too big.
If you really want to see more of the world at once, you might try either scaling it down (making everything smaller so more fits) or increasing the depth buffer clip distance.
Hope that helps.
If you''re confused, here''s my code for rotating the skybox around the camera:

// Draw terrain
glLoadIdentity( );
glRotatef( -m_Camera.m_sDirection.x, 1.0f, 0.0f, 0.0f );
glRotatef( -m_Camera.m_sDirection.y, 0.0f, 1.0f, 0.0f );
glRotatef( -m_Camera.m_sDirection.z, 0.0f, 0.0f, 1.0f );
// Draw sky box/sky sphere

Share this post


Link to post
Share on other sites
Paddeh    122
thanks man how would i go about increasing the depth buffer clip distance?
Its basicly waht i want, since my world/skybox Is roughly the size i want it.
thanks again

Share this post


Link to post
Share on other sites
Krayzeenbk    122
You would use gluPerspective( fov, ratio, near, far ); as mentioned above.
But I really suggest you don''t, unless you really really want to have more of the world visible to you (or your world is so scaled up that it''ll have the same effect as scaling the world itself down). On some slower systems this might hurt framerates significantly. I actually had to manually derive and add perspective clipping a short while ago to improve framerates in my prog =)
I also made it so you can move my skysphere closer and farther away from the camera, because I had so many polygons on the screen.

Share this post


Link to post
Share on other sites
Paddeh    122
:O
that sounds way ahead of me
I realise im supposed to use this command, but im not sure exactly HOW to use it... what kinda values should i be using for a world thats basicly the size of a 50x50 cube? (skybox)
and should it go in my draw function or int function or what?
thanks again

Share this post


Link to post
Share on other sites
Krayzeenbk    122
It should go in your initialization function. Here''s how it works:

gluPerspective( fov, ratio, near, far );

fov - this variable is the field of view (you probably know this) to either side of center, so it''s half of the total field of view. So if you wanted the fov to be 90 deg, then you would set this to 45.

ratio - the aspect ratio of the screen, this is just width/height, I would suggest using your resolution in that ratio, but 4/3 (1.3333f) should work for most standard resolutions.

near - the near clipping. This is how far from the camera an object must be to still be drawn on the screen. Set this to a very small value, I had it at 0.1f.

far - far clipping. This is how deep the depth buffer will be. If you''re going to use a skybox and you want each polygon to be 50 units away from the camera, you will need to set this at least to the square root of triple 50 squared (I''m assuming you know the pythagorean theorem and probably trigonometry too) to prevent the corners from being clipped. So, for a distance of 50, you''ll want to set this to at least 87.

Share this post


Link to post
Share on other sites
Paddeh    122
thanks again, however, this code just simply refuses to work atall. It compiles and all, it just has no visible effects. thanks anyway

Share this post


Link to post
Share on other sites
Winter    122
Then forget about gluPerspective function and use glFrustum instead. The last parameter in glFrustum should be rather big in order to render your skybox properly. By the way, I had the same problem long time ago and it dissapeared when I increased the last glFrustum parameter. This *MUST* work

Share this post


Link to post
Share on other sites
Paddeh    122
clearly i am doing something horribly wrong, as none of these functions will make the slightest bit of difference
anyway, thanks all for your help, I''ll leave it alone for now and hope that it sorts itself out ;O

Share this post


Link to post
Share on other sites
MirekCz    132
ello,

"basicly i''ve got a skybox with a world in the middle of it, if i move to one corner of my skybox the other corner gets cut off when i look towards it. "

hmm? If camera moves, you should move the skybox as well. So camera is ALWAYS in the center of it.



With best regards,
Mirek Czerwiñski
http://kris.top.pl/~kherin/

Share this post


Link to post
Share on other sites
Paddeh    122
umm
then my camera system would be redundent, the idea is to have a camera that actually moves. and doesnt stay stuck in the middle of a box

Share this post


Link to post
Share on other sites
zedzeek    529
paddeh u misunderstand a skybox. u can never get closer to a skybox if the camera could move inside a skybox then the whole skybox effect wouldnt work cause the textures are meant to be seen when the camera is in the exact center of the box, if the camera aint then the textures will apppear to be distorted

Share this post


Link to post
Share on other sites
Paddeh    122
now im confused >:| I really didnt think it mattered. anyway, I guess i''ll wait a while before I attempt this kinda thing again
guess its for more experienced programmers
thanks for the help all

Share this post


Link to post
Share on other sites