public void AddPart(int parentId, EntityPart child) { if (!partList.ContainsKey(child.Id)) { partList.Add(child.Id, child); } child.body.CollisionSkin.callbackFn += new CollisionCallbackFn(PartCollisioncallbackFn); if (partList.ContainsKey(parentId)) { EntityPart parent = partList[parentId]; /* * collision skin types which should or should not collide with those in another certain group. * * */ if (child.part.Name == "fuselageA") { JigLibX.Physics.ConstraintPoint c = new ConstraintPoint(parent.body, new Vector3(3, 3, 3), child.body, new Vector3(-3, -3, 3), 0, 1f); PhysicsSystem.CurrentPhysicsSystem.AddConstraint(c); c.EnableConstraint(); JigLibX.Physics.ConstraintPoint c2 = new ConstraintPoint(parent.body, new Vector3(3, 3, -3), child.body, new Vector3(-3, -3, -3), 0, 1f); PhysicsSystem.CurrentPhysicsSystem.AddConstraint(c2); c2.EnableConstraint(); JigLibX.Physics.ConstraintPoint c3 = new ConstraintPoint(parent.body, new Vector3(3, -3, 0), child.body, new Vector3(-3, -6, 0), 0, 1f); PhysicsSystem.CurrentPhysicsSystem.AddConstraint(c3); c3.EnableConstraint(); } else if (child.part.Name == "fuselageB") { JigLibX.Physics.ConstraintPoint c = new ConstraintPoint(parent.body, new Vector3(-3, 3, 3), child.body, new Vector3(3, -3, 3), 0, 1f); PhysicsSystem.CurrentPhysicsSystem.AddConstraint(c); c.EnableConstraint(); JigLibX.Physics.ConstraintPoint c2 = new ConstraintPoint(parent.body, new Vector3(-3, 3, -3), child.body, new Vector3(3, -3, -3), 0, 1f); PhysicsSystem.CurrentPhysicsSystem.AddConstraint(c2); c2.EnableConstraint(); JigLibX.Physics.ConstraintPoint c3 = new ConstraintPoint(parent.body, new Vector3(-3, -3, 0), child.body, new Vector3(3, -6, 0), 0, 1f); PhysicsSystem.CurrentPhysicsSystem.AddConstraint(c3); c3.EnableConstraint(); } parent.AddPart(ref child); child.fParentPart = parent; } }
public void AddPart(int parentId, EntityPart child) { if (!parts.ContainsKey(child.Id)) { parts.Add(child.Id, child); } child.body.CollisionSkin.callbackFn += new CollisionCallbackFn(PartCollisioncallbackFn); if (parts.ContainsKey(parentId)) { EntityPart parent = parts[parentId]; parent.AddPart(ref child); child.fParentPart = parent; } }