打开镜像世界
我们在Unity里打开镜像的世界呢,原理很简单,我们再加一个Mirror Camera就可以了,其位置是我们当前Camera相对于镜面的一个镜像的映射(Transform)。
- 镜像矩阵
这个概念比较复杂,记公式就可以了。
有了公式,代码就好写了
public static void CalculateReflectionMatrix(ref Matrix4x4 reflectionMat, Vector4 plane)
{
reflectionMat.m00 = (1F - 2F * plane[0] * plane[0]);
reflectionMat.m01 = (-2F * plane[0] * plane[1]);
reflectionMat.m02 = (-2F * plane[0] * plane[2]);
reflectionMat.m03 = (-2F * plane[0] * plane[3]);
reflectionMat.m10 = (-2F * plane[1] * plane[0]);