コード例 #1
0
 public int FindContacts(Primitive primOne, Primitive primTwo)
 {
     CollisionData data = new CollisionData();
       data.contactsLeft = 1;
       int numContacts = FindContacts(primOne, primTwo, data);
       return numContacts;
 }
コード例 #2
0
        public static void Render(Primitive prim, RenderContext context, Color color)
        {
            if (prim.PrimType == Forever.Physics.Collide.CollideType.Sphere)
              {
            Sphere sphere = (Sphere)prim;
            BoundingSphere bs = new BoundingSphere(prim.Body.Position, sphere.Radius);
            BoundingSphereRenderer.Render(bs, context, color);
              }
              else if (prim.PrimType == Forever.Physics.Collide.CollideType.Box)
              {
            Box b = (Box)prim;
            Matrix world = prim.Body.World;
            BoundingBoxRenderer.Render(
              BoundingBox.CreateFromPoints(b.LocalVerts()),
              context.GraphicsDevice,
              world * b.OffsetMatrix,
              context.Camera.View,
              context.Camera.Projection,
              color
            );
              }else if(prim.PrimType == Forever.Physics.Collide.CollideType.Plane){

              Render((Forever.Physics.Collide.Plane)prim, context, color);
              }
              else
              {
            throw new Exception("I don't know how to draw that!");
              }
        }
コード例 #3
0
 public bool Intersecting(Primitive primOne, Primitive primTwo)
 {
     return FindContacts(primOne, primTwo) > 0;
 }
コード例 #4
0
 public int FindContacts(Primitive primOne, Primitive primTwo, CollisionData data)
 {
     return IntersectionTests.primAndPrim(primOne, primTwo, data);
 }
コード例 #5
0
 public void UnloadContent()
 {
     prim = null;
 }
コード例 #6
0
        //dispatch
        public static int primAndPrim(Primitive one, Primitive two, CollisionData data)
        {
            if (one.PrimType == CollideType.Sphere
             && two.PrimType == CollideType.Sphere)
            {
                return sphereAndSphere((Sphere)one, (Sphere)two, data);
            }

            if (one.PrimType == CollideType.Sphere
             && two.PrimType == CollideType.Plane)
            {
                return sphereAndHalfSpace((Sphere)one, (Plane)two, data);
            }

            if (one.PrimType == CollideType.Plane
             && two.PrimType == CollideType.Sphere)
            {
                return sphereAndHalfSpace((Sphere)two, (Plane)one, data);
            }

            if (one.PrimType == CollideType.Box
             && two.PrimType == CollideType.Sphere)
            {
                return boxAndSphere((Box)one, (Sphere)two, data);
            }

            if (one.PrimType == CollideType.Sphere
             && two.PrimType == CollideType.Box)
            {
                return boxAndSphere((Box)two, (Sphere)one, data);
            }

            if (one.PrimType == CollideType.Box
             && two.PrimType == CollideType.Plane)
            {
                return boxAndPlane((Box)one, (Plane)two, data);
            }

            if (one.PrimType == CollideType.Plane
             && two.PrimType == CollideType.Box)
            {
                return boxAndPlane((Box)two, (Plane)one, data);
            }

            if (one.PrimType == CollideType.Box && two.PrimType == CollideType.Box)
            {
                return boxAndBox((Box)one, (Box)two, data);
            }

            throw new Exception("I don't know wtf that is!");
        }