Esempio n. 1
0
 public PickUpGen(CoreEngine c, Vector3 p, PickUp.PickUpType t)
 {
     core = c;
     pos = p;
     itemType = t;
     held = null;
     genTime = 300;
 }
Esempio n. 2
0
 public void removePickUp()
 {
     if (held != null)
         core.physicsEngine.removeFromCollisionGrid(held);
     held = null;
 }
Esempio n. 3
0
 public void genPickUp(PickUp.PickUpType type)
 {
     held = new PickUp(pos + new Vector3(0, 50, 0), itemType, this);
     core.physicsEngine.updateCollisionCellsFor(held);
 }
Esempio n. 4
0
        public bool collidesWithPickup(Vector3 moverRadius, Vector3 basePoint, Vector3 velocity, PickUp collidable)
        {
            /* we cast a ray from the center of collider to the center of
             * collidable. if the collision time is closer (or sufficiently close)
             * for collidable then we're colliding
             */
            BoundingBox otherbb = ((ICollidable)collidable).getBoundingBox();
            Vector3 otherRadius = (otherbb.Max - otherbb.Min) * 0.5f,
                    otherPos = otherbb.Min + otherRadius;

            //now convert everything otherESpace so that we can cast using BoundingSpheres
            Vector3 basePointInOtherESpace = toESpace(otherRadius, toWorldSpace(moverRadius, basePoint)),
                    otherPointInOtherESPace = toESpace(otherRadius, otherPos);
            Ray r = new Ray(basePointInOtherESpace, Vector3.Normalize(otherPointInOtherESPace - basePointInOtherESpace));
            Nullable<float> dist = r.Intersects(new BoundingSphere(otherPointInOtherESPace, 1));
            if (dist != null) { //i don't even know what dist == null means in this context
                //find the collisionPoint in otherESpace
                Vector3 colPoint = r.Position + dist.Value * r.Direction;
                //convert it back to normal eSpace (of basePoint)
                colPoint = toESpace(moverRadius, toWorldSpace(otherRadius, colPoint));
                float colDist = Vector3.Distance(colPoint, basePoint);
                //if the distance is < 1 + epsilon (the radius of the collider in eSpace) then we've collided
                if (colDist < 1 + 0.5) {
                    float t = colDist / (float)Math.Sqrt(Vector3.Dot(velocity, velocity));
                    return true;
                }
            }
            return false;
        }
Esempio n. 5
0
 public void genPickUp(PickUp.PickUpType type)
 {
     held = new PickUp(pos + new Vector3(0, 50, 0), itemType, this);
     core.physicsEngine.updateCollisionCellsFor(held);
 }