GuyGizmo
10-19-2003, 09:40 AM
I've been working on a 3D game written in OpenGL for a while, and I'm nearly finished with it, though there is one major issue I need to resolve. Firstly, the game involves a stupid looking guy on a Unicycle riding around on randomly generated terrain. This is all fine and good, but I also need to include randomly generated endless pits in the terrain.
The terrain is simply an N x N grid of points spanning the XZ plane, with each point having its own Y-coordinate (simple enough). The question is, how do I get OpenGL to quickly and easily render endless pits in this? An endless pit (in the context of the game) is defined by a point anywhere on the grid (X,Z), an orientation (rotation around the Y-axis), and a size Dx,Dz. The pit sort of "lies" across the terrain as though it were a rectangular blanket, except make that blanket an ACME-style rectangular portable hole. Is there any convenient way to get the terrain in the pit not to be drawn?
What I've tried/considered trying:
- Using the stencil buffer, draw the pit on the screen only in the part where it meets the surface of the terrain. This more or less failed miserably, because it's way too processor intensive (especially when there are lots of pits), and all sorts of other depth-sorting errors present themselves as well.
- Actually splicing the polygons over the terrain so that the part covering the pit isn't there. This is monumentally difficult to do, since it gets really nasty and complicated when you have overlapping pits and whatnot, involving oodles of non-convex polygons and clipping.
What would be ideal is if there was some way to define a volume in space and just tell OpenGL not to draw anything in there, though I have a feeling that such a thing wouldn't be too easy on the processor either. Can anyone suggest something that might do the trick?
The terrain is simply an N x N grid of points spanning the XZ plane, with each point having its own Y-coordinate (simple enough). The question is, how do I get OpenGL to quickly and easily render endless pits in this? An endless pit (in the context of the game) is defined by a point anywhere on the grid (X,Z), an orientation (rotation around the Y-axis), and a size Dx,Dz. The pit sort of "lies" across the terrain as though it were a rectangular blanket, except make that blanket an ACME-style rectangular portable hole. Is there any convenient way to get the terrain in the pit not to be drawn?
What I've tried/considered trying:
- Using the stencil buffer, draw the pit on the screen only in the part where it meets the surface of the terrain. This more or less failed miserably, because it's way too processor intensive (especially when there are lots of pits), and all sorts of other depth-sorting errors present themselves as well.
- Actually splicing the polygons over the terrain so that the part covering the pit isn't there. This is monumentally difficult to do, since it gets really nasty and complicated when you have overlapping pits and whatnot, involving oodles of non-convex polygons and clipping.
What would be ideal is if there was some way to define a volume in space and just tell OpenGL not to draw anything in there, though I have a feeling that such a thing wouldn't be too easy on the processor either. Can anyone suggest something that might do the trick?