PDA

View Full Version : OGL:RealWorld measure ratio



Maverick_75
01-14-2003, 01:19 AM
Hi,

Currently Iím working on a small flight simulation (with terrain etc.) Now I know that depth buffer precision is directly dependent of distance between far and near clipping planes (correct me please if Iím wrong). Here in forums I have read an advice to have the far plane at 1000 maximum.

So lets say that Iíll use gluPerspective(45.0f, h/w, 0.1f, 1000.0f);

Now I have a fighter modeled in Max. Its characteristics are: Length 30 meters, Width 20 m and Height 10m.

If Iíll use 1:1 ratio (1m = 1 ogl unit) then near the far plane my fighter is still visible (meaning its dimensions in pixels, its not a dot). Bigger objects will be cut by the far plane, generating ugly results.

My question is: how do you visualize the real world objects. How do you store your object. I would like to know you solutions from your experiences.

I may guess that objects should be stored in their original sizes (for collision detection etc.) and use a sort of scale for rendering. Something like this:

Ö
glPushMatrix();
glScalef(Ö);
[Draw Fighter];
glPopMatrix();

Am I right?

Thank you in advance,
Alexandru (a.k.a. Maverick)

JustHanging
01-14-2003, 01:45 AM
Hi,

I use the scale 1m = 1 opengl unit for all objects. If some object isn't modelled in this scale, I scale it at load time. Note that if you use glScalef with opengl lighting, you will have to enable GL_NORMALIZE, which may cause a slowdown.

As for your far clipping plane issue, it's perfectly ok to use far clipping plane further than that. What counts is the far/near ratio, so if you want to set your far plane to 5000, just move near to 0.5.

-Ilkka

Maverick_75
01-14-2003, 03:11 AM
Thanx for the hint.

Suppose you have a mountain about 5000m heigh. What whould be your glPerspective parameters?

BTW what FOV do you often use (for 1m = 1ogl unit)?

Regards,
Alexandru

JustHanging
01-14-2003, 03:21 AM
Usually I use a 60 degree fov. A nice way for you to get decent near/far values could be to first push the far plane so far back that you can see all you want to, and then push near far enough to get rid of precision problems. Actually drawing the terrain that far in realtime is another thing, you may need to look into some level of detail algorithms.

On a sidenote, are you sure your models are in a right scale? Is a fighter really 10m high?

-Ilkka

Maverick_75
01-14-2003, 04:41 AM
Thanx for advice. I've looked into terrain LOD algorithms.

The scale is ok, it's a SciFi fighter http://www.opengl.org/discussion_boards/ubb/smile.gif

Just to clarify about far/near ratio. What should I target for, in order to have some good results.

Alexandru

JustHanging
01-15-2003, 04:57 AM
I'm not sure about the optimal ratio, I think it's around 1000, but for your situation that seems too low. 5000 could be ok too, it depends on the scene somewhat.

-Ilkka