in ReplicaSDK/include/MirrorRenderer.h [93:120]
void CaptureReflection(
const MirrorSurface& mirror,
PTexMesh& ptexMesh,
const pangolin::OpenGlRenderState& cam,
GLenum frontFace,
const bool drawDepth=false,
const float depthScale=1.0f) {
if (!InView(mirror, cam))
return;
// render reflections to texture
pangolin::OpenGlRenderState reflectCam(
cam.GetProjectionMatrix(), cam.GetModelViewMatrix() * GetReflectionMatrix(mirror));
// Check which side of the surface we're on to render the right clip plane
const Eigen::Vector4d t =
((Eigen::Matrix4d)cam.GetModelViewMatrix().Inverse()).topRightCorner(4, 1);
const double signFlip = mirror.Equation().cast<double>().dot(t) > 0 ? 1.0 : -1.0;
Eigen::Vector4f plane = mirror.Equation();
plane(3) -= surfaceOffset;
BeginDrawScene(frontFace);
if (drawDepth)
ptexMesh.RenderDepth(reflectCam, depthScale, signFlip * plane);
else
ptexMesh.Render(reflectCam, signFlip * plane);
EndDrawScene(frontFace);
}