Ejemplo n.º 1
0
 public Cable(Collidable one, Collidable two, float max, float restitution)
 {
     body[0] = one;
     body[1] = two;
     maxLength = max;
     this.restitution = restitution;
 }
Ejemplo n.º 2
0
 public BVHNode(BVHNode Parent, Collidable Body)
 {
     Children[0] = null;
     Children[1] = null;
     this.Body = Body;
     this.Volume = Body.GetBoundingSphere();
     this.Parent = Parent;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 12
0
 /// <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);
 }
Ejemplo n.º 13
0
 public void AddUpperBody(Collidable body)
 {
     cg.AddConductor(new Rod(body, Balls[0], 0.5f));//,0.6f));
 }
Ejemplo n.º 14
0
 /// <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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 16
0
 public void AddBottomBody(Collidable body)
 {
     cg.AddConductor(new Rod(Balls[Balls.Count - 1], body, 0.5f));//,0.6f));
 }
Ejemplo n.º 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);
Ejemplo n.º 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);
Ejemplo n.º 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);
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 21
0
 public Rod(Collidable one, Collidable two, float len)
 {
     body[0] = one;
     body[1] = two;
     length = len;
 }