/// <summary> /// Initializes the BRaycastVehicle. /// </summary> private void Awake() { rigidBody = GetComponent <BRigidBody>(); if (rigidBody == null) { Destroy(this); return; } RaycastRobot = new RaycastRobot(defaultVehicleTuning = new VehicleTuning { MaxSuspensionForce = 1000f, MaxSuspensionTravelCm = SuspensionToleranceCm, SuspensionDamping = 10f, SuspensionCompression = SuspensionCompressionRatio, SuspensionStiffness = CalculateStiffness(DefaultNumWheels), FrictionSlip = 2f }, (RigidBody)rigidBody.GetCollisionObject(), new BRobotRaycaster((DynamicsWorld)BPhysicsWorld.Get().world)); RaycastRobot.SetCoordinateSystem(0, 1, 2); BRobotManager.Instance.RegisterRaycastRobot(RaycastRobot); }
public RaycastRobot(VehicleTuning tuning, RigidBody chassis, IVehicleRaycaster raycaster) { chassisBody = chassis; vehicleRaycaster = raycaster; SlidingFriction = 1.0f; EffectiveMass = 1.0f / chassis.InvMass; }
/// <summary> /// Initializes the RaycastRobot with the given vehicle settings and parent chassis. /// </summary> /// <param name="tuning"></param> /// <param name="chassis"></param> /// <param name="raycaster"></param> public RaycastRobot(VehicleTuning tuning, RigidBody chassis, IVehicleRaycaster raycaster) { chassisBody = chassis; RootRigidBody = chassis; vehicleRaycaster = raycaster; MaxWheelAngularVelocity = 40f; OverrideMass = 1.0f / chassis.InvMass; }
public RaycastVehicle(VehicleTuning tuning, RigidBody chassis, IVehicleRaycaster raycaster) { m_vehicleRaycaster = raycaster; m_pitchControl = 0f; m_chassisBody = chassis; m_indexRightAxis = 0; m_indexUpAxis = 1; m_indexForwardAxis = 2; DefaultInit(ref tuning); }
public CustomVehicle(VehicleTuning tuning, RigidBody chassis, IVehicleRaycaster raycaster) { chassisBody = chassis; vehicleRaycaster = raycaster; using (var ci = new RigidBodyConstructionInfo(0, null, null)) { _fixedBody = new RigidBody(ci); _fixedBody.SetMassProps(0, Vector3.Zero); } }
/// <summary> /// Устанавливает настройки тюнинга /// </summary> internal static void SetVehicleTuning(Vehicle vehicle, VehicleTuning tuning) { ResetTuning(vehicle); API.shared.setVehiclePrimaryColor(vehicle, tuning.PrimaryColor); API.shared.setVehicleSecondaryColor(vehicle, tuning.SecondColor); API.shared.setVehicleEnginePowerMultiplier(vehicle, tuning.EnginePower); var neonColor = tuning.GetNeonColor(); if (neonColor.Length > 0) { TurnNeonState(vehicle, true); API.shared.setVehicleNeonColor(vehicle, neonColor[0], neonColor[1], neonColor[2]); } foreach (var mod in tuning.GetMods()) { API.shared.setVehicleMod(vehicle, mod.Key, mod.Value); } }
protected void AddWheels(Vector3 halfExtents, RaycastVehicle vehicle, VehicleTuning tuning, float wheelRadius) { //The direction of the raycast, the btRaycastVehicle uses raycasts instead of simiulating the wheels with rigid bodies Vector3 wheelDirectionCS0 = new Vector3(0, -1, 0); //The axis which the wheel rotates arround Vector3 wheelAxleCS = new Vector3(-1, 0, 0); //All the wheel configuration assumes the vehicle is centered at the origin and a right handed coordinate system is used Vector4 points = contactInfoByChassis(mesh.Name); points.Y += suspensionLength + meshAxisRadius.Y - (meshRealHeight / 2f); //Adds the rear wheels Vector3 wheelConnectionPoint = new Vector3(points.X, points.Y - rearWheelsHeight, points.Z); vehicle.AddWheel(wheelConnectionPoint, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, false); vehicle.AddWheel(wheelConnectionPoint * new Vector3(-1, 1, 1), wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, false); //Adds the front wheels wheelConnectionPoint = new Vector3(points.X, points.Y - frontWheelsHeight, points.W); vehicle.AddWheel(wheelConnectionPoint * new Vector3(1, 1, -1), wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, true); vehicle.AddWheel(wheelConnectionPoint * new Vector3(-1, 1, -1), wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, true); //Configures each wheel of our vehicle, setting its friction, damping compression, etc. //For more details on what each parameter does, refer to the docs for (int i = 0; i < vehicle.NumWheels; i++) { WheelInfo wheel = vehicle.GetWheelInfo(i); wheel.MaxSuspensionForce = 700000; //wheel.MaxSuspensionTravelCm = 80; wheel.SuspensionStiffness = suspensionStiffness; wheel.WheelsDampingCompression = dampingCompression * 2 * FastMath.Sqrt(wheel.SuspensionStiffness); wheel.WheelsDampingRelaxation = dampingRelaxation * 2 * FastMath.Sqrt(wheel.SuspensionStiffness); wheel.FrictionSlip = frictionSlip; wheel.RollInfluence = rollInfluence; } }
public WheelInfo AddWheel(Vector3 connectionPointCS, Vector3 wheelDirectionCS0, Vector3 wheelAxleCS, float suspensionRestLength, float wheelRadius, VehicleTuning tuning, bool isFrontWheel) { WheelInfoConstructionInfo ci = new WheelInfoConstructionInfo(); ci.ChassisConnectionCS = connectionPointCS; ci.WheelDirectionCS = wheelDirectionCS0; ci.WheelAxleCS = wheelAxleCS; ci.SuspensionRestLength = suspensionRestLength; ci.WheelRadius = wheelRadius; ci.SuspensionStiffness = tuning.SuspensionStiffness; ci.WheelsDampingCompression = tuning.SuspensionCompression; ci.WheelsDampingRelaxation = tuning.SuspensionDamping; ci.FrictionSlip = tuning.FrictionSlip; ci.IsFrontWheel = isFrontWheel; ci.MaxSuspensionTravelCm = tuning.MaxSuspensionTravelCm; ci.MaxSuspensionForce = tuning.MaxSuspensionForce; WheelInfo wheel = new WheelInfo(ci); wheelInfo.Add(wheel); UpdateWheelTransformsWS(wheel, false); UpdateWheelTransform(NumWheels - 1, false); return(wheel); }
public CustomVehicle(VehicleTuning tuning, RigidBody chassis, IVehicleRaycaster raycaster) { chassisBody = chassis; vehicleRaycaster = raycaster; }
protected override void OnInitializePhysics() { CollisionShape groundShape = new BoxShape(50, 3, 50); CollisionShapes.Add(groundShape); CollisionConf = new DefaultCollisionConfiguration(); Dispatcher = new CollisionDispatcher(CollisionConf); Solver = new SequentialImpulseConstraintSolver(); Vector3 worldMin = new Vector3(-10000, -10000, -10000); Vector3 worldMax = new Vector3(10000, 10000, 10000); Broadphase = new AxisSweep3(worldMin, worldMax); //Broadphase = new DbvtBroadphase(); World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf); int i; Matrix tr; Matrix vehicleTr; //if (UseTrimeshGround) { const float scale = 20.0f; //create a triangle-mesh ground const int NumVertsX = 20; const int NumVertsY = 20; const int totalVerts = NumVertsX * NumVertsY; const int totalTriangles = 2 * (NumVertsX - 1) * (NumVertsY - 1); TriangleIndexVertexArray vertexArray = new TriangleIndexVertexArray(); IndexedMesh mesh = new IndexedMesh(); mesh.Allocate(totalTriangles, totalVerts); mesh.NumTriangles = totalTriangles; mesh.NumVertices = totalVerts; mesh.TriangleIndexStride = 3 * sizeof(int); mesh.VertexStride = Vector3.SizeInBytes; using (var indicesStream = mesh.GetTriangleStream()) { var indices = new BinaryWriter(indicesStream); for (i = 0; i < NumVertsX - 1; i++) { for (int j = 0; j < NumVertsY - 1; j++) { indices.Write(j * NumVertsX + i); indices.Write(j * NumVertsX + i + 1); indices.Write((j + 1) * NumVertsX + i + 1); indices.Write(j * NumVertsX + i); indices.Write((j + 1) * NumVertsX + i + 1); indices.Write((j + 1) * NumVertsX + i); } } indices.Dispose(); } using (var vertexStream = mesh.GetVertexStream()) { var vertices = new BinaryWriter(vertexStream); for (i = 0; i < NumVertsX; i++) { for (int j = 0; j < NumVertsY; j++) { float wl = .2f; float height = 20.0f * (float)(Math.Sin(i * wl) * Math.Cos(j * wl)); vertices.Write((i - NumVertsX * 0.5f) * scale); vertices.Write(height); vertices.Write((j - NumVertsY * 0.5f) * scale); } } vertices.Dispose(); } vertexArray.AddIndexedMesh(mesh); groundShape = new BvhTriangleMeshShape(vertexArray, true); tr = Matrix.Identity; vehicleTr = Matrix.Translation(0, -2, 0); }/* * else * { * // Use HeightfieldTerrainShape * * int width = 40, length = 40; * //int width = 128, length = 128; // Debugging is too slow for this * float maxHeight = 10.0f; * float heightScale = maxHeight / 256.0f; * Vector3 scale = new Vector3(20.0f, maxHeight, 20.0f); * * //PhyScalarType scalarType = PhyScalarType.PhyUChar; * //FileStream file = new FileStream(heightfieldFile, FileMode.Open, FileAccess.Read); * * // Use float data * PhyScalarType scalarType = PhyScalarType.PhyFloat; * byte[] terr = new byte[width * length * 4]; * MemoryStream file = new MemoryStream(terr); * BinaryWriter writer = new BinaryWriter(file); * for (i = 0; i < width; i++) * for (int j = 0; j < length; j++) * writer.Write((float)((maxHeight / 2) + 4 * Math.Sin(j * 0.5f) * Math.Cos(i))); * writer.Flush(); * file.Position = 0; * * HeightfieldTerrainShape heightterrainShape = new HeightfieldTerrainShape(width, length, * file, heightScale, 0, maxHeight, upIndex, scalarType, false); * heightterrainShape.SetUseDiamondSubdivision(true); * * groundShape = heightterrainShape; * groundShape.LocalScaling = new Vector3(scale.X, 1, scale.Z); * * tr = Matrix.Translation(new Vector3(-scale.X / 2, scale.Y / 2, -scale.Z / 2)); * vehicleTr = Matrix.Translation(new Vector3(20, 3, -3)); * * * // Create graphics object * * file.Position = 0; * BinaryReader reader = new BinaryReader(file); * * int totalTriangles = (width - 1) * (length - 1) * 2; * int totalVerts = width * length; * * game.groundMesh = new Mesh(game.Device, totalTriangles, totalVerts, * MeshFlags.SystemMemory | MeshFlags.Use32Bit, VertexFormat.Position | VertexFormat.Normal); * SlimDX.DataStream data = game.groundMesh.LockVertexBuffer(LockFlags.None); * for (i = 0; i < width; i++) * { * for (int j = 0; j < length; j++) * { * float height; * if (scalarType == PhyScalarType.PhyFloat) * { * // heightScale isn't applied internally for float data * height = reader.ReadSingle(); * } * else if (scalarType == PhyScalarType.PhyUChar) * { * height = file.ReadByte() * heightScale; * } * else * { * height = 0.0f; * } * * data.Write((j - length * 0.5f) * scale.X); * data.Write(height); * data.Write((i - width * 0.5f) * scale.Z); * * // Normals will be calculated later * data.Position += 12; * } * } * game.groundMesh.UnlockVertexBuffer(); * file.Close(); * * data = game.groundMesh.LockIndexBuffer(LockFlags.None); * for (i = 0; i < width - 1; i++) * { * for (int j = 0; j < length - 1; j++) * { * // Using diamond subdivision * if ((j + i) % 2 == 0) * { * data.Write(j * width + i); * data.Write((j + 1) * width + i + 1); * data.Write(j * width + i + 1); * * data.Write(j * width + i); * data.Write((j + 1) * width + i); * data.Write((j + 1) * width + i + 1); * } * else * { * data.Write(j * width + i); * data.Write((j + 1) * width + i); * data.Write(j * width + i + 1); * * data.Write(j * width + i + 1); * data.Write((j + 1) * width + i); * data.Write((j + 1) * width + i + 1); * } * * / * * // Not using diamond subdivision * data.Write(j * width + i); * data.Write((j + 1) * width + i); * data.Write(j * width + i + 1); * * data.Write(j * width + i + 1); * data.Write((j + 1) * width + i); * data.Write((j + 1) * width + i + 1); * / * } * } * game.groundMesh.UnlockIndexBuffer(); * * game.groundMesh.ComputeNormals(); * }*/ CollisionShapes.Add(groundShape); //create ground object RigidBody ground = LocalCreateRigidBody(0, tr, groundShape); ground.UserObject = "Ground"; CollisionShape chassisShape = new BoxShape(1.0f, 0.5f, 2.0f); CollisionShapes.Add(chassisShape); CompoundShape compound = new CompoundShape(); CollisionShapes.Add(compound); //localTrans effectively shifts the center of mass with respect to the chassis Matrix localTrans = Matrix.Translation(Vector3.UnitY); compound.AddChildShape(localTrans, chassisShape); RigidBody carChassis = LocalCreateRigidBody(800, Matrix.Identity, compound); carChassis.UserObject = "Chassis"; //carChassis.SetDamping(0.2f, 0.2f); //CylinderShapeX wheelShape = new CylinderShapeX(wheelWidth, wheelRadius, wheelRadius); // clientResetScene(); // create vehicle VehicleTuning tuning = new VehicleTuning(); IVehicleRaycaster vehicleRayCaster = new DefaultVehicleRaycaster(World); //vehicle = new RaycastVehicle(tuning, carChassis, vehicleRayCaster); vehicle = new CustomVehicle(tuning, carChassis, vehicleRayCaster); carChassis.ActivationState = ActivationState.DisableDeactivation; World.AddAction(vehicle); const float connectionHeight = 1.2f; bool isFrontWheel = true; // choose coordinate system vehicle.SetCoordinateSystem(rightIndex, upIndex, forwardIndex); BulletSharp.Math.Vector3 connectionPointCS0 = new Vector3(CUBE_HALF_EXTENTS - (0.3f * wheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - wheelRadius); vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel); connectionPointCS0 = new Vector3(-CUBE_HALF_EXTENTS + (0.3f * wheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - wheelRadius); vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel); isFrontWheel = false; connectionPointCS0 = new Vector3(-CUBE_HALF_EXTENTS + (0.3f * wheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + wheelRadius); vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel); connectionPointCS0 = new Vector3(CUBE_HALF_EXTENTS - (0.3f * wheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + wheelRadius); vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel); for (i = 0; i < vehicle.NumWheels; i++) { WheelInfo wheel = vehicle.GetWheelInfo(i); wheel.SuspensionStiffness = suspensionStiffness; wheel.WheelsDampingRelaxation = suspensionDamping; wheel.WheelsDampingCompression = suspensionCompression; wheel.FrictionSlip = wheelFriction; wheel.RollInfluence = rollInfluence; } vehicle.RigidBody.WorldTransform = vehicleTr; }
public Character(DiscreteDynamicsWorld world, Vehiculo vehiculo, TGCVector3 position, float rotation, GameModel gameModel) { //Cargar sonido turboSound = new TgcStaticSound(); turboSound.loadSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "turbo.wav", gameModel.DirectSound.DsDevice); this.vehiculo = vehiculo; var loader = new TgcSceneLoader(); this.mesh = loader.loadSceneFromFile(vehiculo.ChassisXmlPath).Meshes[0]; this.wheel = loader.loadSceneFromFile(vehiculo.WheelsXmlPath).Meshes[0]; Vehiculo.ChangeTextureColor(this.mesh, vehiculo.Color); this.mesh.AutoTransform = false; this.wheel.AutoTransform = false; maxHitPoints = float.Parse(mesh.UserProperties["maxHitPoints"], CultureInfo.InvariantCulture); engineForce = -float.Parse(mesh.UserProperties["engineForce"], CultureInfo.InvariantCulture); brakeForce = float.Parse(mesh.UserProperties["brakeForce"], CultureInfo.InvariantCulture); steeringAngle = -float.Parse(mesh.UserProperties["steeringAngle"], CultureInfo.InvariantCulture); turboImpulse = float.Parse(mesh.UserProperties["turboImpulse"], CultureInfo.InvariantCulture); frictionSlip = float.Parse(mesh.UserProperties["frictionSlip"], CultureInfo.InvariantCulture); rollInfluence = float.Parse(mesh.UserProperties["rollInfluence"], CultureInfo.InvariantCulture); rearWheelsHeight = float.Parse(mesh.UserProperties["rearWheelsHeight"], CultureInfo.InvariantCulture); frontWheelsHeight = float.Parse(mesh.UserProperties["frontWheelsHeight"], CultureInfo.InvariantCulture); suspensionRestLength = float.Parse(mesh.UserProperties["suspensionRestLength"], CultureInfo.InvariantCulture); suspensionStiffness = float.Parse(mesh.UserProperties["suspensionStiffness"], CultureInfo.InvariantCulture); dampingCompression = float.Parse(mesh.UserProperties["dampingCompression"], CultureInfo.InvariantCulture); dampingRelaxation = float.Parse(mesh.UserProperties["dampingRelaxation"], CultureInfo.InvariantCulture); meshAxisRadius = this.mesh.BoundingBox.calculateAxisRadius().ToBsVector; var wheelRadius = this.wheel.BoundingBox.calculateAxisRadius().Y; //The btBoxShape is centered at the origin CollisionShape chassisShape = new BoxShape(meshAxisRadius.X, meshRealHeight, meshAxisRadius.Z); //A compound shape is used so we can easily shift the center of gravity of our vehicle to its bottom //This is needed to make our vehicle more stable CompoundShape compound = new CompoundShape(); //The center of gravity of the compound shape is the origin. When we add a rigidbody to the compound shape //it's center of gravity does not change. This way we can add the chassis rigidbody one unit above our center of gravity //keeping it under our chassis, and not in the middle of it var localTransform = Matrix.Translation(0, (meshAxisRadius.Y * 1.75f) - (meshRealHeight / 2f), 0); compound.AddChildShape(localTransform, chassisShape); //Creates a rigid body this.rigidBody = CreateChassisRigidBodyFromShape(compound, position, rotation); //Adds the vehicle chassis to the world world.AddRigidBody(this.rigidBody); worldID = world.CollisionObjectArray.IndexOf(this.rigidBody); //RaycastVehicle DefaultVehicleRaycaster vehicleRayCaster = new DefaultVehicleRaycaster(world); VehicleTuning tuning = new VehicleTuning(); //Creates a new instance of the raycast vehicle vehicle = new RaycastVehicle(tuning, this.rigidBody, vehicleRayCaster); //Never deactivate the vehicle this.rigidBody.ActivationState = ActivationState.DisableDeactivation; //Adds the vehicle to the world world.AddAction(vehicle); //Adds the wheels to the vehicle AddWheels(meshAxisRadius, vehicle, tuning, wheelRadius); //Inicializo puntos hitPoints = maxHitPoints; specialPoints = maxSpecialPoints; timerMachineGun = 0f; }
private void CreateVehicle(Matrix transform) { var chassisShape = new BoxShape(1.0f, 0.5f, 2.0f); var compound = new CompoundShape(); //localTrans effectively shifts the center of mass with respect to the chassis Matrix localTrans = Matrix.Translation(Vector3.UnitY); compound.AddChildShape(localTrans, chassisShape); RigidBody carChassis = PhysicsHelper.CreateBody(800, Matrix.Identity, compound, World); carChassis.UserObject = "Chassis"; //carChassis.SetDamping(0.2f, 0.2f); var tuning = new VehicleTuning(); var vehicleRayCaster = new DefaultVehicleRaycaster(World); //vehicle = new RaycastVehicle(tuning, carChassis, vehicleRayCaster); _vehicle = new CustomVehicle(tuning, carChassis, vehicleRayCaster); carChassis.ActivationState = ActivationState.DisableDeactivation; World.AddAction(_vehicle); const float connectionHeight = 1.2f; // choose coordinate system _vehicle.SetCoordinateSystem(rightIndex, upIndex, forwardIndex); Vector3 wheelDirection = Vector3.Zero; Vector3 wheelAxle = Vector3.Zero; wheelDirection[upIndex] = -1; wheelAxle[rightIndex] = -1; bool isFrontWheel = true; var connectionPoint = new Vector3(CUBE_HALF_EXTENTS - (0.3f * wheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - wheelRadius); _vehicle.AddWheel(connectionPoint, wheelDirection, wheelAxle, suspensionRestLength, wheelRadius, tuning, isFrontWheel); connectionPoint = new Vector3(-CUBE_HALF_EXTENTS + (0.3f * wheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - wheelRadius); _vehicle.AddWheel(connectionPoint, wheelDirection, wheelAxle, suspensionRestLength, wheelRadius, tuning, isFrontWheel); isFrontWheel = false; connectionPoint = new Vector3(-CUBE_HALF_EXTENTS + (0.3f * wheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + wheelRadius); _vehicle.AddWheel(connectionPoint, wheelDirection, wheelAxle, suspensionRestLength, wheelRadius, tuning, isFrontWheel); connectionPoint = new Vector3(CUBE_HALF_EXTENTS - (0.3f * wheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + wheelRadius); _vehicle.AddWheel(connectionPoint, wheelDirection, wheelAxle, suspensionRestLength, wheelRadius, tuning, isFrontWheel); for (int i = 0; i < _vehicle.NumWheels; i++) { WheelInfo wheel = _vehicle.GetWheelInfo(i); wheel.SuspensionStiffness = suspensionStiffness; wheel.WheelsDampingRelaxation = suspensionDamping; wheel.WheelsDampingCompression = suspensionCompression; wheel.FrictionSlip = wheelFriction; wheel.RollInfluence = rollInfluence; } _vehicle.RigidBody.WorldTransform = transform; }
public WheelInfo AddWheel(Vector3 connectionPointCS, Vector3 wheelDirectionCS0, Vector3 wheelAxleCS, float suspensionRestLength, float wheelRadius, VehicleTuning tuning, bool isFrontWheel) { var ci = new WheelInfoConstructionInfo { ChassisConnectionCS = connectionPointCS, WheelDirectionCS = wheelDirectionCS0, WheelAxleCS = wheelAxleCS, SuspensionRestLength = suspensionRestLength, WheelRadius = wheelRadius, SuspensionStiffness = tuning.SuspensionStiffness, WheelsDampingCompression = tuning.SuspensionCompression, WheelsDampingRelaxation = tuning.SuspensionDamping, FrictionSlip = tuning.FrictionSlip, IsFrontWheel = isFrontWheel, MaxSuspensionTravelCm = tuning.MaxSuspensionTravelCm, MaxSuspensionForce = tuning.MaxSuspensionForce, }; var wheel = new WheelInfo(ci); _wheelInfo.Add(wheel); UpdateWheelTransformsWS(wheel, false); UpdateWheelTransform(NumWheels - 1, false); return(wheel); }
private void DefaultInit(ref VehicleTuning tuning) { //(void)tuning; m_currentVehicleSpeedKmHour = 0f; m_steeringValue = 0f; }
public WheelInfo AddWheel(ref Vector3 connectionPointCS0, ref Vector3 wheelDirectionCS0, ref Vector3 wheelAxleCS, float suspensionRestLength, float wheelRadius, VehicleTuning tuning, bool isFrontWheel) { WheelInfoConstructionInfo ci = new WheelInfoConstructionInfo(); ci.m_chassisConnectionCS = connectionPointCS0; ci.m_wheelDirectionCS = wheelDirectionCS0; ci.m_wheelAxleCS = wheelAxleCS; ci.m_suspensionRestLength = suspensionRestLength; ci.m_wheelRadius = wheelRadius; ci.m_suspensionStiffness = tuning.m_suspensionStiffness; ci.m_wheelsDampingCompression = tuning.m_suspensionCompression; ci.m_wheelsDampingRelaxation = tuning.m_suspensionDamping; ci.m_frictionSlip = tuning.m_frictionSlip; ci.m_bIsFrontWheel = isFrontWheel; ci.m_maxSuspensionTravelCm = tuning.m_maxSuspensionTravelCm; ci.m_maxSuspensionForce = tuning.m_maxSuspensionForce; WheelInfo wheel = new WheelInfo(ref ci); m_wheelInfo.Add(wheel); UpdateWheelTransformsWS(wheel, false); UpdateWheelTransform(GetNumWheels() - 1, false); return wheel; }