PDA

View Full Version : Planes extending towards infinity?



laprej
04-13-2004, 09:52 PM
Hey all,
I imagine this is an extremely stupid question, so I apologize in advance. Anyway, I'm developing a small program that allows the user to drive a car around in a desert. So I draw the plane that represents the desert, but it does have coordinates and is therefore limited. I draw a 20,000 x 20,000 grid, but I would prefer it went out to infinity. Am I missing something basic here?

Mazy
04-13-2004, 11:06 PM
You can just let the plane stand still. If you have a texture or something like that on it, just move the texture via the gl_texture matrix. since the actuall quads never moves you wont ever go to the edge of it.

laprej
04-14-2004, 09:18 AM
I'm not sure if I understand your solution. The plane does stand still, however the car also moves. I keep track of the car's x/z coordinates and then translate based on those. I definitely do eventually hit the end of the plane and then the whole screen is sky blue (my clearing color). I mean, I guess I could enlarge the plane, but that would just eat up more video memory, right? And I'm not sure I want to do that... but if that's really my only option, I'll do it.

Mazy
04-14-2004, 09:27 AM
you just move the plane with the camera, so that the planes position in respect to the camera is the same all the time.

04-14-2004, 10:03 AM
One correction: enlarging the plane won't "eat up more video memory". The image on the screen will still contain the same number of pixels, you're still passing the same number of triangles and you're using the same texture, so don't worry about that.

The reality is that you can't represent an infinitely-large ground. If the ground never changes, as people have said there's no reason why you have to move the quad at all. In fact, without any variation you don't even need to move the car... :)

However, if there's some variation in the environment you'll need to load new terrain blocks as you approach them. Or just not let the car go wherever it wants!

laprej
04-14-2004, 10:04 AM
Oh, I get it now. So all the stuff that shouldn't move (roads, bushes, etc) should be drawn before I move the camera. Then I move the camera, draw the car, and the plane at the same time?

ZbuffeR
04-14-2004, 01:02 PM
The solution mentionned above implies that your ground is completely flat and uniform (no texturing or mountains).

But actually you can draw polygons reaching infinity, thanks to homegeneous coordinates. You know that with glVertex4f you can specify 4 coordinates, x,y,z for 3D position, and w, which is 1 by default. If you set w to 0, this position will be at infinity. Thanks to perspective projection, the infinity is then transformed to a finite 2d position (the horizon in that case). The x,y,z will only define a direction.

It is a little bit more involved, but can be really useful.

BeginOpenGL
04-16-2004, 12:40 PM
With a perpetual terain shouldŽnt there be some kind of LOD (Level of Detail) algorithm? Where is there an OpenGl example of one. Anybody know?

BeginOpenGL

ZbuffeR
04-18-2004, 08:44 AM
Terrain lod is not OpenGL specific.
There are a lot of terrain demos with LOD, google for it ( ROAM, adaptive subdivision, etc).

http://www.vterrain.org/LOD/index.html

BeginOpenGL
04-18-2004, 08:02 PM
ZbuffeR

Hey, thanks for that great link!

BeginOpenGL

plasmonster
04-18-2004, 08:26 PM
Another interesting possibility is to tile the terrain itself by "wrapping" the camera position. Something like this was done in a game called "Star seige" that came out some time ago. Of course, this is tricky to do, as you would need to work out the physics across the boundary, but it is doable.