示例#1
0
        private void BuildCar()
        {
            JitterDemo demo = this.Game as JitterDemo;
            World world = demo.World;

            CompoundShape.TransformedShape lower = new CompoundShape.TransformedShape(
                new BoxShape(2.5f, 1f, 6.0f), JMatrix.Identity, JVector.Zero);

            CompoundShape.TransformedShape upper = new CompoundShape.TransformedShape(
                new BoxShape(2.0f, 0.5f, 3.0f), JMatrix.Identity, JVector.Up * 0.75f + JVector.Backward * 1.0f);

            CompoundShape.TransformedShape[] subShapes = { lower, upper };

            Shape chassis = new CompoundShape(subShapes);

            //chassis = new BoxShape(2.5f, 1f, 6.0f);

            carBody = new DefaultCar(world, chassis);

            // use the inertia of the lower box.

            // adjust some driving values
            carBody.SteerAngle = 30; carBody.DriveTorque = 155;
            carBody.AccelerationRate = 10;
            carBody.SteerRate = 2f;
            carBody.AdjustWheelValues();

            carBody.Tag = BodyTag.DontDrawMe;
            carBody.AllowDeactivation = false;

            // place the car two units above the ground.
            carBody.Position = new JVector(0, 5, 0);

            world.AddBody(carBody);
        }