Revision: 17794 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17794 Author: ben2610 Date: 2008-12-12 00:02:33 +0100 (Fri, 12 Dec 2008)
Log Message: ----------- VideoTexture.ImageMirror: if the mirror is horizontal in mesh coord, take the Y axis as the up direction for the UV map. If the mirror is not perfectly vertical(horizontal), the projection of the Z(Y) axis on the mirror plane is the mirror Up direction. Modified Paths: -------------- trunk/blender/source/gameengine/VideoTexture/ImageRender.cpp Modified: trunk/blender/source/gameengine/VideoTexture/ImageRender.cpp =================================================================== --- trunk/blender/source/gameengine/VideoTexture/ImageRender.cpp 2008-12-11 22:30:24 UTC (rev 17793) +++ trunk/blender/source/gameengine/VideoTexture/ImageRender.cpp 2008-12-11 23:02:33 UTC (rev 17794) @@ -539,8 +539,9 @@ float mirrorArea = 0.f; float mirrorNormal[3] = {0.f, 0.f, 0.f}; float mirrorUp[3]; - float dist, vec[3]; + float dist, vec[3], axis[3]; float zaxis[3] = {0.f, 0.f, 1.f}; + float yaxis[3] = {0.f, 1.f, 0.f}; float mirrorMat[3][3]; float left, right, top, bottom, back; @@ -602,23 +603,36 @@ THRWEXCP(MirrorNormalInvalid, S_OK); } // the mirror plane has an equation of the type ax+by+cz = d where (a,b,c) is the normal vector - // mirror up direction is the projection of Z on the plane - // scalar product between normal and Z axis - dist = Inpf(mirrorNormal, zaxis); - if (dist < FLT_EPSILON) + // if the mirror is more vertical then horizontal, the Z axis is the up direction. + // otherwise the Y axis is the up direction. + // If the mirror is not perfectly vertical(horizontal), the Z(Y) axis projection on the mirror + // plan by the normal will be the up direction. + if (fabs(mirrorNormal[2]) > fabs(mirrorNormal[1]) && + fabs(mirrorNormal[2]) > fabs(mirrorNormal[0])) + { + // the mirror is more horizontal than vertical + VecCopyf(axis, yaxis); + } + else + { + // the mirror is more vertical than horizontal + VecCopyf(axis, zaxis); + } + dist = Inpf(mirrorNormal, axis); + if (fabs(dist) < FLT_EPSILON) { - // the mirror is already vertical - VecCopyf(mirrorUp, zaxis); + // the mirror is already fully aligned with up axis + VecCopyf(mirrorUp, axis); } else { - // projection of Z to normal + // projection of axis to mirror plane through normal VecCopyf(vec, mirrorNormal); VecMulf(vec, dist); - VecSubf(mirrorUp, zaxis, mirrorNormal); + VecSubf(mirrorUp, axis, vec); if (Normalize(mirrorUp) == 0.f) { - // mirror is horizontal + // should not happen THRWEXCP(MirrorHorizontal, S_OK); return; } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs