Ejemplo n.º 1
0
 public void AddBall(Model model, Texture2D texture, Texture2D selectedTexture, 
     Vector3 position = new Vector3(), float radius = 0.5f, float mass = 5f)
 {
     Ball ball = new Ball(radius);
     ball.Mass = mass;
     ball.Position = position;
     ball.model = model;
     ball.Texture = texture;
     ball.SelectedTexture = selectedTexture;
     bodys.Add(ball);
     cg.AddBody(ball);
 }
Ejemplo n.º 2
0
 public void AddBall(Vector3 position = new Vector3(), 
     float radius = 0.5f, float mass = 5f)
 {
     Ball ball = new Ball(radius);
     ball.Mass = mass;
     ball.Position = position;
     ball.model = BallModel;
     ball.Texture = BallTexture;
     ball.SelectedTexture = SelectedBallTexture;
     bodys.Add(ball);
     cg.AddBody(ball);
 }
Ejemplo n.º 3
0
 public void AddBall(Ball ball)
 {
     bodys.Add(ball);
     cg.AddBody(ball);
 }
Ejemplo n.º 4
0
 public Ball CreateBall(Vector3 position)
 {
     Ball ball = new Ball(0.5f);
     ball.Position = position;
     ball.Mass = 1f;
     ball.model = BallModel;
     ball.Texture = BallTexture;
     ball.SelectedTexture = SelectedBallTexture;
     ball.SelectedTexture_Panel = SelectedBallTexture2;
     AddBall(ball);
     PhysiXEngine.Effect e = effects.Last<PhysiXEngine.Effect>();
     if (e as Gravity != null)
         ((Gravity)e).AddBody(ball);
     else
         throw new Exception();
     return ball;
 }
Ejemplo n.º 5
0
 public void AddToRoom(Ball ball)
 {
     room.Add(ball);
     cg.AddBody(ball);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            /*
            Ball ball = new Ball(0.5f);
            ball.Position = new Vector3(2f, 0f, 0f);
            ball.model = basicLab.BallModel;
            ball.Texture = basicLab.BallTexture;
            ball.SelectedTexture = basicLab.SelectedBallTexture;
            ball.SelectedTexture_Panel = basicLab.SelectedBallTexture2;
            ball.Mass = 5f;
            //ball.InverseMass = 0;
            basicLab.AddBall(ball);

            Ball ball1 = new Ball(0.5f);
            ball1.Position = new Vector3(0.1f, -2f, 0f);
            ball1.model = basicLab.BallModel;
            ball1.Texture = basicLab.BallTexture;
            ball1.SelectedTexture = basicLab.SelectedBallTexture;
            ball1.SelectedTexture_Panel = basicLab.SelectedBallTexture2;
            ball1.InverseMass = 0;
            basicLab.AddBall(ball1);

            Ball ball2 = new Ball(0.5f);
            ball2.model = basicLab.BallModel;
            ball2.Texture = basicLab.BallTexture;
            ball2.Mass = 10f;
            ball2.Position = new Vector3(1f, 1f, 2f);
            ball2.SelectedTexture = basicLab.SelectedBallTexture;
            ball2.SelectedTexture_Panel = basicLab.SelectedBallTexture2;
            basicLab.AddBall(ball2);

            Ball ball3 = new Ball(0.2f);
            ball3.model = basicLab.BallModel;
            ball3.Texture = basicLab.BallTexture;
            ball3.Mass = 2f;
            ball3.Position = new Vector3(2f, 1f, 2f);
            ball3.SelectedTexture = basicLab.SelectedBallTexture;
            ball3.SelectedTexture_Panel = basicLab.SelectedBallTexture2;
            basicLab.AddBall(ball3);

            Crate crate = new Crate(new Vector3(0.5f, 0.2f, 0.3f));
            crate.Mass = 1f;
            crate.model = basicLab.CrateModel;
            crate.Texture = basicLab.CrateTexture;
            crate.SelectedTexture = basicLab.SelectedCrateTexture;
            crate.SelectedTexture_Panel = basicLab.SelectedCrateTexture2;
            crate.Position = new Vector3(1f, -2f, 1f);
            basicLab.AddCrate(crate);

            basicLab.CreateRoom(10f, 10f, 10f);

            basicLab.AddEffect(new Spring(ball, ball1, new Vector3(1, 1, 1), 10f, 2f, 0.995f));

             */
            basicLab.CreateRoom(10f, 10f, 10f);

            Ball ball1 = new Ball(0.5f);
            //ball1.InverseInertiaTensor = new Matrix();
            ball1.Mass = 1f;
            ball1.Position = new Vector3(0f, 8.5f, -5.5f);
            ball1.model = basicLab.BallModel;
            ball1.Texture = basicLab.BallTexture;
            ball1.SelectedTexture = basicLab.SelectedBallTexture;
            ball1.SelectedTexture_Panel = basicLab.SelectedBallTexture2;
            basicLab.AddBall(ball1);

            Ball ball2 = new Ball(0.5f);
            ball2.Mass = 1f;
            //ball2.InverseInertiaTensor = new Matrix();
            ball2.Position = new Vector3(-9f, 8.5f, -6f);
            ball2.model = basicLab.BallModel;
            ball2.Texture = basicLab.BallTexture;
            ball2.SelectedTexture = basicLab.SelectedBallTexture;
            ball2.SelectedTexture_Panel = basicLab.SelectedBallTexture2;
            basicLab.AddBall(ball2);

            Ball ball3 = new Ball(0.6f);
            ball3.Mass = 1f;
            //ball3.InverseInertiaTensor = new Matrix();
            ball3.Position = new Vector3(6f, 8.5f, -9f);
            ball3.model = basicLab.BallModel;
            ball3.Texture = basicLab.BallTexture;
            ball3.SelectedTexture = basicLab.SelectedBallTexture;
            ball3.SelectedTexture_Panel = basicLab.SelectedBallTexture2;
            basicLab.AddBall(ball3);

            Ball ball4 = new Ball(0.5f);
            ball4.Mass = 5f;
            //ball4.InverseInertiaTensor = new Matrix();
            ball4.Position = new Vector3(7f, 8.5f, -5f);
            ball4.model = basicLab.BallModel;
            ball4.Texture = basicLab.BallTexture;
            ball4.SelectedTexture = basicLab.SelectedBallTexture;
            ball4.SelectedTexture_Panel = basicLab.SelectedBallTexture2;
            basicLab.AddBall(ball4);

            Ball FixedBall = new Ball(0.5f);
            FixedBall.InverseMass = 0;
            //FixedBall.InverseInertiaTensor = new Matrix();
            FixedBall.Position = new Vector3(1.5f, 8f, -2f);
            FixedBall.model = basicLab.BallModel;
            FixedBall.Texture = basicLab.BallTexture;
            FixedBall.SelectedTexture = basicLab.SelectedBallTexture;
            FixedBall.SelectedTexture_Panel = basicLab.SelectedBallTexture2;
            basicLab.AddBall(FixedBall);
            /*
            Ball SBall = new Ball(0.5f);
            SBall.Mass = 2f;
            //SBall.InverseInertiaTensor = new Matrix();
            SBall.Position = new Vector3(1.5f, 0f, -2f);
            SBall.model = basicLab.BallModel;
            SBall.Texture = basicLab.BallTexture;
            SBall.SelectedTexture = basicLab.SelectedBallTexture;
            SBall.SelectedTexture_Panel = basicLab.SelectedBallTexture2;
            basicLab.AddBall(SBall);
            */
            Crate crate = new PhysicsLab.Crate(new Vector3(1, 1, 1));
            crate.Mass = 1f;
            crate.Position = new Vector3(1.5f, 0f, -2f);
            crate.model = basicLab.CrateModel;
            crate.Texture = basicLab.CrateTexture;
            crate.SelectedTexture = basicLab.SelectedCrateTexture;
            crate.SelectedTexture_Panel = basicLab.SelectedCrateTexture2;
            basicLab.AddCrate(crate);

            //basicLab.AddEffect(new Spring(SBall, FixedBall, new Vector3(1, 1, 1), 5f, 6f, 0.9f));
            basicLab.AddEffect(new Spring(crate, FixedBall, 5f, 6f, 0.9f, new Vector3(0.5f, 0.5f, 0.5f)));
            //basicLab.AddEffect(new Spring(SBall, FixedBall, new Vector3(1, 1, 1), 5f, 1f, 0.9f));
            //basicLab.AddEffect(new Spring(SBall, ball1, new Vector3(1, 1, 1), 5f, 1f, 0.9f));
            //basicLab.AddEffect(new Spring(ball1, ball2, new Vector3(1, 1, 1), 5f, 1f, 0.9f));
            basicLab.AddEffect(new Gravity(new Vector3(0, -10f, 0)));
        }