Beispiel #1
0
 public Cable(Collidable one, Collidable two, float max, float restitution)
 {
     body[0] = one;
     body[1] = two;
     maxLength = max;
     this.restitution = restitution;
 }
Beispiel #2
0
 public BVHNode(BVHNode Parent, Collidable Body)
 {
     Children[0] = null;
     Children[1] = null;
     this.Body = Body;
     this.Volume = Body.GetBoundingSphere();
     this.Parent = Parent;
 }
Beispiel #3
0
 public Contact(Collidable firstBody, Collidable secondBody)
 {
     this.body[0] = firstBody;
     this.body[1] = secondBody;
     ContactToWorld = new Matrix3();
     restitution = ContactGenerator.restitution;
     friction = ContactGenerator.friction;
 }
Beispiel #4
0
 public Contact(Collidable firstBody, Plane plane)
 {
     this.body[0] = firstBody;
     this.body[1] = null;
     this.WithPlane = true;
     this.plane = new HalfSpace(plane);
     ContactToWorld = new Matrix3();
     restitution = 0.7f;
     friction = 0.3f; // TODO add a dynamic mechanism
 }
Beispiel #5
0
 public override bool generateContacts(Collidable other, Contact contact)
 {
     if (other as Box != null)
     {
         return contact.BoxAndBox();
     }
     else if (other as Sphere != null)
     {
         return contact.SphereAndBox();
     }
     return false;
 }
Beispiel #6
0
        //,float limit)
        //float limit;
        public Joint(Collidable one, Collidable two, Vector3 pos1, Vector3 pos2, float constant)
        {
            body[0] = one;
            body[1] = two;

            position[0] = pos1;
            position[1] = pos2;

            this.constant = constant;

            //this.limit = limit;
        }
Beispiel #7
0
 public override Boolean CollidesWith(Collidable other)
 {
     if (other as Sphere != null)
     {
         return true;
     }
     else if (other as Box != null)
     {
         return true;
     }
     return false;
 }
Beispiel #8
0
 public override ContactData generateContacts(Collidable other)
 {
     Contact contact = new Contact(this, other);
     if (other as Sphere != null)
     {
         contact.SphereAndSphere();
     }
     else if (other as Box != null)
     {
         contact.SphereAndBox();
     }
     return contact.GetContactData();
 }
Beispiel #9
0
 public ContactData generateContacts(Collidable other)
 {
     Contact contact = new Contact(other, this.plane);
     if (other as Sphere != null)
     {
         contact.SphereAndPlane();
     }
     if (other as Box != null)
     {
         contact.BoxAndHalfSpace();
     }
     return contact.GetContactData();
 }
Beispiel #10
0
        /*
        protected override void updateBounding()
        {
            //TODO add update logic
        }

        public override Contact generateContacts(Collidable other)
        {
            Contact contactData = null;

            return contactData;
        }
        */
        public bool generateContacts(Collidable other, Contact contact)
        {
            //TODO FixME
            return false;
            if (other as Sphere != null)
            {
                contact.SphereAndPlane();
            }
            if (other as Box != null)
            {
                contact.BoxAndHalfSpace();
            }
        }
Beispiel #11
0
 public override Boolean CollidesWith(Collidable other)
 {
     //TOOD add CollidesWith() code here
     if (other as Box != null)
     {
         //box.Intersects(((Sphere)other).GetBoundingSphere);
         return true;
     }
     else if (other as Sphere != null)
     {
         return true;
     }
     return false;
 }
 /// <summary>
 /// Adds a body to the collison List to check for it
 /// </summary>
 /// <param name="body"></param>
 public void AddBody(Collidable body)
 {
     this.bodies.AddLast(body);
 }
Beispiel #13
0
 public void AddUpperBody(Collidable body)
 {
     cg.AddConductor(new Rod(body, Balls[0], 0.5f));//,0.6f));
 }
 /// <summary>
 /// Removes a body from collison List 
 /// warning : this method is expensive O(n) , try to not use this in update
 /// </summary>
 /// <param name="body"></param>
 public void RemoveBody(Collidable body)
 {
     this.bodies.Remove(body);
 }
Beispiel #15
0
 /// <summary>
 /// constractor of Rope with upper body upper and bottom body bottom
 /// </summary>
 /// <param name="length"></param>
 /// <param name="cg"></param>
 /// <param name="upper"></param>
 /// <param name="bottom"></param>
 public Rope(float length, ContactGenerator cg, Game game, Gravity gravity, Collidable upper, Collidable bottom)
     : this(length, cg,game,gravity)
 {
     AddUpperBody(upper);
     AddBottomBody(bottom);
 }
Beispiel #16
0
 public void AddBottomBody(Collidable body)
 {
     cg.AddConductor(new Rod(Balls[Balls.Count - 1], body, 0.5f));//,0.6f));
 }
Beispiel #17
0
 /// <summary>
 /// Checks whether the body collides with another collidable or not
 /// </summary>
 /// <param name="other">the other collidable body to collides with </param>
 /// <returns></returns>
 public abstract Boolean CollidesWith(Collidable other);
Beispiel #18
0
 /// <summary>
 /// generates contact information for this collidable body with another one 
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public abstract ContactData generateContacts(Collidable other);
Beispiel #19
0
 /// <summary>
 ///  generates contact information for this collidable body with another one 
 ///  and fill this info into an existing contact
 /// </summary>
 /// <param name="other"></param>
 /// <param name="contact">a contact to fill</param>
 /// <returns></returns>
 public abstract bool generateContacts(Collidable other,Contact contact);
Beispiel #20
0
 public void Insert(Collidable Body)
 {
     if (this.isLeaf())
     {
         Children[0] = new BVHNode(this, this.Body);
         Children[1] = new BVHNode(this, Body);
         this.Body = null;
         RecalculateBoundingVolume();
     }
     else
     {
         BoundingSphere Temp = Body.GetBoundingSphere();
         if (BoundingSphere.CreateMerged(Children[0].Volume, Temp).Radius
             < BoundingSphere.CreateMerged(Children[1].Volume, Temp).Radius)
             Children[0].Insert(Body);
         else
             Children[1].Insert(Body);
     }
 }
Beispiel #21
0
 public Rod(Collidable one, Collidable two, float len)
 {
     body[0] = one;
     body[1] = two;
     length = len;
 }