Pathfinding.GridGraph.GetBoundsMinMax C# (CSharp) Method

GetBoundsMinMax() public method

public GetBoundsMinMax ( Bounds b, Matrix4x4 matrix, Vector3 &min, Vector3 &max ) : void
b UnityEngine.Bounds
matrix UnityEngine.Matrix4x4
min UnityEngine.Vector3
max UnityEngine.Vector3
return void
        public void GetBoundsMinMax(Bounds b, Matrix4x4 matrix, out Vector3 min, out Vector3 max)
        {
            Vector3[] p = new Vector3[8];

            p[0] = matrix.MultiplyPoint3x4 (b.center + new Vector3 ( b.extents.x, b.extents.y, b.extents.z));
            p[1] = matrix.MultiplyPoint3x4 (b.center + new Vector3 ( b.extents.x, b.extents.y,-b.extents.z));
            p[2] = matrix.MultiplyPoint3x4 (b.center + new Vector3 ( b.extents.x,-b.extents.y, b.extents.z));
            p[3] = matrix.MultiplyPoint3x4 (b.center + new Vector3 ( b.extents.x,-b.extents.y,-b.extents.z));
            p[4] = matrix.MultiplyPoint3x4 (b.center + new Vector3 (-b.extents.x, b.extents.y, b.extents.z));
            p[5] = matrix.MultiplyPoint3x4 (b.center + new Vector3 (-b.extents.x, b.extents.y,-b.extents.z));
            p[6] = matrix.MultiplyPoint3x4 (b.center + new Vector3 (-b.extents.x,-b.extents.y, b.extents.z));
            p[7] = matrix.MultiplyPoint3x4 (b.center + new Vector3 (-b.extents.x,-b.extents.y,-b.extents.z));

            min = p[0];
            max = p[0];
            for (int i=1;i<8;i++) {
                min = Vector3.Min (min,p[i]);
                max = Vector3.Max (max,p[i]);
            }
        }

Usage Example

Ejemplo n.º 1
0
    public static IntRect getBoundsRect(Bounds b, GridGraph gg)
    {
        Vector3 min, max;
        gg.GetBoundsMinMax (b,gg.inverseMatrix,out min, out max);

        int minX = Mathf.RoundToInt (min.x-0.5F);
        int maxX = Mathf.RoundToInt (max.x-0.5F);

        int minZ = Mathf.RoundToInt (min.z-0.5F);
        int maxZ = Mathf.RoundToInt (max.z-0.5F);

        IntRect originalRect = new IntRect(minX,minZ,maxX,maxZ);

        IntRect gridRect = new IntRect(0,0,gg.width -1, gg.depth -1);
        IntRect clampedRect = IntRect.Intersection (originalRect, gridRect);

        return clampedRect;
    }
All Usage Examples Of Pathfinding.GridGraph::GetBoundsMinMax