void InitWheelData(IntPtr data, InitDataClass.WheelItem source)
        {
            PhysXNativeVehicleInitData.SetParameter(data, "mass", source.Mass);

            PhysXNativeVehicleInitData.SetParameter(data, "wheelDampingRate", source.WheelDampingRate);
            PhysXNativeVehicleInitData.SetParameter(data, "wheelMaxBrakeTorque", source.WheelMaxBrakeTorque);
            PhysXNativeVehicleInitData.SetParameter(data, "wheelMaxHandBrakeTorque", source.WheelMaxHandBrakeTorque);
            PhysXNativeVehicleInitData.SetParameter(data, "wheelMaxSteer", source.WheelMaxSteer);
            PhysXNativeVehicleInitData.SetParameter(data, "wheelToeAngle", source.WheelToeAngle);
            PhysXNativeVehicleInitData.SetParameter(data, "suspensionSpringStrength", source.SuspensionSpringStrength);
            PhysXNativeVehicleInitData.SetParameter(data, "suspensionSpringDamperRate", source.SuspensionSpringDamperRate);
            PhysXNativeVehicleInitData.SetParameter(data, "suspensionMaxCompression", source.SuspensionMaxCompression);
            PhysXNativeVehicleInitData.SetParameter(data, "suspensionMaxDroop", source.SuspensionMaxDroop);
            PhysXNativeVehicleInitData.SetParameter(data, "suspensionSprungMassCoefficient", source.SuspensionSprungMassCoefficient);

            PhysXNativeVehicleInitData.SetParameter(data, "suspensionForceApplicationPointOffset.X", source.SuspensionForceApplicationPointOffset.X);
            PhysXNativeVehicleInitData.SetParameter(data, "suspensionForceApplicationPointOffset.Y", source.SuspensionForceApplicationPointOffset.Y);
            PhysXNativeVehicleInitData.SetParameter(data, "suspensionForceApplicationPointOffset.Z", source.SuspensionForceApplicationPointOffset.Z);

            PhysXNativeVehicleInitData.SetParameter(data, "tireForceApplicationPointOffset.X", source.TireForceApplicationPointOffset.X);
            PhysXNativeVehicleInitData.SetParameter(data, "tireForceApplicationPointOffset.Y", source.TireForceApplicationPointOffset.Y);
            PhysXNativeVehicleInitData.SetParameter(data, "tireForceApplicationPointOffset.Z", source.TireForceApplicationPointOffset.Z);

            PhysXNativeVehicleInitData.SetParameter(data, "tireLatStiffX", source.TireLatStiffX);
            PhysXNativeVehicleInitData.SetParameter(data, "tireLatStiffY", source.TireLatStiffY);
            PhysXNativeVehicleInitData.SetParameter(data, "tireLongitudinalStiffnessPerUnitGravity", source.TireLongitudinalStiffnessPerUnitGravity);
            PhysXNativeVehicleInitData.SetParameter(data, "tireCamberStiffness", source.TireCamberStiffness);
            PhysXNativeVehicleInitData.SetParameter(data, "frictionVsSlipGraphZeroLongitudinalSlip", source.FrictionVsSlipGraphZeroLongitudinalSlip);
            PhysXNativeVehicleInitData.SetParameter(data, "frictionVsSlipGraphLongitudinalSlipWithMaximumFriction", source.FrictionVsSlipGraphLongitudinalSlipWithMaximumFriction);
            PhysXNativeVehicleInitData.SetParameter(data, "frictionVsSlipGraphMaximumFriction", source.FrictionVsSlipGraphMaximumFriction);
            PhysXNativeVehicleInitData.SetParameter(data, "frictionVsSlipGraphEndPointOfGraph", source.FrictionVsSlipGraphEndPointOfGraph);
            PhysXNativeVehicleInitData.SetParameter(data, "frictionVsSlipGraphValueOfFrictionForSlipsGreaterThanEndPointOfGraph", source.FrictionVsSlipGraphValueOfFrictionForSlipsGreaterThanEndPointOfGraph);
        }
        void PushToWorld()
        {
            PhysXPhysicsScene scene    = (PhysXPhysicsScene)Scene;
            PhysXBody         baseBody = (PhysXBody)BaseBody;

            IntPtr generalData         = PhysXNativeVehicleInitData.Create();
            IntPtr wheelFrontLeftData  = PhysXNativeVehicleInitData.Create();
            IntPtr wheelFrontRightData = PhysXNativeVehicleInitData.Create();
            IntPtr wheelRearLeftData   = PhysXNativeVehicleInitData.Create();
            IntPtr wheelRearRightData  = PhysXNativeVehicleInitData.Create();

            //Chassis mass
            PhysXNativeVehicleInitData.SetParameter(generalData, "massChassis", InitData.MassChassis);

            //Differential
            PhysXNativeVehicleInitData.SetParameter(generalData, "differentialType", (float)(int)InitData.DifferentialType);
            PhysXNativeVehicleInitData.SetParameter(generalData, "differentialFrontRearSplit", InitData.DifferentialFrontRearSplit);
            PhysXNativeVehicleInitData.SetParameter(generalData, "differentialFrontLeftRightSplit", InitData.DifferentialFrontLeftRightSplit);
            PhysXNativeVehicleInitData.SetParameter(generalData, "differentialRearLeftRightSplit", InitData.DifferentialRearLeftRightSplit);
            PhysXNativeVehicleInitData.SetParameter(generalData, "differentialCenterBias", InitData.DifferentialCenterBias);
            PhysXNativeVehicleInitData.SetParameter(generalData, "differentialFrontBias", InitData.DifferentialFrontBias);
            PhysXNativeVehicleInitData.SetParameter(generalData, "differentialRearBias", InitData.DifferentialRearBias);

            //Engine
            {
                PhysXNativeVehicleInitData.SetParameter(generalData, "enginePeakTorque", InitData.EnginePeakTorque);
                PhysXNativeVehicleInitData.SetParameter(generalData, "engineMaxRPM", InitData.EngineMaxRPM);
                PhysXNativeVehicleInitData.SetParameter(generalData, "engineDampingRateFullThrottle",
                                                        InitData.EngineDampingRateFullThrottle);
                PhysXNativeVehicleInitData.SetParameter(generalData, "engineDampingRateZeroThrottleClutchEngaged",
                                                        InitData.EngineDampingRateZeroThrottleClutchEngaged);
                PhysXNativeVehicleInitData.SetParameter(generalData, "engineDampingRateZeroThrottleClutchDisengaged",
                                                        InitData.EngineDampingRateZeroThrottleClutchDisengaged);

                if (InitData.EngineTorqueCurve.Count == 0)
                {
                    Log.Fatal("PhysXPhysicsVehicle: PushToWorld: EngineTorqueCurve is not configured.");
                }
                if (InitData.EngineTorqueCurve.Count > 8)
                {
                    Log.Fatal("PhysXPhysicsVehicle: PushToWorld: EngineTorqueCurve can't have more than 8 values.");
                }
                for (int n = 0; n < InitData.EngineTorqueCurve.Count; n++)
                {
                    InitDataClass.EngineTorqueCurveItem item = InitData.EngineTorqueCurve[n];
                    PhysXNativeVehicleInitData.SetParameter(generalData, string.Format("engineTorqueCurveTorque{0}", n),
                                                            item.NormalizedTorque);
                    PhysXNativeVehicleInitData.SetParameter(generalData, string.Format("engineTorqueCurveRev{0}", n),
                                                            item.NormalizedRev);
                }
            }

            //Gears
            {
                if (InitData.Gears.Count == 0)
                {
                    Log.Fatal("PhysXPhysicsVehicle: PushToWorld: The gears are not defined.");
                }
                if (InitData.FindGearByNumber(0) == null)
                {
                    Log.Fatal("PhysXPhysicsVehicle: PushToWorld: Neutral gear is not defined.");
                }
                if (InitData.FindGearByNumber(-1) == null)
                {
                    Log.Fatal("PhysXPhysicsVehicle: PushToWorld: Reverse gear is not defined.");
                }

                foreach (PhysicsVehicle.InitDataClass.GearItem gearItem in InitData.Gears)
                {
                    if (gearItem.Number < -1)
                    {
                        Log.Fatal("PhysXPhysicsVehicle: PushToWorld: Gear number can't be less than -1.");
                    }
                    if (gearItem.Number > 30)
                    {
                        Log.Fatal("PhysXPhysicsVehicle: PushToWorld: Gear number can't be more than 30.");
                    }

                    if (gearItem.Number < 0 && gearItem.Ratio >= 0)
                    {
                        Log.Fatal("PhysXPhysicsVehicle: PushToWorld: Reverse gear ratio must be less than zero.");
                    }
                    if (gearItem.Number == 0 && gearItem.Ratio != 0)
                    {
                        Log.Fatal("PhysXPhysicsVehicle: PushToWorld: Neutral gear ratio must be zero.");
                    }
                    if (gearItem.Number > 0 && gearItem.Ratio < 0)
                    {
                        Log.Fatal("PhysXPhysicsVehicle: PushToWorld: Forward gear ratios must be greater than zero.");
                    }

                    if (gearItem.Number >= 2)
                    {
                        PhysicsVehicle.InitDataClass.GearItem nextGearItem = InitData.FindGearByNumber(gearItem.Number - 1);
                        if (nextGearItem == null || gearItem.Ratio > nextGearItem.Ratio)
                        {
                            Log.Fatal("PhysXPhysicsVehicle: PushToWorld: Forward gear ratios must be a descending sequence of gear ratios.");
                        }
                    }

                    PhysXNativeVehicleInitData.SetParameter(generalData, string.Format("gear{0}", gearItem.Number), gearItem.Ratio);
                }
                PhysXNativeVehicleInitData.SetParameter(generalData, "gearsSwitchTime", InitData.GearsSwitchTime);
            }

            //Clutch
            PhysXNativeVehicleInitData.SetParameter(generalData, "clutchStrength", InitData.ClutchStrength);

            //Ackermann steer accuracy
            PhysXNativeVehicleInitData.SetParameter(generalData, "ackermannSteerAccuracy", InitData.AckermannSteerAccuracy);

            //Wheels
            InitWheelData(wheelFrontLeftData, InitData.WheelFrontLeft);
            InitWheelData(wheelFrontRightData, InitData.WheelFrontRight);
            InitWheelData(wheelRearLeftData, InitData.WheelRearLeft);
            InitWheelData(wheelRearRightData, InitData.WheelRearRight);

            //Tire settings
            {
                int n = 0;
                foreach (InitDataClass.TireFrictionMultiplierItem frictionItem in InitData.TireFrictionMultipliers)
                {
                    PhysXNativeVehicleInitData.SetParameter(generalData,
                                                            string.Format("tireFrictionMaterial{0}", n), frictionItem.SurfaceMaterialName);
                    PhysXNativeVehicleInitData.SetParameter(generalData,
                                                            string.Format("tireFrictionValue{0}", n), frictionItem.Value);
                    n++;
                }
            }

            nativeVehicle = PhysXNativeVehicle.Create(scene.nativeScene, baseBody.nativeBody, generalData,
                                                      wheelFrontLeftData, wheelFrontRightData, wheelRearLeftData, wheelRearRightData);

            PhysXNativeVehicleInitData.Destroy(generalData);
            PhysXNativeVehicleInitData.Destroy(wheelFrontLeftData);
            PhysXNativeVehicleInitData.Destroy(wheelFrontRightData);
            PhysXNativeVehicleInitData.Destroy(wheelRearLeftData);
            PhysXNativeVehicleInitData.Destroy(wheelRearRightData);

            OnUpdateAutoGearSettings();
        }