PDA

View Full Version : depth perception?



Dogcow
10-24-2002, 08:11 AM
I'm attempting to make a floor for my world, and as the floor (simply a square face) gets further away, one would assume that the sides would draw closer to each other. However, the face simply flattens out. How do I get it to accurately reflect depth? Pictures included in case I'm not making myself clear...

pict1 (http://theunderground.eon.com.au/code/start.pdf) - overhead view
pict2 (http://theunderground.eon.com.au/code/second.pdf) - camera raised up and moved back

-Dogcow "moof!"
Visit The Underground (http://theunderground.eon.com.au)

nexusone
10-24-2002, 08:22 AM
Use gluPerspective( view_angle, hight/width ratio, near, far )
Note near/far must be positive, near > 0.

This will project depth, example even though the object is square, closer side will be larger then far side of square..



Originally posted by Dogcow:
I'm attempting to make a floor for my world, and as the floor (simply a square face) gets further away, one would assume that the sides would draw closer to each other. However, the face simply flattens out. How do I get it to accurately reflect depth? Pictures included in case I'm not making myself clear...

pict1 (http://theunderground.eon.com.au/code/start.pdf) - overhead view
pict2 (http://theunderground.eon.com.au/code/second.pdf) - camera raised up and moved back

-Dogcow "moof!"
Visit The Underground (http://theunderground.eon.com.au)

Dogcow
10-24-2002, 09:27 AM
So would I use that instead of glOrtho or with it somehow?

Thanks,
-Dogcow "moof!"
Visit The Underground (http://theunderground.eon.com.au)

nexusone
10-24-2002, 09:35 AM
Yes, you can use it in place of glOrtho.

But also you can draw using both, example would be drawing bitmaps which need no depth in ortho mode, then switch to perspective to draw 3D objects.

See my examples on my website...
http://www.angelfire.lycos.com/linux/nexusone

Look at GLclock, comes with source code.


Originally posted by Dogcow:
So would I use that instead of glOrtho or with it somehow?

Thanks,
-Dogcow "moof!"
Visit The Underground (http://theunderground.eon.com.au)

Dogcow
10-26-2002, 11:57 AM
I tried numerous gluPerspective settings and none of them look any different.

The first, gluPerspective(45,1,-10,10); resulted in this pict (http://theunderground.eon.com.au/code/first.pdf) .

The second, gluPerspective(85,9,-100,100); resulted in this pict (http://theunderground.eon.com.au/code/second.pdf) .

Why don't these look any different?

-Dogcow "moof!"
Visit The Underground (http://theunderground.eon.com.au)

Dogcow
10-26-2002, 12:05 PM
If this helps more, here's the dimensions of the only object in my world:

glVertex3f(-10.0f,0.0f,10.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(10.0f,0.0f,10.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(10.0f,0.0f,-10.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(-10.0f,0.0f,-10.0f);

My program starts out looking at:

gluLookAt(0.0,5.0,-5.0,0.0,0.0,0.0,0.0,0.0,1.0);

-Dogcow "moof!"
Visit The Underground (http://theunderground.eon.com.au)

Bob
10-26-2002, 12:57 PM
The near clip plane must not be less than or equal to zero.

Dogcow
10-26-2002, 02:06 PM
Hm, I changed it to a positive number and now can't get anything to show up... Any recommendations on some values to put to get it started?

Thanks,
-Dogcow "moof!"
Visit The Underground (http://theunderground.eon.com.au)

Bob
10-26-2002, 03:58 PM
The values depends on the scale of your scene. But you can always start with some absurd values, like set near to 0.0001 and far to 1000000. It will kill the depth buffer for sure, but you can change the values to fogure out what's best for you.