PDA

View Full Version : coplanar geometry



cru
11-20-2004, 04:54 AM
A little background first. I have an app that draws hundreds of thousands of polgyons to screen. The majority of this geometry is stored on disk and while a lesser amount is stored in memory. I have mechanisms in place to load geometry from disk and into memory as needed.

The amount of geometry is rather large. Some sets run into hundreds of megs of bytes. One interesting bit is all of the geometry is co-planar, that is all the geometry has a z coordinate that is set to 0.

The geometry is drawn using simple glDrawArrays calls.

OK, here's my question. Is there a way to somehow eliminate the Z coordinate from my geometry sets yet still have all the geometry drawn on Z=0 plane? That is everytime I send my geometry to the hardware, it 'knows' to use Z=0 for my Z coordinate?

If I could do that I would cut down memory usage bigtime!

halo
11-20-2004, 05:52 AM
Can't you just set the transform matrix and then use glvertex2f()? I am not sure if this is correct, but it seems like it would work.

Of course, my guess is it would be faster to draw all those brushes in one or a few passes, rather than transforming the matrix for each face of each object, and rendering each face separately.

Usually when people have that much geometry rendering in real-time, they use static meshes that share one set of vertices.

jwatte
11-20-2004, 08:37 AM
If you look at "vertex specification" in the OpenGL standard, you will see the function glVertex2fv(). You'll also notice a "count" argument to glVertexPointer(). That's hardly "advanced" usage of the API, though...

cru
11-20-2004, 10:14 AM
Excuse me, I made one mistake that changes things slightly. In this particular app it's not the Z coordinate that's 0, it's the Y. Y is always 0.

I understand that when glVertex2f(...) is called, the Z coordinate is assumed to be 0, but what I want to do is this:

I have a coordinate that is x,y,z where x = 1, and z = 2. Y is always 0, not Z (at least not in this app).

Maybe through matrix manipulation the second coordinate of a glVertex2f call can be made to apply to the Z axis?

M/\dm/\n
11-20-2004, 12:14 PM
Draw on x0z plane & modify glulookat. Might be implemented differently, though.

rgpc
11-20-2004, 01:50 PM
I think what M/\dm/\n is trying to say is that you could draw your geometry using X & Y and add an extra rotation into your Modelview matrix that would rotate the geometry into X & Z...

cru
11-20-2004, 02:48 PM
Yeah, I believe that's what he's saying. Anyway, I've already tested what you guys proposed and it does what I need. I should be able to reduce my memory requirement by 1/3.

I've thought about re-writing that part of the code to eliminate the Z coordinate for months now. I should've done this a long time ago.