   Planar Mirrors
  Wow, I am trying to wrap my head around the math behind planar reflections, and it's just not clicking.  My setup is a bit different then a lot of people seem to do, so I haven't even been able to just hack code from somewhere else until I understand it.Here's my setup:I have a single call to render the scene (to a target if needed), that takes as input a camera.  The camera just stores it's world space position and rotation, range, FoV, etc.  From all this, I can generate my perspective and view matrices (and ultimately my single transformation matrix).All I want to do now is calculate the reflected camera.  I can't seem to do this!!  I have been looking into the article on VCP, which is the method I like, since it generates the virtual camera that I could use in my current setup.  The problem is that I can't seem to figure out the math part of what he's doing.  Are there any better explanations of the code or other examples of a similar method?   
  I'm sure people know how to calculate the camera?I have a working hack, but I don't like it really 'cause I'm sure it'll fall apart sooner or later.  What I do is calculate the mirrored position (this part is easy, get the distance from the camera to the mirror plane, then go back twice that distance along the planes normal, viola, mirrored position), then calculate it's view from that.My problem is what to calculate as the view for that new camera?  I have some stuff hacked out where I calculate the view target of the camera, then reflect it along the mirror (it works, woohoo), but it's flipped on the X axis in the render to texture.  I easily correct this by flipping the X texture coordinate when I read it, and it mirrors things properly.That means I have it working, but really hacked, I'd prefer a truer solution then this.  I like the mirrors because it only requires two render to surfaces (I have working cubemapped reflections, but that means 6 render to targets!!!), and it looks nice (totally different effect between the two, both rock in realtime), but I'd prefer a true solution.Any thoughts?   ;  I have just added mirror to my engine. I started with the VCP article but I ended up being not too happy with it since it keeps 3 coordinates system ; world, view, camera. This makes the things more complicated than if you keep only 2 worl/view and camera. This means that your camera is at the origin looking at +z or -z depending on your choice of right handed or left handed system.Here is the math I use (right handed system) ;   Matrix4f worldTransform = new Matrix4f(vrState.getModelViewMatrix());   Tuple3f center = new Tuple3f(appearance.getCenter());   worldTransform.transformPoint(center);   Tuple3f normal = new Tuple3f(appearance.getZAxis());   worldTransform.transformVector(normal);   float distance = -Tuple3f.dot(normal, center);   if (distance <= 0) {  return;   }   Tuple3f up = new Tuple3f(appearance.getYAxis());   worldTransform.transformVector(up);   Tuple3f virtualCameraPosition = new Tuple3f(normal);   virtualCameraPosition.scale(-2.0f * distance);   Matrix4f view = new Matrix4f();   view.setLookAtRH(virtualCameraPosition, new Tuple3f(), up);   view.mul(vrState.getActiveView().getViewMatrix());   Tuple3f oc = Tuple3f.newSub(center, virtualCameraPosition);   Tuple3f left = Tuple3f.newCross(up, normal);   float xOffset = -Tuple3f.dot(oc, left);   float yOffset = Tuple3f.dot(oc, up);   float xMin = xOffset - 0.5f * (float) appearance.getWidth();   float xMax = xMin + (float) appearance.getWidth();   float yMin = yOffset - 0.5f * (float) appearance.getHeight();   float yMax = yMin + (float) appearance.getHeight();   Matrix4f projection = new Matrix4f();   projection.setPerspectiveRH(xMin, xMax, yMin, yMax, distance, 1000);;  I think I am doing something similar, but I don't create a seperate perspective matrix like that, I use my standard FOV one.  The difference is that when I read the mirror texture, I still flip the X of the texture coordinate, so that it mirrors properly.  I like this because it fits in a lot smoother into the engine then moving the geometry or having to setup a custom perspective matrix (it's currently setup for simple FoV zooming).I now have it all working, sweetness, now I will have to post some screens on the image of the day section.   