示例#1
0
 public bool IsOverlap(BoundBox bb)
 {
     v0 = (this.Vertex1.Position - bb.Center);
     v1 = (this.Vertex2.Position - bb.Center);
     v2 = (this.Vertex3.Position - bb.Center);
     e0 = (this.Vertex2.Position - this.Vertex1.Position);
     e1 = (this.Vertex3.Position - this.Vertex2.Position);
     e2 = (this.Vertex1.Position - this.Vertex3.Position);
     //e0 = this.Edge1;
     //e1 = this.Edge3;
     //e2 = this.Edge2;
     float fex = Math.Abs(e0.X);
     float fey = Math.Abs(e0.Y);
     float fez = Math.Abs(e0.Z);
     if (!AXISTEST_X01(e0.Z, e0.Y, fez, fey, bb.HalfVector)) {
         return false;
     }
     if (!AXISTEST_Y02(e0.Z, e0.X, fez, fex, bb.HalfVector)) {
         return false;
     }
     if (!AXISTEST_Z12(e0.Y, e0.X, fey, fex, bb.HalfVector)) {
         return false;
     }
     fex = Math.Abs(e1.X);
     fey = Math.Abs(e1.Y);
     fez = Math.Abs(e1.Z);
     if (!AXISTEST_X01(e1.Z, e1.Y, fez, fey, bb.HalfVector)) {
         return false;
     }
     if (!AXISTEST_Y02(e1.Z, e1.X, fez, fex, bb.HalfVector)) {
         return false;
     }
     if (!AXISTEST_Z0(e1.Y, e1.X, fey, fex, bb.HalfVector)) {
         return false;
     }
     fex = Math.Abs(e2.X);
     fey = Math.Abs(e2.Y);
     fez = Math.Abs(e2.Z);
     if (!AXISTEST_X2(e2.Z, e2.Y, fez, fey, bb.HalfVector)) {
         return false;
     }
     if (!AXISTEST_Y1(e2.Z, e2.X, fez, fex, bb.HalfVector)) {
         return false;
     }
     if (!AXISTEST_Z12(e2.Y, e2.X, fey, fex, bb.HalfVector)) {
         return false;
     }
     /* test in X-direction */
     FindMinMax(v0.X, v1.X, v2.X);
     if (min > bb.HalfVector.X || max < -bb.HalfVector.X) {
         return false;
     }
     /* test in Y-direction */
     FindMinMax(v0.Y, v1.Y, v2.Y);
     if (min > bb.HalfVector.Y || max < -bb.HalfVector.Y) {
         return false;
     }
     /* test in Z-direction */
     FindMinMax(v0.Z, v1.Z, v2.Z);
     if (min > bb.HalfVector.Z || max < -bb.HalfVector.Z) {
         return false;
     }
     /* test if the box intersects the plane of the triangle */
     //normal = (e0 ^ e1);
     float d = -this.Normal * v0;
     return PlaneBoxOverlap(this.Normal, bb.HalfVector, d);
 }
示例#2
0
 public override bool IsOverlap(BoundBox boundBox)
 {
     throw new NotImplementedException();
 }
示例#3
0
 public override bool IsOverlap(BoundBox boundBox)
 {
     throw new NotImplementedException();
 }
示例#4
0
 /// <summary>
 /// Verify if this primitive is inside in a bound box. Used in
 /// Octree for accerelation <see cref="Octree{T}<T>"/>
 /// </summary>
 /// <param name="boundBox">BoundBox for inside test</param>
 /// <returns>if inside of a box.</returns>
 public abstract bool IsOverlap(BoundBox boundBox);
示例#5
0
 /// <summary>
 /// Verify if this primitive is inside in a bound box. Used in
 /// Octree for accerelation <see cref="Octree{T}<T>"/>
 /// </summary>
 /// <param name="boundBox">BoundBox for inside test</param>
 /// <returns>if inside of a box.</returns>
 public abstract bool IsOverlap(BoundBox boundBox);
示例#6
0
        public override bool IsOverlap(BoundBox bb)
        {
            v0 = (this.Vertex1 - bb.Center);
            v1 = (this.Vertex2 - bb.Center);
            v2 = (this.Vertex3 - bb.Center);
            //e0 = (this.Vertex2 - this.Vertex1);
            //e1 = (this.Vertex3 - this.Vertex2);
            //e2 = (this.Vertex1 - this.Vertex3);
            e0 = this.Edge1;
            e1 = this.Edge3;
            e2 = this.Edge2;
            float fex = Math.Abs(e0.X);
            float fey = Math.Abs(e0.Y);
            float fez = Math.Abs(e0.Z);

            if (!AXISTEST_X01(e0.Z, e0.Y, fez, fey, bb.HalfVector))
            {
                return(false);
            }
            if (!AXISTEST_Y02(e0.Z, e0.X, fez, fex, bb.HalfVector))
            {
                return(false);
            }
            if (!AXISTEST_Z12(e0.Y, e0.X, fey, fex, bb.HalfVector))
            {
                return(false);
            }
            fex = Math.Abs(e1.X);
            fey = Math.Abs(e1.Y);
            fez = Math.Abs(e1.Z);
            if (!AXISTEST_X01(e1.Z, e1.Y, fez, fey, bb.HalfVector))
            {
                return(false);
            }
            if (!AXISTEST_Y02(e1.Z, e1.X, fez, fex, bb.HalfVector))
            {
                return(false);
            }
            if (!AXISTEST_Z0(e1.Y, e1.X, fey, fex, bb.HalfVector))
            {
                return(false);
            }
            fex = Math.Abs(e2.X);
            fey = Math.Abs(e2.Y);
            fez = Math.Abs(e2.Z);
            if (!AXISTEST_X2(e2.Z, e2.Y, fez, fey, bb.HalfVector))
            {
                return(false);
            }
            if (!AXISTEST_Y1(e2.Z, e2.X, fez, fex, bb.HalfVector))
            {
                return(false);
            }
            if (!AXISTEST_Z12(e2.Y, e2.X, fey, fex, bb.HalfVector))
            {
                return(false);
            }
            /* test in X-direction */
            FindMinMax(v0.X, v1.X, v2.X);
            if (min > bb.HalfVector.X || max < -bb.HalfVector.X)
            {
                return(false);
            }
            /* test in Y-direction */
            FindMinMax(v0.Y, v1.Y, v2.Y);
            if (min > bb.HalfVector.Y || max < -bb.HalfVector.Y)
            {
                return(false);
            }
            /* test in Z-direction */
            FindMinMax(v0.Z, v1.Z, v2.Z);
            if (min > bb.HalfVector.Z || max < -bb.HalfVector.Z)
            {
                return(false);
            }
            /* test if the box intersects the plane of the triangle */
            //normal = (e0 ^ e1);
            float d = -this.Normal * v0;

            return(PlaneBoxOverlap(this.Normal, bb.HalfVector, d));
        }