Mirror the Camera or Matrix

Started by
4 comments, last by tgraupmann 18 years, 11 months ago
hi im using render to texture to do a kind of mirror , and yes i have considered the stencil buffer but it doesnt work when mirrors reflect onto each other(Especialy if they reflect infinitely) i want to know i have the standard camera Pos[3],View[3],Up[3] how would i go about mirroring it over a plane consider that i have the Plane Equation,Plane Normal,1 point on the polygon. I also may need to mirror the matrix which i will get from opengl. Thanks
----------------------------

http://djoubert.co.uk
Advertisement
Excuse me if I'm wrong, but can't you just use glScalef with something like:

glScalef(1.0, -1.0, 1.0, 1.0);

I haven't touched OpenGL in awhile, but something like that should cause it to mirror image the scene.
Quote:Original post by Tyderium
Excuse me if I'm wrong, but can't you just use glScalef with something like:

glScalef(1.0, -1.0, 1.0, 1.0);

I haven't touched OpenGL in awhile, but something like that should cause it to mirror image the scene.


its glScalef(1.0, -1.0, 1.0); (put the negative on whatever axis you want inverted of course) but yeah, that should mirror the screen.
- relpats_eht
Provided that 1. Your Mirror is placed at the Origin on the axis your mirroring
Provided that 2. Your mirror is axis aligned

Which neither are.........


So i considered scaling on the normal of the polygon but that doesnt make sense
ie you cant scale 0,1,0.

Perhaps you dont understand i need to mirror the camera not the world.
for 2 reasons.

I use bsp trees and frustum culling to determing my viewing polygons and if i just mirror(scale) the world then i will be viewing the wrong polygons and from behind anyways(since scaling also scales the normals)

Thanks anyways
----------------------------

http://djoubert.co.uk
You could mirror each of camera base vetors (drections, not points) over the plane and create a new camera matrix. Or directly multiply view matrix by mirror matrix. Google should tell you how to construct a mirroring matrix from given plane.
You should never let your fears become the boundaries of your dreams.
You could use a separate camera for the mirror, render the scene to a texture and then display the texture on a quad in your scene.

I know it's a poor man's solution. I have an example and source [here] with a [avi].

The example is a poor man's poor boy's solution. Because I just render the screen to a texture and use that as my mirror. It causes a visual distortion which was the effect I was looking for.
*News tagenigma.com is my new domain.

This topic is closed to new replies.

Advertisement