   Mirror Cameras
  I am trying to setup mirrors in my engine, but am having trouble with generating the virtual camera.  I have looked at the Virtual Camera Position article, but it hasn't been much help.  I understand the concept, but it seems to limit the mirrors to certain planes?I have a general setup where a mirror can be on any plane, but can't find a single solution when rendering the mirror view.  I either have it work for one plane but not another, or work for another but not the first.  Here's my setup:CameraDistance = MirrorPlane.Distance(CameraOrigin)MirrorCameraOrigin = CameraOrigin - (MirrorPlane.Normal * CameraDistance * 2)ReflectMatrix = MATRIX::ReflectPlane(MirrorPlane)MirrorCameraOrientation.rz = ReflectMatrix.Rotate(CameraOrientation.rz)MirrorCameraOrientation.ry = ReflectMatrix.Rotate(CameraOrientation.ry)MirrorCameraOrientation.rz = ReflectMatrix.Rotate(CameraOrientation.rz)The last part is the part that I know doesn't work.  I know my mirror camera origin is correct, it's just the orientation that never seems to be right.  If it works for one plane, it's flipped on the other (so I have to flip the coordinates in the pixel shader when I read it for it to look right when rendering), and vice versa.  Either I have to find out how to correctly flip it based on the plane (create a formula or function for generically calculating the coordinate adjustments), or I have to find out how to properly handle the orientation for all mirrors, regardless of the direction of the plane.   
  I know there is probably a simple closed form math solution for your problem, but off the top of my head, I would suggest shooting a ray from the camera to the mirror plane, then using that intersection point as the 'lookat' point for the mirror camera. Ray->Plane is very fast, and building a LookAt matrix is quite simple as well.   ;  The problem with that is getting the proper XY orientation of the mirror camera.  I know the origin and Z vector of the camera is correct, but the XY isn't consistent between mirrors (which are all facing different directions).  On one plane, I have to negate the texture coordinates when I read it back, on another I have to leave them alone.  This means that things are getting flipped along the X and/or Y axis when I am calculating the final mirror camera orientation matrix, but not in any consistent manner (I can't just negate the texture coordinates for all, it's a per-mirror basis).   