private void AddRigidBodyToWorld(RigidBody item) { // Initialize the shape Jitter.Collision.Shapes.Shape shape = null; // Box shape if (item.Shape is BoxShape) { var shapeInfo = item.Shape as BoxShape; shape = new Jitter.Collision.Shapes.BoxShape(shapeInfo.Size.X, shapeInfo.Size.Y, shapeInfo.Size.Z); } // Capsule shape else if (item.Shape is CapsuleShape) { var shapeInfo = item.Shape as CapsuleShape; shape = new Jitter.Collision.Shapes.CapsuleShape(shapeInfo.Length, shapeInfo.Radius); } // Default shape else { throw new NotImplementedException("The specified shape has not been implemented"); } // Initialize the body with the specified shape var body = new Jitter.Dynamics.RigidBody(shape) { Position = new JVector(item.Position.X, item.Position.Y, item.Position.Z), IsStatic = item.IsStatic, DynamicFriction = 0, Mass = item.Mass }; // Add the body to the world world.AddBody(body); // Map the item to the world item worldItems.Add(item, body); // TODO: DEBUG code only if (item.Id == "Player") { var constraint = new CharacterController(world, body); world.AddConstraint(constraint); item.Tag = constraint; } }
public CapsuleShape(float height, float radius) { coneShape = new Jitter.Collision.Shapes.CapsuleShape(height, radius); }