/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here base.Initialize(); physicsManager.LinearErrorTolerance = .2f; Model cupBottomModel = Content.Load<Model>("cup_bottom"); Model cupTopModel = Content.Load<Model>("cup_top"); Body cupBottom = new Body(this, cupBottomModel, "cup_bottom"); Body cupTop = new Body(this, cupTopModel, "cup_top"); cupBottom.OnCollision += OnCollide; for (int i = 0; i < cupBottom.Skin.Count; i++) { cupBottom.Skin.SetMaterial(cupBottom.Skin[i], new Material(1, .5f)); } cupBottom.MassProperties = MassProperties.Immovable; cupBottom.SetWorld(10, Vector3.Zero, Quaternion.Identity); bodies.Add(cupBottom); for (int i = 0; i < cupTop.Skin.Count; i++) { cupTop.Skin.SetMaterial(cupTop.Skin[i], new Material(1, .5f)); } cupTop.MassProperties = MassProperties.Immovable; cupTop.SetWorld(10, Vector3.Zero, Quaternion.Identity); bodies.Add(cupTop); BodySkin skin = new BodySkin(); skin.DefaultMaterial = new Material(.4f, .5f); skin.Add( new PlanePart(new Vector3(0, 0, -1f), Vector3.UnitZ), new PlanePart(new Vector3(0, 1, 0), -Vector3.UnitY), new PlanePart(new Vector3(0, 0, 0), Vector3.UnitY), new PlanePart(new Vector3(1, 0, 0), -Vector3.UnitX), new PlanePart(new Vector3(-1, 0, 0), Vector3.UnitX) ); wall = new RigidBody(skin); wall.SetWorld(10, Vector3.Zero, Quaternion.Identity); physicsManager.Gravity = new Vector3(0,-9.8f, 0); physicsManager.Add(cupBottom); physicsManager.Add(cupTop); physicsManager.Add(wall); prevState = Keyboard.GetState(); }