Example #1
0
 // Constructor based on hit-collision intersection
 public HitInformation(HitData data, Box hitBox, int collisionId, Box collisionBox)
 {
     this.hitData     = data;
     this.collisionId = collisionId;
     intersection     = new Box(
         FixedVector3.Max(hitBox.pointOne, collisionBox.pointOne),
         FixedVector3.Min(hitBox.pointTwo, collisionBox.pointTwo)
         );
 }
        protected static bool BoxIntersection(PhysicPlaneModel planeModel, FixedVector3 point1, FixedVector3 point2)
        {
            FixedVector3 minPoint = FixedVector3.Min(point1, point2);
            FixedVector3 maxPoint = FixedVector3.Max(point1, point2);

            minPoint -= planeModel.origin;
            maxPoint -= planeModel.origin;
            return(!(
                       minPoint.X > planeModel.maxPos.X ||
                       maxPoint.X < planeModel.minPos.X ||
                       minPoint.Y > planeModel.maxPos.Y ||
                       maxPoint.Y < planeModel.minPos.Y ||
                       minPoint.Z > planeModel.maxPos.Z ||
                       maxPoint.Z < planeModel.minPos.Z
                       ));
        }
        public void ComputeBoundingBox()
        {
            if (offsets == null || offsets.Count < 2)
            {
                return;
            }
            minPos = FixedVector3.Zero;
            maxPos = FixedVector3.Zero;
            FixedVector3 point;

            for (int i = 0; i < offsets.Count; ++i)
            {
                point  = offsets[i];
                minPos = FixedVector3.Min(minPos, point);
                maxPos = FixedVector3.Max(maxPos, point);
            }
            FixedVector3 tolerance = new FixedVector3(0.01f, 0.01f, 0.01f);

            minPos -= tolerance;
            maxPos += tolerance;
        }