/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> protected override void Initialize() { fixedBall = new Ball(1f); fixedBall.Texture = Content.Load<Texture2D>(@"basic_material"); fixedBall.Position = new Vector3(0f, 0, 0f); ball = new Ball(0.3f); ball.Texture = Content.Load<Texture2D>(@"basic_material"); ball.Position = new Vector3(0f, -2f, 0f); crate = new Crate(new Vector3(0.07f, 0.05f, 0.05f)); crate.Position = new Vector3(0.3f, 5f, 0.20f); crate.Mass = 10; cg = new ContactGenerator(); cg.AddBody(fixedBall); cg.AddBody(ball); cg.AddBody(crate); fixedBall.model = Content.Load<Model>(@"ball"); ball.model = fixedBall.model; camera = new Camera(this, new Vector3(0, 0, 10f), Vector3.Zero, Vector3.Up); Components.Add(camera); g = new Gravity(new Vector3(0f, -10f, 0f)); fixedBall.InverseMass = 0; fixedBall.InverseInertiaTensor = new Matrix(); ball.Mass = 1f; sp = new Spring(fixedBall, ball, 3f, 2f, 0.995f, Vector3.Zero, new Vector3(0.5f, 0.5f, 0.5f)); base.Initialize(); }
void CrateSpringPanel() { if (springPanel.springClicked != "") { currentSpring = ((Lab)Game).basicLab.springs[springPanel.springClicked]; Reset(); panel.AddField("Constant", currentSpring.springConstant); panel.AddField("RestLength", currentSpring.restLength); panel.AddField("C", currentSpring.C); panel.AddOkButton(); panel.AddCancelButton(); panel.AddApplyButton(); panel.Show = true; } }