Mirrors in 3-d models

I was curious if there is any info out there about a method for having “mirrors” in your 3-d system. I only want to count one bounce(no multiple bounces between mirrors), but I want to have multiple mirrors in the system. Do I actually have to create new primatives as the reflected images or can I draw the real objects again using some sort of transformation? Also is there a way to draw a polygon filled with black, but has some color edge and still blocks the view of polygons behind it(not just a line loop). Any help would be greatly appreciated.

Brian

Do I actually have to create new primatives as the reflected images or can I draw the real objects again using some sort of transformation?

You do the latter. Just determine the reflection transform and multiply your modelview matrix by it before drawing any reflected geometry. The harder part is determining which polygons are to be reflected. You can either do it brute force and reflect all. Or calculate the reflected frustum and clip against it rather than the view frustum.

Also is there a way to draw a polygon filled with black, but has some color edge and still blocks the view of polygons behind it(not just a line loop)

Sure, draw a black triangle fan surrounded by a colored triangle strip.

HI there !

I just thought I could give some more hints on that…

For reflections (using the stencil buffer), go to :
http://www.nvidia.com/Marketing/Developer/DevRel.nsf/pages/549510738648AA2B8825681E007AE532

For rendering objects in what I call “Hidden Lines” mode, use :

    glPushAttrib(GL_ENABLE_BIT);
    glDisable(GL_LIGHTING);
    glPolygonOffset(1,1);
    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
    glEnable(GL_POLYGON_OFFSET_FILL);
    glMaterialfv(GL_FRONT,GL_AMBIENT,&pDoc->Model->BackGroundColor.Red);
    glMaterialfv(GL_FRONT,GL_DIFFUSE,&pDoc->Model->BackGroundColor.Red);
    glMaterialfv(GL_FRONT,GL_SPECULAR,&pDoc->Model->BackGroundColor.Red);
    glColor3fv(&pDoc->Model->BackGroundColor.Red);
    Objects.Render();
    glPopAttrib();
    glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
    glDisable(GL_POLYGON_OFFSET_FILL);
    Objects.RenderColor();

Where RenderColor renders the colored objects (which means it calls glColor/glMaterial somewhere) and Render simply send the vertices (it musn’t call any glColor/glMaterial as we set everything to black).

Best regards.

Eric

Eric,
thanks for that info. I used that code for black filled polygons and it works great. Is there anything you can do so you don’t have to draw the scene twice? (My understanding of the code is that you are drawing your polys twice)

Also thanks for the stencil buffer paper. I’m fighting through it now.

Brian

He doesn’t draw the whole scene twice. He calls his rendering function twice. But the first time he draws filled, black polygons with a little z-buffer displacement (polygon offset) and the second time he draws the outlines.
So there’s nothing you can optimize here.

Kilam is right : you can not avoid rendering the object twice…

What you can do is create a display list that renders the object without any call to glColor/glMaterial. And call it twice… The thing is, it does not work for objects that use multiple materials/colors nor with objects that use vertex colors… But you can compile the whole thing into one huge display list (that’s what I do)…

There is really no other way to do “hidden lines” mode…

Regards.

Eric

Hi,
how are you calculation the transformation
matrix for the reflection?

Thanks
Dimi

Dimi,
Go to the link that Eric posted in his reply and I believe the reflection matrix info is in the appendix to the article in question.

Brian

I’m trying to understand what you guys are talking about when you talk about the black-filled polygons or “hidden lines”. What are you using this to do? Thanks!

To implement a fast hidden line algorithm, you could use OpenGL. Therefore you draw every face with the background color (lights off!) and the the outlines again in the color of your choice. Then the polygons hide the lines.
Normaly the polygons appear stippled then. Solution: Use glPolygonOffset.

Kilam.

What are you accomplishing when you do this? And what are you trying to accomplish? Stippled? I guess I’m just having trouble understanding why you need to do this for reflections.

Now I understand your problem. This has nothing to do with reflections. Read the first post from BBrown. He had a second question regarding hidden line. That was the answer.

Oh, I see. Thanks!

Keep in mind that if you’re using GL’s back-face culling (glEnable(GL_CULL_FACE)) that pushing your geometry through a reflection matrix will convert front-facing primitives to back-facing ones and vice versa …

/ec