View Full Version : Mirrors in 3-d models
10-10-2000, 11:30 AM
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.
10-10-2000, 12:56 PM
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 :
For rendering objects in what I call "Hidden Lines" mode, use :
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).
10-11-2000, 12:23 PM
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.
10-11-2000, 09:20 PM
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...
10-12-2000, 01:52 AM
how are you calculation the transformation
matrix for the reflection?
10-15-2000, 10:18 PM
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.
10-16-2000, 07:00 AM
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!
10-16-2000, 08:04 AM
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.
10-17-2000, 06:14 AM
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.
10-17-2000, 06:37 AM
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.
10-18-2000, 07:52 AM
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 ...
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.