/// <summary> /// Builds and spawns the body into the world. /// </summary> public virtual void SpawnBody() { if (Body != null) { DestroyBody(); } Body = new BEPUphysics.Entities.Entity(Shape, Mass); Body.CollisionInformation.CollisionRules.Group = CGroup; InternalOffset = new Location(Body.Position); Body.AngularVelocity = new Vector3((double)AVel.X, (double)AVel.Y, (double)AVel.Z); Body.LinearVelocity = new Vector3((double)LVel.X, (double)LVel.Y, (double)LVel.Z); Body.WorldTransform = WorldTransform; // TODO: Position, Orientation Body.Tag = this; Body.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Passive; if (!CanRotate) { Body.AngularDamping = 1; } // TODO: Other settings // TODO: Gravity SetFriction(Friction); SetBounciness(Bounciness); TheRegion.PhysicsWorld.Add(Body); for (int i = 0; i < Joints.Count; i++) { if (Joints[i] is BaseJoint) { BaseJoint joint = (BaseJoint)Joints[i]; joint.CurrentJoint = joint.GetBaseJoint(); TheRegion.PhysicsWorld.Add(joint.CurrentJoint); } } }
public void AddJoint(InternalBaseJoint joint) { Joints.Add(joint); joint.One.Joints.Add(joint); joint.Two.Joints.Add(joint); joint.Enable(); if (joint is BaseJoint) { BaseJoint pjoint = (BaseJoint)joint; pjoint.CurrentJoint = pjoint.GetBaseJoint(); PhysicsWorld.Add(pjoint.CurrentJoint); } }
public void AddJoint(InternalBaseJoint joint) { Joints.Add(joint); joint.One.Joints.Add(joint); joint.Two.Joints.Add(joint); joint.JID = jID++; joint.Enable(); if (joint is BaseJoint) { BaseJoint pjoint = (BaseJoint)joint; pjoint.CurrentJoint = pjoint.GetBaseJoint(); PhysicsWorld.Add(pjoint.CurrentJoint); } SendToAll(new AddJointPacketOut(joint)); }