Example #1
0
        public            PolygonInfo[] SplitToSquares()
        {
            Vector3 cubeForward = rotation * Vector3.forward;
            Vector3 cubeUp      = rotation * Vector3.up;
            Vector3 cubeRight   = rotation * Vector3.right;

            Vector3 forwardExtent = cubeForward * size.z / 2;
            Vector3 rightExtent   = cubeRight * size.x / 2;
            Vector3 upExtent      = cubeUp * size.y / 2;

            PolygonInfo frontFace  = CalculateFace(position, forwardExtent, rightExtent, upExtent);
            PolygonInfo backFace   = CalculateFace(position, -forwardExtent, -rightExtent, upExtent);
            PolygonInfo leftFace   = CalculateFace(position, -rightExtent, forwardExtent, upExtent);
            PolygonInfo rightFace  = CalculateFace(position, rightExtent, -forwardExtent, upExtent);
            PolygonInfo topFace    = CalculateFace(position, upExtent, rightExtent, -forwardExtent);
            PolygonInfo bottomFace = CalculateFace(position, -upExtent, rightExtent, forwardExtent);

            return(new PolygonInfo[] { frontFace, backFace, leftFace, rightFace, topFace, bottomFace });
        }