private void DrawWheel(Wheel wh, bool rotated) { Camera camera = ((JiggleGame)this.Game).Camera; foreach (ModelMesh mesh in wheel.Meshes) { foreach (BasicEffect effect in mesh.Effects) { float steer = wh.SteerAngle; Matrix rot; if (rotated) rot = Matrix.CreateRotationY(MathHelper.ToRadians(180.0f)); else rot = Matrix.Identity; effect.World = rot * Matrix.CreateRotationZ(MathHelper.ToRadians(-wh.AxisAngle)) * // rotate the wheels Matrix.CreateRotationY(MathHelper.ToRadians(steer)) * Matrix.CreateTranslation(wh.Pos + wh.Displacement * wh.LocalAxisUp) * car.Chassis.Body.Orientation * // oritentation of wheels Matrix.CreateTranslation(car.Chassis.Body.Position); // translation effect.View = camera.View; effect.Projection = camera.Projection; effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; } mesh.Draw(); } }
private void DrawWheel(Wheel wh, bool rotated) { //foreach (ModelMesh mesh in wheel.Meshes) { //foreach (BasicEffect effect in mesh.Effects) { float steer = wh.SteerAngle; /*Matrix rot; if (rotated) rot = Matrix.CreateRotationY(MathHelper.ToRadians(180.0f)); else rot = Matrix.Identity; effect.World = rot * Matrix.CreateRotationZ(MathHelper.ToRadians(-wh.AxisAngle)) * // rotate the wheels Matrix.CreateRotationY(MathHelper.ToRadians(steer)) * Matrix.CreateTranslation(wh.Pos + wh.Displacement * wh.LocalAxisUp) * car.Chassis.Body.Orientation * // oritentation of wheels Matrix.CreateTranslation(car.Chassis.Body.Position); // translation */ } //mesh.Draw(); } }