Ejemplo n.º 1
0
        private static NewtonTire CreateTire(TireID tireID, TransformNode tireTrans,
            GeometryNode carNode, float gravity)
        {
            NewtonTire tire = new NewtonTire();

            Material tireMat = new Material();
            tireMat.Diffuse = Color.Orange.ToVector4();
            tireMat.Specular = Color.White.ToVector4();
            tireMat.SpecularPower = 10;

            float tireRadius = 0.7f;
            GeometryNode tireNode = new GeometryNode("Race Car " + tireID + " Tire");
            tireNode.Model = new Cylinder(tireRadius, tireRadius, 0.3f, 20);
            tireNode.Material = tireMat;

            carNode.AddChild(tireTrans);
            tireTrans.AddChild(tireNode);

            tire.Mass = 5.0f;
            tire.Width = 0.3f * 1.25f;
            tire.Radius = tireRadius;

            switch (tireID)
            {
                case TireID.FrontLeft:
                    tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(-1.5f, 0, -1f));
                    break;
                case TireID.FrontRight:
                    tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(-1.5f, 0, 1f));
                    break;
                case TireID.RearLeft:
                    tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(1.5f, 0, -1f));
                    break;
                case TireID.RearRight:
                    tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(1.5f, 0, 1f));
                    break;
            }

            // the tire will spin around the lateral axis of the same tire space
            tire.Pin = Vector3.UnitZ;

            tire.SuspensionLength = RaceCar.SUSPENSION_LENGTH;

            // calculate the spring and damper contact for the subquestion  
            //
            // from the equation of a simple spring the force is given by
            // a = k * x
            // where k is a spring constant and x is the displacement and a is the spring acceleration.
            // we desire that a rest length the acceleration generated by the spring equal that of the gravity
            // several gravity forces
            // m * gravity = k * SUSPENSION_LENGTH * 0.5f, 
            float x = RaceCar.SUSPENSION_LENGTH;
            tire.SuspensionSpring = (200.0f * (float)Math.Abs(gravity)) / x;
            //tireSuspesionSpring = (100.0f * dAbs (GRAVITY)) / x;

            // from the equation of a simple spring / damper system
            // the system resonate at a frequency 
            // w^2 = ks
            //
            // and the damping attenuation is given by
            // d = ks / 2.0f
            // where:
            // if   d = w = 2 * pi * f -> the system is critically damped
            // if   d > w < 2 * pi * f -> the system is super critically damped
            // if   d < w < 2 * pi * f -> the system is under damped damped 
            // for a vehicle we usually want a suspension that is about 10% super critically damped 
            float w = (float)Math.Sqrt(tire.SuspensionSpring);

            // a critically damped suspension act too jumpy for a race car
            tire.SuspensionShock = 1.0f * w;

            // make it a little super critical y damped
            //tireSuspesionShock = 2.0f * w;

            tire.CollisionID = 0x100;

            return tire;
        }
Ejemplo n.º 2
0
        private static NewtonTire CreateTire(TireID tireID, TransformNode tireTrans,
                                             GeometryNode carNode, float gravity)
        {
            NewtonTire tire = new NewtonTire();

            Material tireMat = new Material();

            tireMat.Diffuse       = Color.Orange.ToVector4();
            tireMat.Specular      = Color.White.ToVector4();
            tireMat.SpecularPower = 10;

            float        tireRadius = 1.4f;
            GeometryNode tireNode   = new GeometryNode("Race Car " + tireID + " Tire");

            tireNode.Model    = new Cylinder(tireRadius, tireRadius, 0.9f, 20);
            tireNode.Material = tireMat;

            carNode.AddChild(tireTrans);
            tireTrans.AddChild(tireNode);

            tire.Mass   = 5.0f;
            tire.Width  = 0.3f * 1.25f;
            tire.Radius = tireRadius;

            switch (tireID)
            {
            case TireID.FrontLeft:
                tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(-5.9f, 0, -3.0f));
                break;

            case TireID.FrontRight:
                tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(-5.9f, 0, 3.0f));
                break;

            case TireID.RearLeft:
                tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(5.0f, 0, -3.0f));
                break;

            case TireID.RearRight:
                tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(5.0f, 0, 3.0f));
                break;
            }

            // the tire will spin around the lateral axis of the same tire space
            tire.Pin = Vector3.UnitZ;

            tire.SuspensionLength = RaceCar.SUSPENSION_LENGTH;

            float x = RaceCar.SUSPENSION_LENGTH;

            tire.SuspensionSpring = (200.0f * (float)Math.Abs(gravity)) / x;
            //tireSuspesionSpring = (100.0f * dAbs (GRAVITY)) / x;

            float w = (float)Math.Sqrt(tire.SuspensionSpring);

            // a critically damped suspension act too jumpy for a race car
            tire.SuspensionShock = 1.0f * w;

            // make it a little super critical y damped
            //tireSuspesionShock = 2.0f * w;

            tire.CollisionID = 0x100;

            return(tire);
        }
Ejemplo n.º 3
0
        private static NewtonTire CreateTire(TireID tireID, TransformNode tireTrans,
            GeometryNode carNode, float gravity)
        {
            NewtonTire tire = new NewtonTire();

            Material tireMat = new Material();
            tireMat.Diffuse = Color.Orange.ToVector4();
            tireMat.Specular = Color.White.ToVector4();
            tireMat.SpecularPower = 10;

            float tireRadius = 1.4f;
            GeometryNode tireNode = new GeometryNode("Race Car " + tireID + " Tire");
            tireNode.Model = new Cylinder(tireRadius, tireRadius, 0.9f, 20);
            tireNode.Material = tireMat;

            carNode.AddChild(tireTrans);
            tireTrans.AddChild(tireNode);

            tire.Mass = 5.0f;
            tire.Width = 0.3f * 1.25f;
            tire.Radius = tireRadius;

            switch (tireID)
            {
                case TireID.FrontLeft:
                    tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(-5.9f, 0, -3.0f));
                    break;
                case TireID.FrontRight:
                    tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(-5.9f, 0, 3.0f));
                    break;
                case TireID.RearLeft:
                    tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(5.0f, 0, -3.0f));
                    break;
                case TireID.RearRight:
                    tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(5.0f, 0, 3.0f));
                    break;
            }

            // the tire will spin around the lateral axis of the same tire space
            tire.Pin = Vector3.UnitZ;

            tire.SuspensionLength = RaceCar.SUSPENSION_LENGTH;

            float x = RaceCar.SUSPENSION_LENGTH;
            tire.SuspensionSpring = (200.0f * (float)Math.Abs(gravity)) / x;
            //tireSuspesionSpring = (100.0f * dAbs (GRAVITY)) / x;

            float w = (float)Math.Sqrt(tire.SuspensionSpring);

            // a critically damped suspension act too jumpy for a race car
            tire.SuspensionShock = 1.0f * w;

            // make it a little super critical y damped
            //tireSuspesionShock = 2.0f * w;

            tire.CollisionID = 0x100;

            return tire;
        }
Ejemplo n.º 4
0
        private static NewtonTire CreateTire(TireID tireID, TransformNode tireTrans,
                                             GeometryNode carNode, float gravity)
        {
            NewtonTire tire = new NewtonTire();

            Material tireMat = new Material();

            tireMat.Diffuse       = Color.Orange.ToVector4();
            tireMat.Specular      = Color.White.ToVector4();
            tireMat.SpecularPower = 10;

            float        tireRadius = 0.7f;
            GeometryNode tireNode   = new GeometryNode("Race Car " + tireID + " Tire");

            tireNode.Model    = new Cylinder(tireRadius, tireRadius, 0.3f, 20);
            tireNode.Material = tireMat;

            carNode.AddChild(tireTrans);
            tireTrans.AddChild(tireNode);

            tire.Mass   = 5.0f;
            tire.Width  = 0.3f * 1.25f;
            tire.Radius = tireRadius;

            switch (tireID)
            {
            case TireID.FrontLeft:
                tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(-1.5f, 0, -1f));
                break;

            case TireID.FrontRight:
                tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(-1.5f, 0, 1f));
                break;

            case TireID.RearLeft:
                tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(1.5f, 0, -1f));
                break;

            case TireID.RearRight:
                tire.TireOffsetMatrix = Matrix.CreateTranslation(new Vector3(1.5f, 0, 1f));
                break;
            }

            // the tire will spin around the lateral axis of the same tire space
            tire.Pin = Vector3.UnitZ;

            tire.SuspensionLength = RaceCar.SUSPENSION_LENGTH;

            // calculate the spring and damper contact for the subquestion
            //
            // from the equation of a simple spring the force is given by
            // a = k * x
            // where k is a spring constant and x is the displacement and a is the spring acceleration.
            // we desire that a rest length the acceleration generated by the spring equal that of the gravity
            // several gravity forces
            // m * gravity = k * SUSPENSION_LENGTH * 0.5f,
            float x = RaceCar.SUSPENSION_LENGTH;

            tire.SuspensionSpring = (200.0f * (float)Math.Abs(gravity)) / x;
            //tireSuspesionSpring = (100.0f * dAbs (GRAVITY)) / x;

            // from the equation of a simple spring / damper system
            // the system resonate at a frequency
            // w^2 = ks
            //
            // and the damping attenuation is given by
            // d = ks / 2.0f
            // where:
            // if   d = w = 2 * pi * f -> the system is critically damped
            // if   d > w < 2 * pi * f -> the system is super critically damped
            // if   d < w < 2 * pi * f -> the system is under damped damped
            // for a vehicle we usually want a suspension that is about 10% super critically damped
            float w = (float)Math.Sqrt(tire.SuspensionSpring);

            // a critically damped suspension act too jumpy for a race car
            tire.SuspensionShock = 1.0f * w;

            // make it a little super critical y damped
            //tireSuspesionShock = 2.0f * w;

            tire.CollisionID = 0x100;

            return(tire);
        }