public void GetWheelTransform(int unitIndex, int axleIndex, int axleSide, ref Vector3 position, ref Quaternion rotation) { if (IntPtr.Zero != VsVehicleHandle) { Check(VS_Vehicle.IsValidVehicle(VsVehicleHandle)); if (VS_Vehicle.IsOk(VsVehicleHandle)) { double forward = 0; double left = 0; double up = 0; double rollRightRad = 0; double pitchDownRad = 0; double yawLeftRad = 0; VS_Vehicle.GetTireWorldPosition(VsVehicleHandle, unitIndex, axleIndex, axleSide, ref forward, ref left, ref up); VS_Vehicle.GetTireWorldOrientation(VsVehicleHandle, unitIndex, axleIndex, axleSide, ref rollRightRad, ref pitchDownRad, ref yawLeftRad); position = VsUnityLib.VSToUnityVector(forward, left, up); rotation = VsUnityLib.VSToUnityRotation(rollRightRad, pitchDownRad, yawLeftRad); //Log(rollRightRad + "," + pitchDownRad + "," + yawLeftRad); //CarSim_UnityLib.SetUnityTransformFromSolverValues(wheelGameObject, (float)forward, (float)left, (float)up, (float)rollRightRad, (float)pitchDownRad, (float)yawLeftRad); } } }
public Quaternion GetUnitWorldOrientation(int unitIndex) { double rollRightRad = 0, pitchDownRad = 0, yawLeftRad = 0; VS_Vehicle.GetWorldOrientation(VsVehicleHandle, unitIndex, ref rollRightRad, ref pitchDownRad, ref yawLeftRad); Quaternion worldRotation = VsUnityLib.VSToUnityRotation(rollRightRad, pitchDownRad, yawLeftRad); return(worldRotation); }
/// <summary> /// set unity transform from vs vehicle infomation. /// </summary> /// <param name="gameObject"></param> /// <param name="forward"></param> /// <param name="left"></param> /// <param name="up"></param> /// <param name="roll"></param> /// <param name="pitch"></param> /// <param name="yaw"></param> static public void SetUnityTransformFromSolverValues(GameObject gameObject, float forward, float left, float up, float roll, float pitch, float yaw) { gameObject.transform.position = VsUnityLib.VSToUnityVector(forward, left, up); gameObject.transform.rotation = VsUnityLib.VSToUnityRotation(roll, pitch, yaw); }