lvjincheng 4 anni fa
parent
commit
7fd5928dc9
1 ha cambiato i file con 6 aggiunte e 6 eliminazioni
  1. 6 6
      Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

+ 6 - 6
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -245,12 +245,12 @@ public class AimHandler : MonoBehaviour
             return;
         
         float ax = -TwoByteToFloat(bytes[7], bytes[8]);
-        float ay = TwoByteToFloat(bytes[9], bytes[10]);
+        float ay = -TwoByteToFloat(bytes[9], bytes[10]);
         float az = -TwoByteToFloat(bytes[11], bytes[12]);
         ax = ax / 32768 * 16;
         ay = ay / 32768 * 16;
         az = az / 32768 * 16;
-        Acc = new Vector3(ax, ay, az);
+        Acc = new Vector3(ay, ax, az);
         AccObj.transform.GetChild(0).localPosition = Acc;
 
 
@@ -258,9 +258,9 @@ public class AimHandler : MonoBehaviour
         float pitch = TwoByteToFloat(bytes[15], bytes[16]);
         float yaw = TwoByteToFloat(bytes[17], bytes[18]);
         roll = -roll / 32768 * 2000;
-        pitch = pitch / 32768 * 2000;
+        pitch = -pitch / 32768 * 2000;
         yaw = -yaw / 32768 * 2000;
-        Gyr = new Vector3(roll, pitch, yaw) / 1000;
+        Gyr = new Vector3(pitch, roll, yaw) / 1000;
         Gyr = GyrCalibrater.Update(Gyr);
         if (GyrCalibrater.Calibration) 
         {
@@ -277,8 +277,8 @@ public class AimHandler : MonoBehaviour
 
         float x = TwoByteToFloat(bytes[19], bytes[20]);
         float y = TwoByteToFloat(bytes[21], bytes[22]);
-        float z = -TwoByteToFloat(bytes[23], bytes[24]);
-        var mag = new Vector3(x, y, z);
+        float z = TwoByteToFloat(bytes[23], bytes[24]);
+        var mag = new Vector3(-y, x, -z);
         Mag = mag / 32768 * 256;