Example #1
0
    public bool Intersects(AABBThreeD aabb)
    {
        var obb = new OBBThreeD();

        obb.SetFrom(aabb);
        return(Intersects(obb, 0));
    }
Example #2
0
    public AABBThreeD MinimalEnclosingAABB()
    {
        AABBThreeD aabb = new AABBThreeD();;

        aabb.SetFrom(this);
        return(aabb);
    }
Example #3
0
 void SetFrom(AABBThreeD aabb)
 {
     pos     = aabb.center;
     r       = aabb.halfSize;
     axis[0] = new Vector3(1, 0, 0);
     axis[1] = new Vector3(0, 1, 0);
     axis[2] = new Vector3(0, 0, 1);
 }
Example #4
0
    //错误
    void AABBTransformAsAABB(AABBThreeD aabb, Matrix4x4 m)
    {
        //Vector3 newCenter = m.MulPos(aabb.CenterPoint());
        // center = m.MultiplyPoint(aabb.CenterPoint());
        Vector3 newDir;
        //Vector3 h = aabb.HalfSize();
        //halfSize
        Vector3 h = halfSize;

        //The following is equal to taking the absolute value of the whole matrix m.
        newDir.x      = MathFunc.ABSDOT3(m.GetRow(0), h);
        newDir.y      = MathFunc.ABSDOT3(m.GetRow(1), h);
        newDir.z      = MathFunc.ABSDOT3(m.GetRow(2), h);
        aabb.minPoint = center - newDir;
        aabb.maxPoint = center + newDir;
    }
Example #5
0
    public bool Intersects(AABBThreeD aabb)
    {
        // If any of the cardinal X,Y,Z axes is a separating axis, then
        // there is no intersection.
        return(minPoint.x < aabb.maxPoint.x &&

               minPoint.y < aabb.maxPoint.y &&

               minPoint.z < aabb.maxPoint.z &&

               aabb.minPoint.x < maxPoint.x &&

               aabb.minPoint.y < maxPoint.y &&

               aabb.minPoint.z < maxPoint.z);
    }
Example #6
0
 public bool Contains(AABBThreeD aabb)
 {
     return(this.Contains(aabb.minPoint) && this.Contains(aabb.maxPoint));
 }
Example #7
0
 void Start()
 {
     data = new AABBThreeD();
 }