public Cable(Collidable one, Collidable two, float max, float restitution) { body[0] = one; body[1] = two; maxLength = max; this.restitution = restitution; }
public BVHNode(BVHNode Parent, Collidable Body) { Children[0] = null; Children[1] = null; this.Body = Body; this.Volume = Body.GetBoundingSphere(); this.Parent = Parent; }
public Contact(Collidable firstBody, Collidable secondBody) { this.body[0] = firstBody; this.body[1] = secondBody; ContactToWorld = new Matrix3(); restitution = ContactGenerator.restitution; friction = ContactGenerator.friction; }
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 }
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; }
//,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; }
public override Boolean CollidesWith(Collidable other) { if (other as Sphere != null) { return true; } else if (other as Box != null) { return true; } return false; }
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(); }
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(); }
/* 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(); } }
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); }
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); }
/// <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); }
public void AddBottomBody(Collidable body) { cg.AddConductor(new Rod(Balls[Balls.Count - 1], body, 0.5f));//,0.6f)); }
/// <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);
/// <summary> /// generates contact information for this collidable body with another one /// </summary> /// <param name="other"></param> /// <returns></returns> public abstract ContactData generateContacts(Collidable other);
/// <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);
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); } }
public Rod(Collidable one, Collidable two, float len) { body[0] = one; body[1] = two; length = len; }