public void UpdateWheel(RigidBody chassis, RaycastInfo raycastInfo) { if (raycastInfo.IsInContact) { float project = Vector3.Dot(raycastInfo.ContactNormalWS, raycastInfo.WheelDirectionWS); Vector3 chassis_velocity_at_contactPoint; Vector3 relpos = raycastInfo.ContactPointWS - chassis.CenterOfMassPosition; chassis_velocity_at_contactPoint = chassis.GetVelocityInLocalPoint(relpos); float projVel = Vector3.Dot(raycastInfo.ContactNormalWS, chassis_velocity_at_contactPoint); if (project >= -0.1f) { SuspensionRelativeVelocity = 0; ClippedInvContactDotSuspension = 1.0f / 0.1f; } else { float inv = -1.0f / project; SuspensionRelativeVelocity = projVel * inv; ClippedInvContactDotSuspension = inv; } } else // Not in contact : position wheel in a nice (rest length) position { RaycastInfo.SuspensionLength = SuspensionRestLength; SuspensionRelativeVelocity = 0; RaycastInfo.ContactNormalWS = -raycastInfo.WheelDirectionWS; ClippedInvContactDotSuspension = 1.0f; } }
public WheelInfo(WheelInfoConstructionInfo ci) { SuspensionRestLength1 = ci.SuspensionRestLength; MaxSuspensionTravelCm = ci.MaxSuspensionTravelCm; WheelsRadius = ci.WheelRadius; SuspensionStiffness = ci.SuspensionStiffness; WheelsDampingCompression = ci.WheelsDampingCompression; WheelsDampingRelaxation = ci.WheelsDampingRelaxation; ChassisConnectionPointCS = ci.ChassisConnectionCS; WheelDirectionCS = ci.WheelDirectionCS; WheelAxleCS = ci.WheelAxleCS; FrictionSlip = ci.FrictionSlip; Steering = 0; EngineForce = 0; Rotation = 0; DeltaRotation = 0; Brake = 0; RollInfluence = 0.1f; IsFrontWheel = ci.IsFrontWheel; MaxSuspensionForce = ci.MaxSuspensionForce; //ClientInfo = IntPtr.Zero; //ClippedInvContactDotSuspension = 0; WorldTransform = Matrix.Identity; //WheelsSuspensionForce = 0; //SuspensionRelativeVelocity = 0; //SkidInfo = 0; RaycastInfo = new RaycastInfo(); }
public unsafe static void GetContactNormalWS(this RaycastInfo obj, out OpenTK.Vector3 value) { fixed(OpenTK.Vector3 *valuePtr = &value) { *(BulletSharp.Math.Vector3 *)valuePtr = obj.ContactNormalWS; } }
public unsafe static void SetWheelDirectionWS(this RaycastInfo obj, ref OpenTK.Vector3 value) { fixed(OpenTK.Vector3 *valuePtr = &value) { obj.WheelDirectionWS = *(BulletSharp.Math.Vector3 *)valuePtr; } }
public unsafe static void SetHardPointWS(this RaycastInfo obj, ref OpenTK.Vector3 value) { fixed(OpenTK.Vector3 *valuePtr = &value) { obj.HardPointWS = *(BulletSharp.Math.Vector3 *)valuePtr; } }
public unsafe static void GetWheelAxleWS(this RaycastInfo obj, out OpenTK.Vector3 value) { fixed(OpenTK.Vector3 *valuePtr = &value) { *(BulletSharp.Math.Vector3 *)valuePtr = obj.WheelAxleWS; } }
public static void SetWheelDirectionWS(this RaycastInfo obj, OpenTK.Vector3 value) { SetWheelDirectionWS(obj, ref value); }
public static void SetHardPointWS(this RaycastInfo obj, OpenTK.Vector3 value) { SetHardPointWS(obj, ref value); }
public static void SetContactNormalWS(this RaycastInfo obj, OpenTK.Vector3 value) { SetContactNormalWS(obj, ref value); }
public static OpenTK.Vector3 GetWheelDirectionWS(this RaycastInfo obj) { OpenTK.Vector3 value; GetWheelDirectionWS(obj, out value); return(value); }
public static OpenTK.Vector3 GetHardPointWS(this RaycastInfo obj) { OpenTK.Vector3 value; GetHardPointWS(obj, out value); return(value); }
public static OpenTK.Vector3 GetContactNormalWS(this RaycastInfo obj) { OpenTK.Vector3 value; GetContactNormalWS(obj, out value); return(value); }