コード例 #1
0
        public override float getSeperatingVelocity(CollisionHandler other)
        {
            float   retVal;
            Vector3 distanceNormal = normal;
            Vector3 velocity       = parent.Velocity - other.parent.Velocity;

            retVal = Vector3.Dot(velocity, distanceNormal);
            return(retVal);
        }
コード例 #2
0
        public override float getSeperatingVelocity(CollisionHandler other)
        {
            float retVal;
            //TODO:: don't recalculate
            Vector3 distanceNormal = getContactNormal(other);
            Vector3 velocity       = parent.Velocity - other.parent.Velocity;

            retVal = Vector3.Dot(velocity, distanceNormal);
            return(retVal);
        }
コード例 #3
0
 public override bool DetectCollsion(CollisionHandler other)
 {
     if (other is SphereCollisionHandler)
     {
         return(detectSphereCollision((SphereCollisionHandler)other));
     }
     else
     {
         return(false);
     }
 }
コード例 #4
0
 public override float getPenDepth(CollisionHandler other)
 {
     if (other is SphereCollisionHandler)
     {
         return(spherePenDepth((SphereCollisionHandler)other));
     }
     if (other is HalfSpaceCollisionHandler)
     {
         return(-other.getPenDepth(this));
     }
     else
     {
         throw new Exception("No collision pen depth calculation for this type exists");
     }
 }
コード例 #5
0
ファイル: ContactResolver.cs プロジェクト: proliver/Engine1
        /// <summary>
        /// updates objA and objB post collision over some time
        /// </summary>
        /// <param name="collisionA"></param>
        /// <param name="collisionB"></param>
        /// <param name="timeStep"></param>
        public static void ResolveContact(CollisionHandler collisionA, CollisionHandler collisionB, GameTime gameTime)
        {
            bool collisionVector = collisionA.DetectCollsion(collisionB);

            if (collisionVector)
            {
                float   seperatingVelocity = collisionA.getSeperatingVelocity(collisionB);
                Vector3 contactNormal      = collisionA.getContactNormal(collisionB);
                float   penetrationDepth   = collisionA.getPenDepth(collisionB);

                collisionA.updatePhysics(gameTime, contactNormal, -seperatingVelocity,
                                         penetrationDepth, collisionB.parent.mass);
                collisionB.updatePhysics(gameTime, -contactNormal, -seperatingVelocity,
                                         penetrationDepth, collisionA.parent.mass);
            }
        }
コード例 #6
0
 public override float getPenDepth(CollisionHandler other)
 {
     if (other is SphereCollisionHandler)
     {
         float distance = Vector3.Dot(other.Position, normal) - Vector3.Dot(Position, normal);
         SphereCollisionHandler pointerObject = (SphereCollisionHandler)other;
         return(distance - pointerObject.Radius);
     }
     if (other is HalfSpaceCollisionHandler)
     {
         throw new NotImplementedException();
     }
     else
     {
         throw new Exception("no pen depth test of this type");
     }
 }
コード例 #7
0
 public override Vector3 getContactNormal(CollisionHandler other)
 {
     if (other is SphereCollisionHandler)
     {
         Vector3 cNorm;
         cNorm = parent.Position - other.parent.Position;
         cNorm.Normalize();
         return(cNorm);
     }
     if (other is HalfSpaceCollisionHandler)
     {
         return(other.getContactNormal(this));
     }
     else
     {
         throw new Exception("No collision handler for this type exists");
     }
 }
コード例 #8
0
 public override bool DetectCollsion(CollisionHandler that)
 {
     if (that is SphereCollisionHandler)
     {
         if (checkSphereCollision((SphereCollisionHandler)that))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     if (that is HalfSpaceCollisionHandler)
     {
         return(that.DetectCollsion(this));
     }
     throw new ArgumentException("Spheres are not able to detect collision with this handler");
 }
コード例 #9
0
 public override Vector3 getContactNormal(CollisionHandler other)
 {
     return(normal);
 }
コード例 #10
0
ファイル: CollisionHandler.cs プロジェクト: proliver/Engine1
 public abstract float getSeperatingVelocity(CollisionHandler other);
コード例 #11
0
ファイル: CollisionHandler.cs プロジェクト: proliver/Engine1
 public abstract float getPenDepth(CollisionHandler other);
コード例 #12
0
ファイル: CollisionHandler.cs プロジェクト: proliver/Engine1
 public abstract Vector3 getContactNormal(CollisionHandler other);
コード例 #13
0
ファイル: CollisionHandler.cs プロジェクト: proliver/Engine1
        //TODO:: implement this. remove from collision objects
        //public virtual void destroy();

        public abstract bool DetectCollsion(CollisionHandler other);