Tilted Mirror ?

I’m using the Nehe Example 26, can you say, how I can use tiled mirrors and multi-mirrors ?

What if there is a mirror in front of another ?

And how can I rotate a mirror ?

Thanks for your help in advance !

For tilted mirror you can read this file at section 2.

Try to avoid the case where two mirrors are exactly parallel because in real life it generate and infinite recursion of the scene in the mirror. With the above technique, I think you can only draw the first iteration of the recursion in each of the parallel mirror, so it doesn’t look real but it’s better than nothing.

I didn’t find it in this file…
I mean like rotated 23° around the X-axis ore something like that…
That is complicated because of the clipping…

And isn’t there a possibility to draw this recursion (10 mirrors deep for example), can I do that with Raytracking, or is that something else ?

Did you find this in the file?

  It is relatively straight forward to render a scene with reflections
in the floor.  What if the mirror is placed and oriented arbitrarily in
the world?  This complicates the construction of the reflection matrix.
Conceptually the steps to construct this reflection matrix are:

1. The mirror and object in world coordinates

                | <- Mirror     
                |       @
                |       ^Object

2. Transform into mirror space, so the mirror lies in the X-Y plane and passes
   through the origin.  This is the inverse of the mirror's transformation 



3. Now reflect about the Z-axis.  ie scale by x = 1.0, y = 1.0, z = -1.0



4. Finally transform back to the mirrors original position.  This is the 
   mirror's original transformation matrix.

        @       |

The position of the object is now reflected about the plane of the mirror.

        In a more direct form three matrices are needed.

        MirrorT   -   The transformation that maps the mirror into world

        MirrorT'  -  The inverse of MirrorT.  This maps from world space to
                     mirror space.

        ScaleZ    -  A scale matrix with a scale of -1.0 in z.

        reflectionMatrix = MirrorT * ScaleZ * MirrorT'

        (Note: This assumes vertices are represented as column vectors.  If
        the application uses row vectors the order of the matrix multiplies
        will have to be reversed.)

        The reflection matrix can be used in the same manner as the previous

And isn’t there a possibility to draw this recursion (10 mirrors deep for example), can I do that with Raytracking, or is that something else ?

You can limit the recursion 10 mirrors deep for example, but it can hurt a lot the performance of your OpenGL program if complex objects are between the mirrors. In the case of 10 mirror deep, you have to draw each object at least 20 + 1 times with the right transform matrix.

For Raytracking do you mean ray tracing? If you do not need real time rendering, rendering scene with mirror is a lot easier with ray tracing.

what a lovely little article, thanks. Feel very nostalgic now.

Sorry, it still doesn’t work. I used this Thread, because so I don’t have to create a new Thread.

If I use the method of this text, it is not mirrored at the z-axis.
An with my method, it works only with x OR y rotation…
What’s wrong, when I use both at the same time ??

float ObjectRX=2*SpiegelRX;
float ObjectRY=2*SpiegelRY;

float SpiegelMitte[3]={(Xmax-Xmin)/2+Xmin, (Ymax-Ymin)/2+Ymin+yyyyy, (Zmax-Zmin)/2+Zmin+zzzzz};

float KugelMitte[3]={xxx,yyy + height,zzz};

float diff[3];
int i;


GLdouble matrixReverse[16];

int i;


glTranslatef(0.0f, height, 0.0f);
glRotatef(xrot, 1.0f, 0.0f, 0.0f);
glRotatef(yrot, 0.0f, 1.0f, 0.0f);



//My alternative Method:


//Draw mirrored object:


Hope you can help me. :sorrow:
I tried to get that to work, but I always found a position of the mirror where the ball is not correctly reflected…

DarkShadow44, sorry for reading your post late. What algorithm do you use for inverting your matrix?. I will try to make a simple demo program to implement the algorithm and I will post my solution here if it successful.