private static void Main() { using (var game = new JitterDemo()) { game.Run(); } }
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); }
private void DrawChassis() { JitterDemo demo = this.Game as JitterDemo; foreach (ModelMesh mesh in chassisModel.Meshes) { foreach (BasicEffect effect in mesh.Effects) { Matrix matrix = Conversion.ToXNAMatrix(carBody.Orientation); matrix.Translation = Conversion.ToXNAVector(carBody.Position) - Vector3.Transform(new Vector3(0, 1.0f, 0), matrix); //effect.EnableDefaultLighting(); effect.World = matrix; effect.View = demo.Camera.View; effect.Projection = demo.Camera.Projection; } mesh.Draw(); } }
private void DrawWheels() { JitterDemo demo = this.Game as JitterDemo; for (int i = 0; i < carBody.Wheels.Length; i++) { Wheel wheel = carBody.Wheels[i]; Vector3 position = Conversion.ToXNAVector(wheel.GetWorldPosition()); foreach (ModelMesh mesh in tireModel.Meshes) { foreach (BasicEffect effect in mesh.Effects) { Matrix addOrienation; if (i % 2 != 0) { addOrienation = Matrix.CreateRotationX(MathHelper.Pi); } else { addOrienation = Matrix.Identity; } effect.World = addOrienation * Matrix.CreateRotationZ(MathHelper.PiOver2) * Matrix.CreateRotationX(MathHelper.ToRadians(-wheel.WheelRotation)) * Matrix.CreateRotationY(MathHelper.ToRadians(wheel.SteerAngle)) * Conversion.ToXNAMatrix(carBody.Orientation) * Matrix.CreateTranslation(position); //effect.EnableDefaultLighting(); effect.View = demo.Camera.View; effect.Projection = demo.Camera.Projection; } mesh.Draw(); } } }
public override void Draw(GameTime gameTime) { JitterDemo demo = this.Game as JitterDemo; GraphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap; GraphicsDevice.DepthStencilState = DepthStencilState.Default; effect.View = demo.Camera.View; effect.Projection = demo.Camera.Projection; foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList, vertices, 0, cloth.VertexBodies.Count, indices, 0, cloth.Triangles.Count); } base.Draw(gameTime); }
public PrismaticJointTest(JitterDemo demo) : base(demo) { }
public SoftBodyJenga(JitterDemo demo) : base(demo) { }
public BroadphaseStress(JitterDemo demo) : base(demo) { }
public Cloth(JitterDemo demo) : base(demo) { }
public CylinderWall(JitterDemo demo) : base(demo) { }
public PrismaticJointTest(JitterDemo demo) : base(demo) { }
public NewtonCradle(JitterDemo demo) : base(demo) { }
public TriangleMesh(JitterDemo demo) : base(demo) { }
public ConvexDecomposition(JitterDemo demo) : base(demo) { }
public TriangleMesh(JitterDemo demo) : base(demo) { }
public Tower(JitterDemo demo) : base(demo) { }
public Scene(JitterDemo demo) { Demo = demo; }
public Domino(JitterDemo demo) : base(demo) { }
public EmptyScene(JitterDemo demo) : base(demo) { }
public Ragdoll(JitterDemo demo) : base(demo) { }
public Restitution(JitterDemo demo) : base(demo) { }
public Scene(JitterDemo demo) { this.Demo = demo; }
public Restitution(JitterDemo demo) : base(demo) { }
public Pyramid(JitterDemo demo) : base(demo) { }
public Ragdoll(JitterDemo demo) : base(demo) { }
public BroadphaseStress(JitterDemo demo) : base(demo) { }
public Scene(JitterDemo demo) { this.Demo = demo; }
public SoftBodyJenga(JitterDemo demo) : base(demo) { }
public ConvexDecomposition(JitterDemo demo) : base(demo) { }
public Wall(JitterDemo demo) : base(demo) { }
public Tower(JitterDemo demo) : base(demo) { }
public Rope(JitterDemo demo) : base(demo) { }
public CylinderWall(JitterDemo demo) : base(demo) { }
public Domino(JitterDemo demo) : base(demo) { }
public Rope(JitterDemo demo) : base(demo) { }
public Cloth(JitterDemo demo) : base(demo) { }
public NewtonCradle(JitterDemo demo) : base(demo) { }
public Wall(JitterDemo demo) : base(demo) { }
public Terrain(JitterDemo demo) : base(demo) { }
public CardHouse(JitterDemo demo) : base(demo) { }
public Pyramid(JitterDemo demo) : base(demo) { }
public CardHouse(JitterDemo demo) : base(demo) { }
public EmptyScene(JitterDemo demo) : base(demo) { }
public Jenga(JitterDemo demo) : base(demo) { }
public Terrain(JitterDemo demo) : base(demo) { }
public Jenga(JitterDemo demo) : base(demo) { }