lvjincheng 3 жил өмнө
parent
commit
ceb77dc305

+ 333 - 371
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -7,6 +7,7 @@ using UnityEngine.UI;
 using Newtonsoft.Json;
 using o0._9Axis;
 using o0;
+using System.Reflection;
 
 /* 瞄准处理器 */
 public class AimHandler : MonoBehaviour
@@ -19,43 +20,11 @@ public class AimHandler : MonoBehaviour
             return null;
         }
     }
-    [SerializeField] Button SetIdentityButton;
-    [SerializeField] Button MagCalibrationButton;
-    [SerializeField] Button GyrCalibrationButton;
-    [SerializeField] Text MagScaleText;
-    [SerializeField] Text GyrScaleText;
-
-    //椭圆对象
-    [SerializeField] Ellipse ellipseScript;
-    [SerializeField] GameObject AccObj;
-    [SerializeField] GameObject MagObj;
-
-    [SerializeField] GameObject AccMesh;
-    [SerializeField] GameObject GryMesh;
-    [SerializeField] GameObject MagMesh;
-    [SerializeField] GameObject AMesh;
-    [SerializeField] Transform DebugTexts;
-    [SerializeField] Transform DrawImage;
-    
-    long TimeGap = default;
-    Vector3 Acc = default;
-    Vector3 Gyr = default;
-    Vector3 Mag = default;
-    public o09Axis _9Axis = new o09Axis();
-
-    Vector3 cMaxVector = new Vector3(0,0,0);
-    Vector3 cMinVector = new Vector3(0, 0, 0);
-
-    [o0.Serialize]
-    MagnetometerAutoCalibrater MagCalibrater;
-    o0GyrCalibrater GyrCalibrater;
 
     //陀螺仪校准进度记录
     [NonSerialized] public int gyrCalibrateCompleteCount = 0;
     [NonSerialized] public int gyrCalibrateTotalCount = 2000;
 
-    [NonSerialized] public long msOld = 0;
-
     public static AimHandler ins; 
 
     void Start()
@@ -64,198 +33,42 @@ public class AimHandler : MonoBehaviour
         BluetoothDispatcher.aim = OnDataReceived;
 
         //初始化
-        _9Axis.LoadIdentity();
-
-        _9Axis.AccMesh = AccMesh;
-        _9Axis.GryMesh = GryMesh;
-        _9Axis.MagMesh = MagMesh;
-
-        for (var i = 0; i < 9; ++i)
-        {
-            _9Axis.Tester.Add(DrawImage.Find(i.ToString()).gameObject.AddComponent<o0UIRawImageTester>());
-        }
-
-        for (var i = 0; i < 15; ++i)
-        {
-            _9Axis.TextTester.Add(DebugTexts.transform.Find("Text" + i.ToString()).gameObject.GetComponent<Text>());
-        }
-
-        if (SetIdentityButton) 
-        {
-            SetIdentityButton.onClick.AddListener(DoIdentity);
-        }
-
-        InitGyr(null);
-        InitMag(null);
-    }
-
-    public void InitGyr(string record) {
-        try {
-            if (!string.IsNullOrEmpty(record)) {
-                var res = JsonConvert.DeserializeObject<o0GyrCalibrater>(record);
-                if (res != null) GyrCalibrater = res;
-            } else {
-                GyrCalibrater = new o0GyrCalibrater();
-            }
-        } catch(Exception) {}
-    }
-
-    public void InitMag(string record) {
-        try {
-            if (!string.IsNullOrEmpty(record)) {
-                MagCalibrater = JsonConvert.DeserializeObject<MagnetometerAutoCalibrater>(record, new MagJsonConverter());
-            } else {
-                MagCalibrater = new MagnetometerAutoCalibrater();
-            }
-        } catch (System.Exception e) {
-            Debug.LogError("地磁计反序列化出错");
-            Debug.LogError(e.Message);
-            Debug.LogError(e.StackTrace);
-        }
-        magComplete = MagCalibrater.Complete;
+        Init();
     }
 
     public void ResetGyr() {
-        GyrCalibrater._Average = Vector3.zero;
+        _663Axis.Attitude.GyrCalibrate = true;
+        _663Axis.Attitude.GyrCalibrate = false;
     }
 
     public void ResetMag() {
-        MagCalibrater = new MagnetometerAutoCalibrater();
+        _663Axis.Attitude.MagCalibrater = new o0.IMU.MagnetometerAutoCalibrater();
     }
 
     public bool IsGyrCompleted() {
-        return !GyrCalibrater._Average.Equals(Vector3.zero);
+        FieldInfo fieldInfo = _663Axis.Attitude.GetType().GetField("GyrCalibrater1", BindingFlags.Instance | BindingFlags.NonPublic);
+        var mm = fieldInfo.GetValue(_663Axis.Attitude) as MeanMaintainer<o0.Geometry.Vector<double>>;
+        return mm.Count > 0;
     }
 
     public bool IsMagCompleted() {
-        return MagCalibrater.Complete;
+        return _663Axis.Attitude.MagCalibrater.Complete;
     }
 
     public IEnumerator SaveGyr() {
         yield return null;
-        string mac = LoginMgr.myUserInfo.mac;
-        string record = JsonConvert.SerializeObject(GyrCalibrater);
-        UserPlayer.ins.call("userComp.saveMacCalibrate", 0, mac, record);
+        SaveCalibrateRecord();
     }
 
     public IEnumerator SaveMag() {
         yield return null;
-        string mac = LoginMgr.myUserInfo.mac;
-        string record = JsonConvert.SerializeObject(MagCalibrater, new JsonConverter[]{new MagJsonConverter()});
-        UserPlayer.ins.call("userComp.saveMacCalibrate", 1, mac, record);
+        SaveCalibrateRecord();
     }
 
     public void CalibrateGyr(bool calibration) {
         try {
-            GyrCalibrater.Calibration = calibration;
-            if (calibration)
-            {
-                GyrCalibrationButton.GetComponentInChildren<Text>().text = "停止陀螺仪校准";
-            }
-            else
-            {
-                GyrCalibrationButton.GetComponentInChildren<Text>().text = "开始陀螺仪校准";
-            }
-        } catch (Exception e) { Debug.LogError(e.Message); }
-    }
-
-    [NonSerialized] public bool isCalibrateMagPerfect = false;
-     public void CalibrateMag(bool calibration) {
-        // try {
-        //     if (calibration)
-        //     {
-        //         PointCorrector.ins = new PointCorrector(this.ellipseScript, this.MagCalibrater);
-        //         MagCalibrater.Calibration = calibration;
-        //         MagCalibrationButton.GetComponentInChildren<Text>().text = "停止地磁计校准";
-        //         this.cMaxVector = new Vector3(float.MinValue, float.MinValue, float.MinValue);
-        //         this.cMinVector = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
-        //         this.ellipseScript.ellipseTran.gameObject.SetActive(false);
-        //     }
-        //     else
-        //     {
-        //         PointCorrector.ins = null;
-        //         List<Vector3> list = MagCalibrater.getRecords();
-
-        //         //停止校准时候,看看数组值
-        //         float maxDistance = 0f,ratio = 1f;
-        //         Vector3 maxVector3 = new Vector3(0,0,0);
-        //         List<Vector3> endRecords = new List<Vector3>();
-        //         foreach (Vector3 i in list)
-        //         {
-        //             Vector3 v = i - MagCalibrater._Center;
-        //             if (Math.Abs(v.magnitude) > maxDistance)
-        //             {
-        //                 maxVector3 = v;
-        //                 maxDistance = Math.Abs(v.magnitude);
-        //                 if(Math.Abs(v.magnitude) < Math.Abs(MagCalibrater._Radius.magnitude))
-        //                     ratio = Math.Abs(v.magnitude) / Math.Abs(MagCalibrater._Radius.magnitude);
-        //                 else
-        //                     ratio = Math.Abs(MagCalibrater._Radius.magnitude) / Math.Abs(v.magnitude);
-        //             }
-        //         }
-        //         Debug.LogWarning(maxDistance + " == " + Math.Abs(MagCalibrater._Radius.magnitude) + " == " + MagCalibrater._Radius + " = " + maxVector3);
-        //         //如果比例效果不理想。可以设置为ratio=0.5f 
-        //         foreach (Vector3 i in list)
-        //         {
-        //             //- MagCalibrater._Center
-        //             Vector3 v = i ;
-        //             v *= ratio;
-        //             if(endRecords.Count>3000)
-        //             {
-        //                 endRecords.RemoveAt(0);
-        //             }
-        //             endRecords.Add(v);
-        //         }
-        //         this.ellipseScript.ClearAndUpdatePointArray();
-        //         // this.ellipseScript.DrawPointCloud(endRecords);
-
-        //         MagCalibrater.Calibration = calibration;
-
-        //         this.ellipseScript.ellipseTran.gameObject.SetActive(true);
-        //         //绘制椭圆形
-        //         if (MagCalibrater._Radius != this.ellipseScript.ellipseTran.localScale)
-        //         {
-        //             this.ellipseScript.setEllipseLocalScaleAndCenter(MagCalibrater._Radius, MagCalibrater._Center * ratio);
-        //             //设置绘制图像相机的对应位置
-        //             this.ellipseScript.setCameraPos(MagCalibrater._Center * ratio);
-        //             this.ellipseScript.setCameraSize(MagCalibrater._Radius);
-        //         }
-
-        //         MagCalibrationButton.GetComponentInChildren<Text>().text = "开始地磁计校准";
-        //         PlayerPrefs.SetString("o0MagneticCalibrater", JsonConvert.SerializeObject(MagCalibrater));
-
-        //         #region 看校准是否完美,求Records方差
-        //         if (list == null || list.Count == 0) isCalibrateMagPerfect = false;
-        //         else
-        //         {
-        //             double sumV = 0;
-        //             double[] listArray = new double[list.Count];
-        //             for (int i = 0; i < list.Count; i++)
-        //             {
-        //                 listArray[i] = MagCalibrater.Update(list[i]).magnitude;
-        //                 sumV += listArray[i];
-        //             }
-        //             double avarageV = sumV / listArray.Length;
-        //             double varianceV = 0;
-        //             foreach (double vvv in listArray)
-        //             {
-        //                 varianceV += Math.Pow(vvv - avarageV, 2);
-        //             }
-        //             varianceV /= listArray.Length;
-        //             isCalibrateMagPerfect = varianceV < 0.001;
-        //             PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByKey("tip_mag-calibrate-variance-equal") + varianceV);
-        //         }
-        //         #endregion
-        //     }
-        // } catch (Exception e) { Debug.LogError(e.Message); }
-    }
-
-    //转换读取的数据,无符号->有符号
-    float TwoByteToFloat(byte b1, byte b2) 
-    {
-        ushort twoByte = (ushort) (b1 * 256 + b2);
-        short shortNum = (short) twoByte;
-        return (float) shortNum; 
+            _663Axis.Attitude.GyrCalibrate = calibration;
+        } catch (Exception) {}
     }
 
     public void OnDataReceived(byte[] bytes)
@@ -288,143 +101,31 @@ public class AimHandler : MonoBehaviour
             }
             return;
         }
-        // if (DeviceBatteryView.ins) {
-        //     DeviceBatteryView.ins.labelTemperature.text = (TwoByteToFloat(bytes[5], bytes[6]) / 100).ToString("#0.00") + "℃";
-        // }
-        if (bytes[7] == 0 && bytes[8] == 0 && bytes[9] == 0 && bytes[10] == 0 && bytes[11] == 0 && bytes[12] == 0)
-            return;
-        if (bytes[19] == 0 && bytes[20] == 0 && bytes[21] == 0 && bytes[22] == 0 && bytes[23] == 0 && bytes[24] == 0)
-            return;
 
-       //if (ban9AxisCalculate) //如果箭射出后禁止九轴计算,就缓存最新几帧九轴数据
-       //{
-       //    
-       //    if (cached9AxisFrames.Count < 2)
-       //    {
-       //        cached9AxisFrames.Enqueue(bytes);
-       //    }
-       //    else
-       //    {
-       //        cached9AxisFrames.Dequeue();
-       //        cached9AxisFrames.Enqueue(bytes);
-       //    }
-       //    return;
-       //}
-
-        float ax = TwoByteToFloat(bytes[7], bytes[8]);
-        float ay = TwoByteToFloat(bytes[9], bytes[10]);
-        float az = TwoByteToFloat(bytes[11], bytes[12]);
-
-        float roll = TwoByteToFloat(bytes[13], bytes[14]);
-        float pitch = TwoByteToFloat(bytes[15], bytes[16]);
-        float yaw = TwoByteToFloat(bytes[17], bytes[18]);
-
-        float x = TwoByteToFloat(bytes[19], bytes[20]);
-        float y = TwoByteToFloat(bytes[21], bytes[22]);
-        float z = TwoByteToFloat(bytes[23], bytes[24]);
-
-        float mxr = TwoByteToFloat(bytes[20], bytes[19]);
-        float myr = TwoByteToFloat(bytes[22], bytes[21]);
-        float mzr = TwoByteToFloat(bytes[24], bytes[23]);
-
-        if (CommonConfig.devicePlan == 3) {
-            Acc = new Vector3(az, ay, ax) / 32768 * 16;
-            Gyr = new Vector3(-yaw, -pitch, -roll) / 32768 * 2;
-            Mag = new Vector3(z, y, -x) / 32768 * 256; //最新版
-        } else if (CommonConfig.devicePlan == 0) {
-            Acc = new Vector3(-az, ay, -ax) / 32768 * 16;
-            Gyr = new Vector3(yaw, -pitch, roll) / 32768 * 2;
-            Mag = new Vector3(-z, y, x) / 32768 * 256; //旧版
-        } else if (CommonConfig.devicePlan == 1) {
-            Acc = new Vector3(ax, ay, az) / 32768 * 16;
-            Gyr = new Vector3(roll, pitch, yaw) / 32768 * 2;
-            Mag = new Vector3(z, x, -y) / 32768 * 256;//第一个6+3硬件
-        } else if (CommonConfig.devicePlan == 2) {
-            Acc = new Vector3(-az, ax, -ay) / 32768 * 16;
-            Gyr = new Vector3(-yaw, roll, -pitch) / 32768 * 2;
-            Mag = new Vector3(mzr, mxr, -myr) / 32768 * 256;//第二个6+3硬件
-        } 
-
-        AccObj.transform.GetChild(0).localPosition = Acc;
-
-        Gyr = GyrCalibrater.Update(Gyr);
-
-        if (GyrCalibrater.Calibration) 
+        if (_663Axis.Attitude.GyrCalibrate)
         {
-            if (gyrCalibrateCompleteCount < gyrCalibrateTotalCount) {
+            if (gyrCalibrateCompleteCount < gyrCalibrateTotalCount)
+            {
                 gyrCalibrateCompleteCount++;
             }
         }
-        // if (GyrScaleText && GyrCalibrater.Calibration) 
-        // {   
-        //     // _9Axis.getGyrOld(),states缓存列表没数据时,会报错
-        //     GyrScaleText.text = "" + (_9Axis.getGyrOld() * 1000000).ToString();
-        // }
-
-        // if(Mag.x > -128 && Mag.y > -128 && Mag.z > -128 && Mag.x < 128 && Mag.y < 128 && Mag.z < 128)
-        // {   
-        //     //绘制地磁计点
-        //     if (MagCalibrater.Calibration)
-        //     {
-        //         this.ellipseScript.AddAndUpdatePointArray(Mag);
-
-        //         if (Mag.x > cMaxVector.x) cMaxVector.x = Mag.x;
-        //         if (Mag.y > cMaxVector.y) cMaxVector.y = Mag.y;
-        //         if (Mag.z > cMaxVector.z) cMaxVector.z = Mag.z;
-        //         if (Mag.x < cMinVector.x) cMinVector.x = Mag.x;
-        //         if (Mag.y < cMinVector.y) cMinVector.y = Mag.y;
-        //         if (Mag.z < cMinVector.z) cMinVector.z = Mag.z;
-
-        //         Vector3 centerPoint = (this.cMaxVector + this.cMinVector) / 2;
-
-        //         //设置绘制图像相机的对应位置
-        //         this.ellipseScript.setCameraPos(centerPoint);
-        //         this.ellipseScript.setCameraSize(this.cMaxVector - this.cMinVector);
-
-        //         PointCorrector.ins?.Update(centerPoint);
-        //     }
-        //     Mag = MagCalibrater.Update(Mag);
-
-        //     if (MagScaleText)
-        //     {
-        //         MagScaleText.text = MagCalibrater._Radius.ToString();
-        //     }
-           
-        // }
-        mag0o = UnityVectorTo0o(Mag);
-        try {
-            if (!MagCalibrater.Update(mag0o)) return;
-        } catch(System.Exception) {
-            ResetMag();
-            PopupMgr.ins.ShowTipTop("磁场干扰请远离电子设备");
-            return;
-        }
-        mag0o = MagCalibrater.EllipsoidFitting.Map(mag0o);
-        Mag = o0VectorToUnity(mag0o);
-        MagObj.transform.GetChild(0).localPosition = Mag;
 
-        var ms = (((long)bytes[1]) *60 + bytes[2])*1000 + (long)TwoByteToFloat(bytes[3], bytes[4]);
-        if(msOld == default)
+        o0.Geometry.Quaternion Qua = o0.Geometry.Quaternion.Identity;
+        try
         {
-            msOld = ms;
-            return;
+            lock (_663Axis)
+                Qua = _663Axis.Update(new byte[] { bytes[13], bytes[14], bytes[15], bytes[16], bytes[17], bytes[18] }, 
+                    new byte[] { bytes[25], bytes[26], bytes[27], bytes[28], bytes[29], bytes[30] },
+                    new byte[] { bytes[7], bytes[8], bytes[9], bytes[10], bytes[11], bytes[12] },
+                    new byte[] { bytes[19], bytes[20], bytes[21], bytes[22], bytes[23], bytes[24] },
+                    new byte[] { bytes[31], bytes[32], bytes[33], bytes[34], bytes[35], bytes[36] },
+                    bytes[1], bytes[2], bytes[3], bytes[4]);/**///双陀螺仪
         }
-        TimeGap = ms - msOld;
-        msOld = ms;
-
-        GapMs = TimeGap;
-        gyr0o = UnityVectorTo0o(Gyr);
-        acc0o = UnityVectorTo0o(Acc);
-        
-        distanceToAxis.Update(gyr0o, acc0o, mag0o, GapMs);
-        acc0o = distanceToAxis.AccCorrection(gyr0o, acc0o, GapMs);/**///轴心偏离矫正
-        Acc = o0VectorToUnity(acc0o);
-
-        var GyrOperator = new Quaternion();
-        GyrOperator.eulerAngles = Gyr * TimeGap;
-        GryMesh.transform.localRotation *= GyrOperator;
-
-        AMesh.transform.localRotation = newRotation = _9Axis.update(Acc, Gyr, Mag, TimeGap);
+        catch (Exception e) {
+            Debug.LogError(e.Message);
+            Debug.LogError(e.StackTrace);
+        }
+        newRotation = o0.Bow.Extension.ToUnityQuaternion(Qua);
 
         if (BowQuatDebug.ins) BowQuatDebug.ins.ShowModuleQuat(newRotation.eulerAngles);
 
@@ -433,21 +134,9 @@ public class AimHandler : MonoBehaviour
         }
     }
 
-    o0.Bow.DistanceToAxis distanceToAxis = new o0.Bow.DistanceToAxis();
-    double GapMs;
-    o0.Geometry.Vector<double> gyr0o;
-    o0.Geometry.Vector<double> acc0o;
-    o0.Geometry.Vector<double> mag0o;
-    o0.Geometry.Vector<double> UnityVectorTo0o(Vector3 src) {
-        return new o0.Geometry.Vector<double>(double.Parse(src.x.ToString()), double.Parse(src.y.ToString()), double.Parse(src.z.ToString()));
-    }
-    Vector3 o0VectorToUnity(o0.Geometry.Vector<double> src) {
-        return new Vector3(float.Parse(src.x.ToString()), float.Parse(src.y.ToString()), float.Parse(src.z.ToString()));
-    }
-
     [NonSerialized] public bool lerpForRotation = true;
     [NonSerialized] public float lerpTimeRate = 7;
-    public void Update()
+    void Update()
     {
         if (controlObj && !ban9AxisCalculate)
         {
@@ -472,43 +161,316 @@ public class AimHandler : MonoBehaviour
     bool magComplete;
 
     private bool ban9AxisCalculate = false;
-    private Queue<byte[]> cached9AxisFrames = new Queue<byte[]>();
     public void Ban9AxisCalculate(bool ban) {
         ban9AxisCalculate = ban;
-        if (!ban) {
-            msOld = default;
-            // try
-            // {
-            //     if (StatesBackDebug.ins) _9Axis.DeleteStatesFromTail(StatesBackDebug.ins.val);
-            // }
-            // catch (Exception) { }
-            //恢复九轴计算时,把缓存的最新几帧计算了
-            // bool isFirstFrame = true;
-            while (cached9AxisFrames.Count > 0)
-            {
-                try
-                {
-                    OnDataReceived(cached9AxisFrames.Dequeue());
-                    //最初的一帧是用来顶掉msOld的,不会进state数组,因此不需要设置方差
-                    // if (!isFirstFrame) {
-                    //     _9Axis.SetAccMagVariance(10000);
-                    // }
-                    // isFirstFrame = false;
-                }
-                catch (Exception) { }
-            }
-            //立马应用到控制物体中
-            if (controlObj) controlObj.localRotation = newRotation;
-        }
     }
 
     [NonSerialized] public Quaternion newRotation = Quaternion.identity;
 
     public void DoIdentity()
     {
-        _9Axis.SetIdentityAndSave();
-        Quaternion qua = _9Axis.getLastState().Qua;
+        _663Axis.SetIdentityAndSave();
+        Quaternion qua = o0.Bow.Extension.ToUnityQuaternion(_663Axis.getLastState().Qua);
         newRotation = qua;
         if (controlObj) controlObj.localRotation = qua;
     }
-}
+    
+    public void OnShot()
+    {
+        _663Axis.OnShot(100, 100, 100000);
+    }
+
+    private o0.Bow.o0663Axis _663Axis;
+    /*
+    public o0.Geometry.Vector<int> GyrByteIndex = new o0.Geometry.Vector<int>(3, -2, 1);
+    public o0.Geometry.Vector<int> AccByteIndex = new o0.Geometry.Vector<int>(3, -2, 1);
+    public o0.Geometry.Vector<int> MagByteIndex = new o0.Geometry.Vector<int>(-3, 2, 1);/**///9轴 usb向上 pcb向左 电池向右
+    /*
+    public o0.Geometry.Vector<int> GyrByteIndex = new o0.Geometry.Vector<int>(-3, -2, -1);
+    public o0.Geometry.Vector<int> AccByteIndex = new o0.Geometry.Vector<int>(-3, -2, -1);
+    public o0.Geometry.Vector<int> MagByteIndex = new o0.Geometry.Vector<int>(3, 2, -1);/**///9轴 usb向上 pcb向右 电池向左
+    public o0.Geometry.Vector<int> GyrByteIndex = new o0.Geometry.Vector<int>(-3, -2, -1);
+    public o0.Geometry.Vector<int> AccByteIndex = new o0.Geometry.Vector<int>(-3, -2, -1);
+    public o0.Geometry.Vector<int> MagByteIndex = new o0.Geometry.Vector<int>(-3, -1, 2);/**///双陀螺仪 usb向上 pcb向右 电池向右
+
+    private void Init()
+    {
+        _663Axis = new o0.Bow.o0663Axis(GyrByteIndex, GyrByteIndex, AccByteIndex, AccByteIndex, MagByteIndex);
+        _663Axis.Attitude = new o0.IMU._663AxisPreProcessor(GyrByteIndex, GyrByteIndex, AccByteIndex, AccByteIndex, MagByteIndex);
+        _663Axis.LoadIdentity();
+        // StartCoroutine(Test());
+    }
+
+    IEnumerator Test() {
+        while (LoginMgr.myUserInfo.id == 0) yield return null;
+        UserComp.Instance.saveMac2();
+    }
+
+    public void ResumeCalibrateRecord(string record) 
+    {
+        try
+        {
+            Json.FromJson<o0.IMU._663AxisPreProcessor>(record, ref _663Axis.Attitude);
+            Debug.Log("663轴数据恢复成功" + ", MagComplete" + _663Axis.Attitude.MagCalibrater.Complete);
+        }
+        catch (Exception e)
+        {
+            Debug.LogError(e.Message);
+            Debug.LogError(e.StackTrace);
+        }
+        magComplete = _663Axis.Attitude.MagCalibrater.Complete;
+    }
+
+    public void SaveCalibrateRecord() 
+    {
+        try
+        {
+            string record = JsonConvert.SerializeObject(_663Axis.Attitude);
+            if (!string.IsNullOrEmpty(record))
+            {
+                Debug.Log("663轴数据序列化成功");
+                UserComp.Instance.saveCalibrateRecord(record);
+            }
+        }
+        catch (Exception e)
+        {
+            Debug.LogError(e.Message);
+            Debug.LogError(e.StackTrace);
+        }
+    }
+
+    public const int DeviceType = 663;
+}
+
+// /* 瞄准处理器 */
+// public class AimHandler : MonoBehaviour
+// {
+//     Transform controlObj {
+//         get {
+//             if (CameraToLook.ins) {
+//                 return CameraToLook.ins.transform;
+//             }
+//             return null;
+//         }
+//     }
+
+//     //陀螺仪校准进度记录
+//     [NonSerialized] public int gyrCalibrateCompleteCount = 0;
+//     [NonSerialized] public int gyrCalibrateTotalCount = 2000;
+
+//     public static AimHandler ins; 
+
+//     void Start()
+//     {
+//         ins = this;
+//         BluetoothDispatcher.aim = OnDataReceived;
+
+//         //初始化
+//         Init();
+//     }
+
+//     public void ResetGyr() {
+//         _9Axis.Attitude.GyrCalibrate = true;
+//         _9Axis.Attitude.GyrCalibrate = false;
+//     }
+
+//     public void ResetMag() {
+//         _9Axis.Attitude.MagCalibrater = new o0.IMU.MagnetometerAutoCalibrater();
+//     }
+
+//     public bool IsGyrCompleted() {
+//         FieldInfo fieldInfo = _9Axis.Attitude.GetType().GetField("GyrCalibrater", BindingFlags.Instance | BindingFlags.NonPublic);
+//         var mm = fieldInfo.GetValue(_9Axis.Attitude) as MeanMaintainer<o0.Geometry.Vector<double>>;
+//         return mm.Count > 0;
+//     }
+
+//     public bool IsMagCompleted() {
+//         return _9Axis.Attitude.MagCalibrater.Complete;
+//     }
+
+//     public IEnumerator SaveGyr() {
+//         yield return null;
+//         SaveCalibrateRecord();
+//     }
+
+//     public IEnumerator SaveMag() {
+//         yield return null;
+//         SaveCalibrateRecord();
+//     }
+
+//     public void CalibrateGyr(bool calibration) {
+//         try {
+//             _9Axis.Attitude.GyrCalibrate = calibration;
+//         } catch (Exception) {}
+//     }
+
+//     public void OnDataReceived(byte[] bytes)
+//     {
+//         // Debug.Log("瞄准模块数据长度" + bytes.Length);
+//         if (bytes.Length != 27)
+//         {
+//             if (bytes.Length == 2) {
+//                 if (bytes[0] == 0x66 && bytes[1] == 0x31) {
+//                     if (SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked) {
+//                         //视角回正
+//                         DoIdentity();
+//                         //鼠标居中自然会居中
+//                     } else {
+//                         AutoResetView.DoIdentity();
+//                     }
+//                 } else if (bytes[0] == 0x66 && bytes[1] == 0x32) {
+//                     if (SB_EventSystem.ins) {
+//                     // if (SB_EventSystem.ins && !CommonConfig.SpecialVersion1) {
+//                         //唤起/隐藏虚拟鼠标
+//                         SB_EventSystem.ins.AwakenSimulateMouse(); 
+//                     }
+//                 } else if (bytes[1] == 10) {
+//                     //显示电量
+//                     DeviceBatteryView.ins.RenderBattery(1, bytes[0]); 
+//                 }
+//             } else if (bytes[0] == 0x5b) {
+//                 //红外射击检测
+//                 ShootCheck.ins.ShootByInfrared(bytes); 
+//             }
+//             return;
+//         }
+
+//         if (_9Axis.Attitude.GyrCalibrate)
+//         {
+//             if (gyrCalibrateCompleteCount < gyrCalibrateTotalCount)
+//             {
+//                 gyrCalibrateCompleteCount++;
+//             }
+//         }
+
+//         o0.Geometry.Quaternion Qua = o0.Geometry.Quaternion.Identity;
+//         try
+//         {
+//             lock (_9Axis)
+//                 Qua = _9Axis.Update(new byte[] { bytes[13], bytes[14], bytes[15], bytes[16], bytes[17], bytes[18] },
+//                     new byte[] { bytes[7], bytes[8], bytes[9], bytes[10], bytes[11], bytes[12] },
+//                     new byte[] { bytes[19], bytes[20], bytes[21], bytes[22], bytes[23], bytes[24] },
+//                     bytes[1], bytes[2], bytes[3], bytes[4]);/**///9轴
+//         }
+//         catch (Exception e) {
+//             Debug.LogError(e.Message);
+//             Debug.LogError(e.StackTrace);
+//         }
+//         newRotation = o0.Bow.Extension.ToUnityQuaternion(Qua);
+
+//         if (BowQuatDebug.ins) BowQuatDebug.ins.ShowModuleQuat(newRotation.eulerAngles);
+
+//         if (SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked) {
+//             SB_EventSystem.ins.MoveSimulateMouse(newRotation);
+//         }
+//     }
+
+//     [NonSerialized] public bool lerpForRotation = true;
+//     [NonSerialized] public float lerpTimeRate = 7;
+//     void Update()
+//     {
+//         if (controlObj && !ban9AxisCalculate)
+//         {
+//             if (lerpForRotation)
+//             {
+//                 controlObj.localRotation = Quaternion.Lerp(controlObj.localRotation, newRotation, Time.deltaTime * lerpTimeRate);   
+//             } 
+//             else 
+//             {
+//                 controlObj.localRotation = newRotation;
+//             }
+//         }
+//         _magCompleteTemp = IsMagCompleted();
+//         if (!magComplete && _magCompleteTemp) {
+//             StartCoroutine(SaveMag());
+//             PopupMgr.ins.ShowTipTop(TextAutoLanguage2.GetTextByKey("tip_mag-calibrate_success"));
+//         }
+//         magComplete = _magCompleteTemp;
+//     }
+
+//     bool _magCompleteTemp;
+//     bool magComplete;
+
+//     private bool ban9AxisCalculate = false;
+//     public void Ban9AxisCalculate(bool ban) {
+//         ban9AxisCalculate = ban;
+//     }
+
+//     [NonSerialized] public Quaternion newRotation = Quaternion.identity;
+
+//     public void DoIdentity()
+//     {
+//         _9Axis.SetIdentityAndSave();
+//         Quaternion qua = o0.Bow.Extension.ToUnityQuaternion(_9Axis.getLastState().Qua);
+//         newRotation = qua;
+//         if (controlObj) controlObj.localRotation = qua;
+//     }
+    
+//     public void OnShot()
+//     {
+//         _9Axis.OnShot(100, 100, 100000);
+//     }
+
+//     private o0.Bow.o09AxisAfterXiaMenFromDll _9Axis;
+//     /*
+//     public o0.Geometry.Vector<int> GyrByteIndex = new o0.Geometry.Vector<int>(3, -2, 1);
+//     public o0.Geometry.Vector<int> AccByteIndex = new o0.Geometry.Vector<int>(3, -2, 1);
+//     public o0.Geometry.Vector<int> MagByteIndex = new o0.Geometry.Vector<int>(-3, 2, 1);/**///9轴 usb向上 pcb向左 电池向右
+//     public o0.Geometry.Vector<int> GyrByteIndex = new o0.Geometry.Vector<int>(-3, -2, -1);
+//     public o0.Geometry.Vector<int> AccByteIndex = new o0.Geometry.Vector<int>(-3, -2, -1);
+//     public o0.Geometry.Vector<int> MagByteIndex = new o0.Geometry.Vector<int>(3, 2, -1);/**///9轴 usb向上 pcb向右 电池向左
+//     /*
+//     public o0.Geometry.Vector<int> GyrByteIndex = new o0.Geometry.Vector<int>(-3, -2, -1);
+//     public o0.Geometry.Vector<int> AccByteIndex = new o0.Geometry.Vector<int>(-3, -2, -1);
+//     public o0.Geometry.Vector<int> MagByteIndex = new o0.Geometry.Vector<int>(-3, -1, 2);/**///双陀螺仪 usb向上 pcb向右 电池向右
+//     //public static o0.Bow.o0663Axis _663Axis;
+//     //public static o0.Bow.o09AxisFromDll _9Axis;
+
+//     private void Init()
+//     {
+//         _9Axis = new o0.Bow.o09AxisAfterXiaMenFromDll(GyrByteIndex, AccByteIndex, MagByteIndex);
+//         _9Axis.Attitude = new o0.IMU._9AxisPreProcessor(GyrByteIndex, AccByteIndex, MagByteIndex);
+//         _9Axis.LoadIdentity();
+//         // StartCoroutine(Test());
+//     }
+
+//     IEnumerator Test() {
+//         while (LoginMgr.myUserInfo.id == 0) yield return null;
+//         UserComp.Instance.saveMac2();
+//     }
+
+//     public void ResumeCalibrateRecord(string record) 
+//     {
+//         try
+//         {
+//             Json.FromJson<o0.IMU._9AxisPreProcessor>(record, ref _9Axis.Attitude);
+//             Debug.Log("9轴数据恢复成功" + ", MagComplete" + _9Axis.Attitude.MagCalibrater.Complete);
+//         }
+//         catch (Exception e)
+//         {
+//             Debug.LogError(e.Message);
+//             Debug.LogError(e.StackTrace);
+//         }
+//         magComplete = _9Axis.Attitude.MagCalibrater.Complete;
+//     }
+
+//     public void SaveCalibrateRecord() 
+//     {
+//         try
+//         {
+//             string record = JsonConvert.SerializeObject(_9Axis.Attitude);
+//             if (!string.IsNullOrEmpty(record))
+//             {
+//                 Debug.Log("9轴数据序列化成功");
+//                 UserComp.Instance.saveCalibrateRecord(record);
+//             }
+//         }
+//         catch (Exception e)
+//         {
+//             Debug.LogError(e.Message);
+//             Debug.LogError(e.StackTrace);
+//         }
+//     }
+
+//     public const int DeviceType = 9;
+// }

+ 1 - 28
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -108,7 +108,6 @@ public class BluetoothAim : MonoBehaviour
         SetStatus(BluetoothStatusEnum.ConnectFail);
         BowCamera.isTouchMode = true;
         DestroyWhenDisconenct();
-        if (AimHandler.ins) AimHandler.ins.msOld = default;
     }
 
     void Update()
@@ -550,7 +549,7 @@ public class BluetoothAim : MonoBehaviour
         if (mac != null) mac = mac.Trim();
         if (CheckIsMacValid(mac)) {
             LoginMgr.myUserInfo.mac = mac;
-            SaveMac(mac);
+            UserComp.Instance.saveMac2();
         }
     }
 
@@ -565,30 +564,4 @@ public class BluetoothAim : MonoBehaviour
         }
         return true;
     }
-
-    void SaveMac(string mac) {
-        Action<Newtonsoft.Json.Linq.JToken> cb = (Newtonsoft.Json.Linq.JToken o) => {
-            string gyrStr = o.Value<string>("gyr");
-            string magStr = o.Value<string>("mag");
-            AimHandler.ins.InitGyr(gyrStr);
-            AimHandler.ins.InitMag(magStr);
-        };
-        UserPlayer.ins.call("userComp.saveMac", new object[]{mac}, cb);
-    }
-
-    // #region 测试mac获取服务端校准记录
-    // void Awake()
-    // {
-    //     StartCoroutine(qqq());
-    // }
-
-    // System.Collections.IEnumerator qqq() {
-    //     while (LoginMgr.myUserInfo.id == 0) {
-    //         yield return null;
-    //     }
-    //     SaveMac("123");
-    //     StartCoroutine(AimHandler.ins.SaveGyr());
-    //     StartCoroutine(AimHandler.ins.SaveMag());
-    // }
-    // #endregion
 }

+ 0 - 65
Assets/BowArrow/Scripts/Bluetooth/MagJsonConvert.cs

@@ -1,65 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using o0._9Axis;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using MathNet.Numerics.LinearAlgebra;
-
-public class MagJsonConvert
-{
-    public static MagnetometerAutoCalibrater Parse(string jsonStr)
-    {
-        JObject jo = JObject.Parse(jsonStr);
-        jo.Remove("Complete");
-        JToken jt_e = jo.GetValue("EllipsoidFitting");
-        jo.Remove("EllipsoidFitting");
-        JToken jt_v = jo.GetValue("VectorByBlock");
-        jo.Remove("VectorByBlock");
-        int FitCountLeft = jo.GetValue("FitCountLeft").Value<int>();
-        jo.Remove("FitCountLeft");
-        MagnetometerAutoCalibrater calibrater = jo.ToObject<MagnetometerAutoCalibrater>();
-        calibrater.FitCountLeft = FitCountLeft;
-        calibrater.EllipsoidFitting = ToEllipsoidFitting(jt_e);
-        foreach (JProperty item in jt_v)
-        {
-            calibrater.VectorByBlock[ToVectorInt(JArray.Parse(item.Name))] = ToVectorDouble(item.Value as JArray);    
-        }
-        return calibrater;
-    }
-
-    public static string ToJson(MagnetometerAutoCalibrater calibrater)
-    {
-        return JsonConvert.SerializeObject(calibrater);
-    }
-
-    private static EllipsoidFitting ToEllipsoidFitting(JToken jToken) 
-    {
-        var Center = ToVectorDouble(jToken["Center"] as JArray);
-        var CorrectMatrix = ToMatrixDouble(jToken["CorrectMatrixArray"] as JArray);
-        var Radius = ToVectorDouble(jToken["Radius"] as JArray);
-        return new EllipsoidFitting(Center, CorrectMatrix, Radius);
-    }
-
-    private static Matrix<double> ToMatrixDouble(JArray arr) 
-    {
-        int rcCount = arr.Count;
-        Matrix<double> matrix = CreateMatrix.Dense<double>(rcCount, rcCount);
-        for (var i = 0; i < rcCount; ++i)
-            for (var j = 0; j < rcCount; ++j)
-                matrix[i, j] = arr[i][j].Value<double>();
-        return matrix;
-    }
-
-    private static o0.Geometry.Vector<double> ToVectorDouble(JArray arr) 
-    {
-        return new o0.Geometry.Vector<double>(
-            arr[0].Value<double>(), arr[1].Value<double>(), arr[2].Value<double>());
-    }
-
-    private static o0.Geometry.Vector<int> ToVectorInt(JArray arr) 
-    {
-        return new o0.Geometry.Vector<int>(
-            arr[0].Value<int>(), arr[1].Value<int>(), arr[2].Value<int>());
-    }
-}

+ 2 - 1
Assets/Plugins/o0Lib/o0NetLib.pdb.meta → Assets/BowArrow/Scripts/Bluetooth/New.meta

@@ -1,5 +1,6 @@
 fileFormatVersion: 2
-guid: 6515bc2df92dd2e4c958a41349db743d
+guid: 4aad3da9a9b630e43b19cc3449ae80eb
+folderAsset: yes
 DefaultImporter:
   externalObjects: {}
   userData: 

+ 291 - 0
Assets/BowArrow/Scripts/Bluetooth/New/o0663Axis.cs

@@ -0,0 +1,291 @@
+using o0.Geometry;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using Newtonsoft.Json;
+
+namespace o0.Bow
+{
+    public class o0663Axis
+    {
+        public IMU._663AxisPreProcessor Attitude;
+
+        public static List<UnityEngine.Quaternion> QuaTest = new List<UnityEngine.Quaternion>();
+        public o0663Axis(Vector<int> Gyr1ByteIndex = default, Vector<int> Gyr2ByteIndex = default, Vector<int> Acc1ByteIndex = default, Vector<int> Acc2ByteIndex = default, Vector<int> MagByteIndex = default)
+        {
+            Attitude = new IMU._663AxisPreProcessor(Gyr1ByteIndex, Gyr2ByteIndex, Acc1ByteIndex, Acc2ByteIndex, MagByteIndex);
+
+            QuaTest.Add(UnityEngine.Quaternion.identity);
+            QuaTest.Add(UnityEngine.Quaternion.identity);
+        }
+
+        static public Vector<double> AccIdentity = new Vector<double>(0, -1, 0);
+        static public Vector<double> MagIdentity = new Vector<double>(-1, 2, 0).Normalized;
+        public class State
+        {
+            public double TimeGap;
+            public Vector<double> Acc = AccIdentity;
+            public Vector<double> AccSmooth = AccIdentity;
+
+            public Vector<double> Gyr;
+            public Vector<double> Mag = MagIdentity;
+            public Vector<double> MagSmooth = MagIdentity;
+
+            public double GapMS;
+
+            public Geometry.Quaternion Qua = Geometry.Quaternion.Identity;
+            public Geometry.Quaternion QuaSmooth = Geometry.Quaternion.Identity;
+            public double Variance = 1;
+            public double GyrVariance = 1;
+            public double AccVariance = 1;
+            public double MagVariance = 1;
+            public Geometry.Quaternion QuaAccMag = Geometry.Quaternion.Identity;
+            public int QuaAccMagCount = 0;
+            public double AccMagVariance = 1;
+            public double TotalVariance = 1;
+        }
+
+
+        public List<State> States = new List<State>();
+        public int StatesMaxCount = 1000;
+
+        public float x;
+        public float y;
+        public float z;
+
+        long TimeGapOld;
+
+        double lastv = default;
+        public Geometry.Quaternion Update(IEnumerable<byte> gyr1Byte, IEnumerable<byte> gyr2Byte, IEnumerable<byte> acc1Byte, IEnumerable<byte> acc2Byte, IEnumerable<byte> magByte,
+            byte min, byte sec, byte ms1, byte ms2)
+        {
+            if(lastv != Attitude.MagCalibrater?.Variance)
+            {
+                lastv = Attitude.MagCalibrater?.Variance ?? default;
+                Debug.Log(lastv);
+            }
+            var (Gyr, Acc, Mag, TimeGap) = Attitude.Update(gyr1Byte, gyr2Byte, acc1Byte, acc2Byte, magByte, min, sec, ms1, ms2);
+
+
+            var GyrOperator = Geometry.Quaternion.Euler(Gyr * TimeGap);
+
+
+            var Last = States.LastOrDefault() ?? new State();
+            States.Add(new State());
+            if (States.Count > StatesMaxCount)
+                States.RemoveAt(0);
+            var state = States.Last();
+            state.Acc = Acc;
+
+
+            //Debug.Log(Gyr.magnitude);
+
+            state.Gyr = Gyr;
+            state.Mag = Mag;/**/
+            state.TimeGap = TimeGap;
+            if (States.Count <= 1)
+                return Geometry.Quaternion.Identity;
+            return Process9Axis(Last, state);
+        }
+        int ShakeFrame;
+        int AccVarianceInput;
+        /// //////////////////向前追溯多少帧//向后多少帧计算抖动
+        public void OnShot(int TrackBack, int ShakeFrame, int AccVarianceInput)
+        {
+            this.AccVarianceInput = AccVarianceInput;
+            TrackBack = Math.Min(TrackBack, States.Count);
+            var startI = States.Count - TrackBack;
+            State Last = default;
+            foreach (var i in TrackBack.Range())
+            {
+                var state = States[startI + i];
+
+                if (Last != default)
+                    Process9Axis(Last, state);
+                Last = state;
+            }
+
+            this.ShakeFrame = ShakeFrame;
+            Debug.Log("OnShot");/**/
+        }
+        public double diff = 0.001;
+        public Geometry.Quaternion Process9Axis(State Last, State state)
+        {
+            var Acc = state.Acc;
+            var Gyr = state.Gyr;
+            var Mag = state.Mag;
+            double TimeGap = state.TimeGap;
+
+            o0UIRawImageTester.UpdateAllOffset();
+
+
+            var LastQuaternion = Last.Qua;
+
+
+
+            var GyrOperator = Geometry.Quaternion.Euler(Gyr * TimeGap);
+            var quaGyr = LastQuaternion * GyrOperator;
+
+
+            //TestVector.Update9AxisRotation(GyrOperator, 1);
+            //TestVector.SetAcc(Acc / 10, 1);
+            //TestVector.SetMag(Mag, 1);
+            var accTest = Geometry.Quaternion.FromToRotation(Last.Acc, Acc).Inversed;
+            var magTest = Geometry.Quaternion.FromToRotation(Last.Mag, Mag).Inversed;
+            //TestVector.Set9AxisRotation(Last.Qua, 3);
+
+            double AccLengthToAngle = 5;//1倍引力差相当于多少度方差
+            double MagLengthToAngle = 5;//1倍磁力差相当于多少度方差
+
+            double GyrVariance = Last.Variance + Math.Pow((Gyr * TimeGap).Length * 0.3, 3) + diff;// 指数4 = 方差2 * 欧拉角旋转误差2     移动导致累计误差
+
+            //double GyrVariance = Last.Variance + Math.Pow((Gyr * TimeGap).magnitude * 0.3, 3) + 0.1;// 指数4 = 方差2 * 欧拉角旋转误差2     移动导致累计误差
+            //    Debug.Log("GyrVariance==" + GyrVariance);
+            double AccVariance = AccVarianceInput != default ? AccVarianceInput : Math.Max((Gyr * TimeGap).Length, state.Acc.Angle(Last.Acc)) * 1 + Math.Pow(Math.Abs(state.Acc.Length - 1) / 1 * AccLengthToAngle, 4);
+            double MagVariance = 10 + Math.Pow(Math.Abs(state.Mag.Length - 1) / 1 * MagLengthToAngle, 4);/**/
+
+
+
+            if (double.IsInfinity(GyrVariance))
+                GyrVariance = double.MinValue;
+            if (double.IsNaN(GyrVariance))
+                GyrVariance = double.MinValue;
+            if (double.IsNaN(AccVariance))
+                AccVariance = double.MinValue;
+            if (double.IsNaN(MagVariance))
+                MagVariance = double.MinValue;
+
+            state.Variance = GyrVariance;
+            state.Variance = state.Variance * (AccVariance + MagVariance) / (state.Variance + (AccVariance + MagVariance));
+
+
+            if (double.IsNaN(state.Variance))
+                state.Variance = double.MinValue;
+
+            var quaAccMag = Geometry.Quaternion.FormQuaternion(AccIdentity, MagIdentity, state.Acc, state.Mag, (float)(AccVariance / (AccVariance + MagVariance)));
+            var quaMinRate = GyrVariance / (GyrVariance + Math.Max(AccVariance, MagVariance));
+            var quaMaxRate = GyrVariance / (GyrVariance + Math.Min(AccVariance, MagVariance));
+            Geometry.Quaternion quaFirst = Geometry.Quaternion.SLerp(quaGyr, quaAccMag, (float)quaMinRate);
+            if (double.IsNaN(quaFirst.w))
+                quaFirst = Last.Qua;
+
+            var quaSecondRate = (quaMaxRate - quaMinRate) / (1 - quaMinRate);
+
+            state.Qua = AccVariance < MagVariance ? Geometry.Quaternion.FormQuaternion(quaFirst, AccIdentity, state.Acc, (float)quaSecondRate) : Geometry.Quaternion.FormQuaternion(quaFirst, MagIdentity, state.Mag, (float)quaSecondRate);
+
+
+
+
+            ///////////////////////////////////////////////////////////////
+
+            if (double.IsNaN(state.Qua.w))
+                state.Qua = Last.Qua;/**/
+            state.QuaSmooth = Geometry.Quaternion.SLerp(Last.QuaSmooth, state.Qua, 0.3f);//Last.QuaSmooth - state.Qua    0 - 1
+
+
+            //QuaTest[0] = o0Project.o0.FormQuaternion(QuaTest[0] * GyrOperator, AccIdentity, state.AccSmooth, 1);
+            // QuaTest[0] = Geometry.Quaternion.FormQuaternion(AccIdentity, MagIdentity, state.AccSmooth, state.MagSmooth, (float)(AccVariance / (AccVariance + MagVariance))).ToUnityQuaternion();
+            // QuaTest[1] = state.QuaAccMag.ToUnityQuaternion();
+            //QuaTest[1] = o0Project.o0.FormQuaternion(QuaTest[1] * GyrOperator, MagIdentity, state.MagSmooth, 1);
+            //Debug.Log(o09AxisCS.QuaTest[0]);
+
+            if (ShakeFrame > 0)
+            {
+                --ShakeFrame;
+                if (ShakeFrame == 0)
+                    AccVarianceInput = default;
+            }
+            return state.QuaSmooth;
+        }
+
+        public void Init()
+        {
+            States.Last().AccVariance = 1000;
+            States.Last().GyrVariance = 1000;
+            States.Last().MagVariance = 1000;
+            States.Last().AccMagVariance = 1000;
+            States.Last().TotalVariance = 1000;
+        }
+        public Geometry.Quaternion SetIdentity()
+        {
+            //UnityEngine.Quaternion qua = default;
+
+            //int averageCount = Math.Min(States.Count, 5);
+            int averageCount = Math.Min(States.Count, 50);
+            Vector<double> aveAcc = Vector<double>.Zero;
+            Vector<double> aveMag = Vector<double>.Zero;
+            for (var i = States.Count - averageCount; i < States.Count; ++i)
+            {
+                aveAcc += States[i].Acc;
+                aveMag += States[i].Mag;
+            }
+            aveAcc /= averageCount;
+            aveMag /= averageCount;
+            //AccIdentity = AccOld;
+            //MagIdentity = MagOld;
+            AccIdentity = aveAcc;
+            MagIdentity = aveMag;
+            //qua = o0Project.o0.FormQuaternion(Quaternion.identity, Vector3.down,AccIdentity, 1);
+            //AccIdentity=qua*AccIdentity;
+            //MagIdentity = qua*MagIdentity;
+            States.Last().Qua = Geometry.Quaternion.Identity;
+            States.Last().QuaSmooth = Geometry.Quaternion.Identity;
+            //States.Last().Qua = qua*States.Last().Qua;//Quaternion.identity;
+            States.Last().Variance = 0.0000001;
+            States.Last().AccVariance = 0.0000001;
+            States.Last().GyrVariance = 0.0000001;
+            States.Last().MagVariance = 0.0000001;
+            States.Last().QuaAccMag = Geometry.Quaternion.Identity;
+            States.Last().QuaAccMagCount = 0;
+            States.Last().AccMagVariance = 0.0000001;
+            States.Last().TotalVariance = 0.0000001;
+
+
+            return States.Last().Qua;
+        }
+
+        public State getLastState()
+        {
+            return this.States.Last();
+        }
+
+        public void LoadIdentity() 
+        {
+            try {
+                string magIdentityStr = PlayerPrefs.GetString("MagIdentity", "");
+                if (magIdentityStr.Length > 0) {
+                    double[] arr = JsonConvert.DeserializeObject<double[]>(magIdentityStr);
+                    AccIdentity = new Vector<double>(arr[0], arr[1], arr[2]);
+                }
+                string accIdentityStr = PlayerPrefs.GetString("AccIdentity", "");
+                if (accIdentityStr.Length > 0) {
+                    double[] arr = JsonConvert.DeserializeObject<double[]>(accIdentityStr);
+                    MagIdentity = new Vector<double>(arr[0], arr[1], arr[2]);
+                }
+            } catch (System.Exception e) { 
+                Debug.LogError(e.Message);
+                Debug.LogError(e.StackTrace); 
+            }
+        }
+
+        public void SetIdentityAndSave()
+        {
+            SetIdentity();
+            SaveIdentity();
+        }
+        
+        private void SaveIdentity() {
+            Vector<double> m = MagIdentity;
+            Vector<double> a = AccIdentity;
+            PlayerPrefs.SetString("MagIdentity",JsonConvert.SerializeObject(new double[]{
+                m.x, m.y, m.z
+            }));
+            PlayerPrefs.SetString("AccIdentity", JsonConvert.SerializeObject(new double[]{
+                a.x, a.y, a.z
+            }));
+        }
+
+    }
+
+}

+ 1 - 1
Assets/BowArrow/Scripts/Bluetooth/MagJsonConvert.cs.meta → Assets/BowArrow/Scripts/Bluetooth/New/o0663Axis.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: d14196d04be3a1446966fb1aaa5a1b04
+guid: 2495f42154b3fe643b04272e9bd62058
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 296 - 0
Assets/BowArrow/Scripts/Bluetooth/New/o09AxisAfterXiaMenFromDll.cs

@@ -0,0 +1,296 @@
+using o0.Geometry;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using Newtonsoft.Json;
+
+
+namespace o0.Bow
+{
+    public class o09AxisAfterXiaMenFromDll
+    {
+        public IMU._9AxisPreProcessor Attitude;
+        public IMU.HardwareVariance GyrHardwareVariance;
+        public IMU.HardwareVariance AccHardwareVariance;
+        public IMU.HardwareVariance MagHardwareVariance;
+
+        public static List<UnityEngine.Quaternion> QuaTest = new List<UnityEngine.Quaternion>();
+        public o09AxisAfterXiaMenFromDll(Vector<int> GyrByteIndex = default, Vector<int> AccByteIndex = default, Vector<int> MagByteIndex = default)
+        {
+            Attitude = new IMU._9AxisPreProcessor(GyrByteIndex, AccByteIndex, MagByteIndex);
+            GyrHardwareVariance = new IMU.HardwareVariance();
+            AccHardwareVariance = new IMU.HardwareVariance();
+            MagHardwareVariance = new IMU.HardwareVariance();
+
+            QuaTest.Add(UnityEngine.Quaternion.identity);
+            QuaTest.Add(UnityEngine.Quaternion.identity);
+        }
+
+        static public Vector<double> AccIdentity = new Vector<double>(0, -1, 0);
+        static public Vector<double> MagIdentity = new Vector<double>(-1, 2, 0).Normalized;
+        public class State
+        {
+            public double TimeGap;
+            public Vector<double> Acc = AccIdentity;
+            public Vector<double> AccSmooth = AccIdentity;
+
+            public Vector<double> Gyr;
+            public Vector<double> Mag = MagIdentity;
+            public Vector<double> MagSmooth = MagIdentity;
+
+            public double GapMS;
+
+            public Geometry.Quaternion Qua = Geometry.Quaternion.Identity;
+            public Geometry.Quaternion QuaSmooth = Geometry.Quaternion.Identity;
+            public double Variance = 1;
+            public double GyrVariance = 1;
+            public double AccVariance = 1;
+            public double MagVariance = 1;
+            public Geometry.Quaternion QuaAccMag = Geometry.Quaternion.Identity;
+            public int QuaAccMagCount = 0;
+            public double AccMagVariance = 1;
+            public double TotalVariance = 1;
+        }
+
+
+        public List<State> States = new List<State>();
+        public int StatesMaxCount = 1000;
+
+
+        public Geometry.Quaternion Update(IEnumerable<byte> gyrByte, IEnumerable<byte> accByte, IEnumerable<byte> magByte,
+            byte min, byte sec, byte ms1, byte ms2)
+        {
+            var (Gyr, Acc, Mag, TimeGap) = Attitude.Update(gyrByte, accByte, magByte, min, sec, ms1, ms2);
+            if((Gyr, Acc, Mag, TimeGap) == default)
+                return Geometry.Quaternion.Identity;
+            Vector<double> Buffer = default;
+            Buffer = GyrHardwareVariance.Update(Attitude.LastGyr);
+            if (Buffer != default)
+                Debug.Log("GyrHardwareVariance: " + Buffer.Length);
+            Buffer = AccHardwareVariance.Update(Acc);
+            if (Buffer != default)
+                Debug.Log("AccHardwareVariance: " + Buffer.Length);
+            Buffer = MagHardwareVariance.Update(Mag);
+            if (Buffer != default)
+                Debug.Log("MagHardwareVariance: " + Buffer.Length);
+
+            var GyrOperator = Geometry.Quaternion.Euler(Gyr * TimeGap);
+
+
+            var Last = States.LastOrDefault() ?? new State();
+            States.Add(new State());
+            if (States.Count > StatesMaxCount)
+                States.RemoveAt(0);
+            var state = States.Last();
+            state.Acc = Acc;
+
+
+            //Debug.Log(Gyr.magnitude);
+
+            state.Gyr = Gyr;
+            state.Mag = Mag;/**/
+            state.TimeGap = TimeGap;
+            if (States.Count <= 1)
+                return Geometry.Quaternion.Identity;
+            return Process9Axis(Last, state);
+        }
+        int ShakeFrame;
+        int AccVarianceInput;
+        /// //////////////////向前追溯多少帧//向后多少帧计算抖动
+        public void OnShot(int TrackBack, int ShakeFrame, int AccVarianceInput)
+        {
+            this.AccVarianceInput = AccVarianceInput;
+            TrackBack = Math.Min(TrackBack, States.Count);
+            var startI = States.Count - TrackBack;
+            State Last = default;
+            foreach (var i in TrackBack.Range())
+            {
+                var state = States[startI + i];
+
+                if (Last != default)
+                    Process9Axis(Last, state);
+                Last = state;
+            }
+
+            this.ShakeFrame = ShakeFrame;
+            Debug.Log("OnShot");/**/
+        }
+        public double diff = 0.001;
+        public Geometry.Quaternion Process9Axis(State Last, State state)
+        {
+            var Acc = state.Acc;
+            var Gyr = state.Gyr;
+            var Mag = state.Mag;
+            double TimeGap = state.TimeGap;
+
+            o0UIRawImageTester.UpdateAllOffset();
+
+
+            var LastQuaternion = Last.Qua;
+
+
+
+            var GyrOperator = Geometry.Quaternion.Euler(Gyr * TimeGap);
+            var quaGyr = LastQuaternion * GyrOperator;
+
+
+            //TestVector.Update9AxisRotation(GyrOperator, 1);
+            //TestVector.SetAcc(Acc / 10, 1);
+            //TestVector.SetMag(Mag, 1);
+            var accTest = Geometry.Quaternion.FromToRotation(Last.Acc, Acc).Inversed;
+            var magTest = Geometry.Quaternion.FromToRotation(Last.Mag, Mag).Inversed;
+            //TestVector.Set9AxisRotation(Last.Qua, 3);
+
+            double AccLengthToAngle = 5;//1倍引力差相当于多少度方差
+            double MagLengthToAngle = 5;//1倍磁力差相当于多少度方差
+
+            double GyrVariance = Last.Variance + Math.Pow((Gyr * TimeGap).Length * 0.3, 3) + diff;// 指数4 = 方差2 * 欧拉角旋转误差2     移动导致累计误差
+
+            //double GyrVariance = Last.Variance + Math.Pow((Gyr * TimeGap).magnitude * 0.3, 3) + 0.1;// 指数4 = 方差2 * 欧拉角旋转误差2     移动导致累计误差
+            //    Debug.Log("GyrVariance==" + GyrVariance);
+            double AccVariance = AccVarianceInput != default ? AccVarianceInput : Math.Max((Gyr * TimeGap).Length, state.Acc.Angle(Last.Acc)) * 1 + Math.Pow(Math.Abs(state.Acc.Length - 1) / 1 * AccLengthToAngle, 4);
+            double MagVariance = 10 + Math.Pow(Math.Abs(state.Mag.Length - 1) / 1 * MagLengthToAngle, 4);/**/
+
+
+
+            if (double.IsInfinity(GyrVariance))
+                GyrVariance = double.MinValue;
+            if (double.IsNaN(GyrVariance))
+                GyrVariance = double.MinValue;
+            if (double.IsNaN(AccVariance))
+                AccVariance = double.MinValue;
+            if (double.IsNaN(MagVariance))
+                MagVariance = double.MinValue;
+
+            state.Variance = GyrVariance;
+            state.Variance = state.Variance * (AccVariance + MagVariance) / (state.Variance + (AccVariance + MagVariance));
+
+
+            if (double.IsNaN(state.Variance))
+                state.Variance = double.MinValue;
+
+            var quaAccMag = Geometry.Quaternion.FormQuaternion(AccIdentity, MagIdentity, state.Acc, state.Mag, (float)(AccVariance / (AccVariance + MagVariance)));
+            var quaMinRate = GyrVariance / (GyrVariance + Math.Max(AccVariance, MagVariance));
+            var quaMaxRate = GyrVariance / (GyrVariance + Math.Min(AccVariance, MagVariance));
+            Geometry.Quaternion quaFirst = Geometry.Quaternion.SLerp(quaGyr, quaAccMag, (float)quaMinRate);
+            if (double.IsNaN(quaFirst.w))
+                quaFirst = Last.Qua;
+
+            var quaSecondRate = (quaMaxRate - quaMinRate) / (1 - quaMinRate);
+
+            state.Qua = AccVariance < MagVariance ? Geometry.Quaternion.FormQuaternion(quaFirst, AccIdentity, state.Acc, (float)quaSecondRate) : Geometry.Quaternion.FormQuaternion(quaFirst, MagIdentity, state.Mag, (float)quaSecondRate);
+
+
+
+
+            ///////////////////////////////////////////////////////////////
+
+            if (double.IsNaN(state.Qua.w))
+                state.Qua = Last.Qua;/**/
+            state.QuaSmooth = Geometry.Quaternion.SLerp(Last.QuaSmooth, state.Qua, 0.3f);//Last.QuaSmooth - state.Qua    0 - 1
+
+
+            //QuaTest[0] = o0Project.o0.FormQuaternion(QuaTest[0] * GyrOperator, AccIdentity, state.AccSmooth, 1);
+            // QuaTest[0] = Geometry.Quaternion.FormQuaternion(AccIdentity, MagIdentity, state.AccSmooth, state.MagSmooth, (float)(AccVariance / (AccVariance + MagVariance))).ToUnityQuaternion();
+            // QuaTest[1] = state.QuaAccMag.ToUnityQuaternion();
+            //QuaTest[1] = o0Project.o0.FormQuaternion(QuaTest[1] * GyrOperator, MagIdentity, state.MagSmooth, 1);
+            //Debug.Log(o09AxisCS.QuaTest[0]);
+
+            if (ShakeFrame > 0)
+            {
+                --ShakeFrame;
+                if (ShakeFrame == 0)
+                    AccVarianceInput = default;
+            }
+            return state.QuaSmooth;
+        }
+
+        public void Init()
+        {
+            States.Last().AccVariance = 1000;
+            States.Last().GyrVariance = 1000;
+            States.Last().MagVariance = 1000;
+            States.Last().AccMagVariance = 1000;
+            States.Last().TotalVariance = 1000;
+        }
+        public Geometry.Quaternion SetIdentity()
+        {
+            //UnityEngine.Quaternion qua = default;
+
+            //int averageCount = Math.Min(States.Count, 5);
+            int averageCount = Math.Min(States.Count, 50);
+            Vector<double> aveAcc = Vector<double>.Zero;
+            Vector<double> aveMag = Vector<double>.Zero;
+            for (var i = States.Count - averageCount; i < States.Count; ++i)
+            {
+                aveAcc += States[i].Acc;
+                aveMag += States[i].Mag;
+            }
+            aveAcc /= averageCount;
+            aveMag /= averageCount;
+            //AccIdentity = AccOld;
+            //MagIdentity = MagOld;
+            AccIdentity = aveAcc;
+            MagIdentity = aveMag;
+            //qua = o0Project.o0.FormQuaternion(Quaternion.identity, Vector3.down,AccIdentity, 1);
+            //AccIdentity=qua*AccIdentity;
+            //MagIdentity = qua*MagIdentity;
+            States.Last().Qua = Geometry.Quaternion.Identity;
+            States.Last().QuaSmooth = Geometry.Quaternion.Identity;
+            //States.Last().Qua = qua*States.Last().Qua;//Quaternion.identity;
+            States.Last().Variance = 0.0000001;
+            States.Last().AccVariance = 0.0000001;
+            States.Last().GyrVariance = 0.0000001;
+            States.Last().MagVariance = 0.0000001;
+            States.Last().QuaAccMag = Geometry.Quaternion.Identity;
+            States.Last().QuaAccMagCount = 0;
+            States.Last().AccMagVariance = 0.0000001;
+            States.Last().TotalVariance = 0.0000001;
+
+
+            return States.Last().Qua;
+        }
+
+        public State getLastState()
+        {
+            return this.States.Last();
+        }
+
+        public void LoadIdentity() 
+        {
+            try {
+                string magIdentityStr = PlayerPrefs.GetString("MagIdentity", "");
+                if (magIdentityStr.Length > 0) {
+                    double[] arr = JsonConvert.DeserializeObject<double[]>(magIdentityStr);
+                    AccIdentity = new Vector<double>(arr[0], arr[1], arr[2]);
+                }
+                string accIdentityStr = PlayerPrefs.GetString("AccIdentity", "");
+                if (accIdentityStr.Length > 0) {
+                    double[] arr = JsonConvert.DeserializeObject<double[]>(accIdentityStr);
+                    MagIdentity = new Vector<double>(arr[0], arr[1], arr[2]);
+                }
+            } catch (System.Exception e) { 
+                Debug.LogError(e.Message);
+                Debug.LogError(e.StackTrace); 
+            }
+        }
+
+        public void SetIdentityAndSave()
+        {
+            SetIdentity();
+            SaveIdentity();
+        }
+        
+        private void SaveIdentity() {
+            Vector<double> m = MagIdentity;
+            Vector<double> a = AccIdentity;
+            PlayerPrefs.SetString("MagIdentity",JsonConvert.SerializeObject(new double[]{
+                m.x, m.y, m.z
+            }));
+            PlayerPrefs.SetString("AccIdentity", JsonConvert.SerializeObject(new double[]{
+                a.x, a.y, a.z
+            }));
+        }
+    }
+}

+ 11 - 0
Assets/BowArrow/Scripts/Bluetooth/New/o09AxisAfterXiaMenFromDll.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 429dc5ad711556147a3df13e41d3d35d
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 18 - 0
Assets/BowArrow/Scripts/Bluetooth/New/o0Bow.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using o0.Geometry;
+using o0.Num;
+
+namespace o0.Bow
+{
+    public static partial class Extension
+    {
+        public static UnityEngine.Quaternion ToUnityQuaternion(this Quaternion q) => new UnityEngine.Quaternion((float)q.x, (float)q.y, (float)q.z, (float)q.w);
+        public static Quaternion Too0Quaternion(this UnityEngine.Quaternion q) => new Quaternion(q.x, q.y, q.z, q.w);
+        public static UnityEngine.Vector3 ToUnityVector(this Vector<double> v) => new UnityEngine.Vector3((float)v.x, (float)v.y, (float)v.z);
+        public static Vector<double> Too0Vector(this UnityEngine.Vector3 v) => new Vector<double>(v.x, v.y, v.z);
+    }
+}

+ 11 - 0
Assets/BowArrow/Scripts/Bluetooth/New/o0Bow.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e1c8cb7f5a32f6c44bf4186136fad55a
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Assets/BowArrow/Scripts/Bluetooth/New/o0NetIMU.dll


+ 33 - 0
Assets/BowArrow/Scripts/Bluetooth/New/o0NetIMU.dll.meta

@@ -0,0 +1,33 @@
+fileFormatVersion: 2
+guid: f04512b2c65539f4aab346661d52ab29
+PluginImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  iconMap: {}
+  executionOrder: {}
+  defineConstraints: []
+  isPreloaded: 0
+  isOverridable: 0
+  isExplicitlyReferenced: 0
+  validateReferences: 1
+  platformData:
+  - first:
+      Any: 
+    second:
+      enabled: 1
+      settings: {}
+  - first:
+      Editor: Editor
+    second:
+      enabled: 0
+      settings:
+        DefaultValueInitialized: true
+  - first:
+      Windows Store Apps: WindowsStoreApps
+    second:
+      enabled: 0
+      settings:
+        CPU: AnyCPU
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Assets/BowArrow/Scripts/Bluetooth/New/o0NetLib.dll


+ 1 - 1
Assets/Plugins/o0Lib/o0NetLib.dll.meta → Assets/BowArrow/Scripts/Bluetooth/New/o0NetLib.dll.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: e13dab309567c5847a70e24d05e9ed6b
+guid: e986f4277f4afd141a685b29364b0302
 PluginImporter:
   externalObjects: {}
   serializedVersion: 2

+ 2 - 1
Assets/BowArrow/Scripts/Bluetooth/ShootCheck.cs

@@ -357,7 +357,8 @@ public class ShootCheck : MonoBehaviour
             ShootCheck.ins.webSocket.Send(logTxt);
         } catch (Exception) {}
         //调用游戏中的射箭接口
-        AimHandler.ins._9Axis.axisCSBridge.o09AxisCS.OnShot(100, 100, 100000);
+        // AimHandler.ins._9Axis.axisCSBridge.o09AxisCS.OnShot(100, 100, 100000);
+        AimHandler.ins.OnShot();
         if (SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked) {
             SB_EventSystem.ins.ClickMouse(); 
         } else if (ArmBow.ins) {

+ 21 - 0
Assets/BowArrow/Scripts/Network/SocketComp/UserComp.cs

@@ -11,4 +11,25 @@ public class UserComp : JCUnityLib.Singleton<UserComp>
     public void saveUserInfo(UserInfo userInfo) {
         UserPlayer.ins.call("userComp.saveUserInfo", userInfo);
     }
+
+    public void saveMac2()
+    {
+        string mac = LoginMgr.myUserInfo.mac;
+        if (string.IsNullOrEmpty(mac)) return;
+        int type = AimHandler.DeviceType;
+        UserPlayer.ins.call("userComp.saveMac2", mac, type);
+    } 
+
+    public void saveCalibrateRecord(string record) {
+        string mac = LoginMgr.myUserInfo.mac;
+        if (string.IsNullOrEmpty(mac)) return;
+        int type = AimHandler.DeviceType;
+        UserPlayer.ins.call("userComp.saveCalibrateRecord", type, record, mac);
+    }
+
+    #region 被服务端调用的函数
+    public void onResumeCalibrateRecord(string record) {
+        AimHandler.ins.ResumeCalibrateRecord(record);
+    }
+    #endregion
 }

+ 1 - 0
Assets/BowArrow/Scripts/Network/UserPlayer.cs

@@ -11,6 +11,7 @@ public class UserPlayer : JCEntity
     public UserPlayer() {
         ins = this;
         components.Add("PKComp", PKComp.Instance);
+        components.Add("UserComp", UserComp.Instance);
     }
     public static void ConnectServer() {
         if (ins != null) return;

+ 0 - 263
Assets/Plugins/o0Lib/o0NetLib.deps.json

@@ -1,263 +0,0 @@
-{
-  "runtimeTarget": {
-    "name": ".NETStandard,Version=v2.0/",
-    "signature": ""
-  },
-  "compilationOptions": {},
-  "targets": {
-    ".NETStandard,Version=v2.0": {},
-    ".NETStandard,Version=v2.0/": {
-      "o0NetLib/1.0.0": {
-        "dependencies": {
-          "BouncyCastle": "1.8.9",
-          "Fractions": "7.0.0",
-          "Mono.Data.Sqlite": "1.0.61",
-          "NETStandard.Library": "2.0.3",
-          "SixLabors.ImageSharp": "2.1.1",
-          "System.Reflection.Emit.Lightweight": "4.7.0",
-          "System.Runtime.Numerics": "4.0.0",
-          "zlib.net": "1.0.4"
-        },
-        "runtime": {
-          "o0NetLib.dll": {}
-        }
-      },
-      "BouncyCastle/1.8.9": {
-        "runtime": {
-          "lib/BouncyCastle.Crypto.dll": {
-            "assemblyVersion": "1.8.9.0",
-            "fileVersion": "1.8.20343.1"
-          }
-        }
-      },
-      "Fractions/7.0.0": {
-        "dependencies": {
-          "System.Runtime.Numerics": "4.0.0"
-        },
-        "runtime": {
-          "lib/netstandard2.0/Fractions.dll": {
-            "assemblyVersion": "7.0.0.0",
-            "fileVersion": "7.0.0.0"
-          }
-        }
-      },
-      "Microsoft.NETCore.Platforms/1.1.0": {},
-      "Mono.Data.Sqlite/1.0.61": {
-        "runtime": {
-          "lib/net40/Mono.Data.Sqlite.dll": {
-            "assemblyVersion": "4.0.0.0",
-            "fileVersion": "1.0.61.0"
-          }
-        }
-      },
-      "NETStandard.Library/2.0.3": {
-        "dependencies": {
-          "Microsoft.NETCore.Platforms": "1.1.0"
-        }
-      },
-      "SixLabors.ImageSharp/2.1.1": {
-        "dependencies": {
-          "System.Buffers": "4.5.1",
-          "System.Memory": "4.5.4",
-          "System.Numerics.Vectors": "4.5.0",
-          "System.Runtime.CompilerServices.Unsafe": "5.0.0",
-          "System.Text.Encoding.CodePages": "5.0.0"
-        },
-        "runtime": {
-          "lib/netstandard2.0/SixLabors.ImageSharp.dll": {
-            "assemblyVersion": "2.0.0.0",
-            "fileVersion": "2.1.1.0"
-          }
-        }
-      },
-      "System.Buffers/4.5.1": {
-        "runtime": {
-          "lib/netstandard2.0/System.Buffers.dll": {
-            "assemblyVersion": "4.0.3.0",
-            "fileVersion": "4.6.28619.1"
-          }
-        }
-      },
-      "System.Memory/4.5.4": {
-        "dependencies": {
-          "System.Buffers": "4.5.1",
-          "System.Numerics.Vectors": "4.5.0",
-          "System.Runtime.CompilerServices.Unsafe": "5.0.0"
-        },
-        "runtime": {
-          "lib/netstandard2.0/System.Memory.dll": {
-            "assemblyVersion": "4.0.1.1",
-            "fileVersion": "4.6.28619.1"
-          }
-        }
-      },
-      "System.Numerics.Vectors/4.5.0": {
-        "runtime": {
-          "lib/netstandard2.0/System.Numerics.Vectors.dll": {
-            "assemblyVersion": "4.1.4.0",
-            "fileVersion": "4.6.26515.6"
-          }
-        }
-      },
-      "System.Reflection.Emit.ILGeneration/4.7.0": {
-        "runtime": {
-          "lib/netstandard2.0/System.Reflection.Emit.ILGeneration.dll": {
-            "assemblyVersion": "4.0.0.0",
-            "fileVersion": "4.700.19.56404"
-          }
-        }
-      },
-      "System.Reflection.Emit.Lightweight/4.7.0": {
-        "dependencies": {
-          "System.Reflection.Emit.ILGeneration": "4.7.0"
-        },
-        "runtime": {
-          "lib/netstandard2.0/System.Reflection.Emit.Lightweight.dll": {
-            "assemblyVersion": "4.0.0.0",
-            "fileVersion": "4.700.19.56404"
-          }
-        }
-      },
-      "System.Runtime.CompilerServices.Unsafe/5.0.0": {
-        "runtime": {
-          "lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll": {
-            "assemblyVersion": "5.0.0.0",
-            "fileVersion": "5.0.20.51904"
-          }
-        }
-      },
-      "System.Runtime.Numerics/4.0.0": {},
-      "System.Text.Encoding.CodePages/5.0.0": {
-        "dependencies": {
-          "System.Runtime.CompilerServices.Unsafe": "5.0.0"
-        },
-        "runtime": {
-          "lib/netstandard2.0/System.Text.Encoding.CodePages.dll": {
-            "assemblyVersion": "5.0.0.0",
-            "fileVersion": "5.0.20.51904"
-          }
-        }
-      },
-      "zlib.net/1.0.4": {
-        "runtime": {
-          "lib/zlib.net.dll": {
-            "assemblyVersion": "1.0.3.0",
-            "fileVersion": "1.0.3.0"
-          }
-        }
-      }
-    }
-  },
-  "libraries": {
-    "o0NetLib/1.0.0": {
-      "type": "project",
-      "serviceable": false,
-      "sha512": ""
-    },
-    "BouncyCastle/1.8.9": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-axnBgvdD5n+FnEG6efk/tfKuMFru7R/EoISH9zjh319yb3HD24TEHSAbNN/lTRT2ulOGRxDgOsCjkuk08iwWPg==",
-      "path": "bouncycastle/1.8.9",
-      "hashPath": "bouncycastle.1.8.9.nupkg.sha512"
-    },
-    "Fractions/7.0.0": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-1uv2IqQ6AsLtrcsibOTEyyHLQpxgjONssPrI0Ug84AIuSVqVDcotaNkTaJTprFvxbCNi7Kp/3WAAtnytuQP3qQ==",
-      "path": "fractions/7.0.0",
-      "hashPath": "fractions.7.0.0.nupkg.sha512"
-    },
-    "Microsoft.NETCore.Platforms/1.1.0": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
-      "path": "microsoft.netcore.platforms/1.1.0",
-      "hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
-    },
-    "Mono.Data.Sqlite/1.0.61": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-o5bYhnYDlQ8qiDBDJEnnK/LlQnHzpAb6ixXdrZKcVGv26jBfSm58ujAR1NLBhs0h+R5782VufbaF6gzYq3iiaA==",
-      "path": "mono.data.sqlite/1.0.61",
-      "hashPath": "mono.data.sqlite.1.0.61.nupkg.sha512"
-    },
-    "NETStandard.Library/2.0.3": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
-      "path": "netstandard.library/2.0.3",
-      "hashPath": "netstandard.library.2.0.3.nupkg.sha512"
-    },
-    "SixLabors.ImageSharp/2.1.1": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-oNHMT8+yUR9dyuU2r7fwsXvvS4OnfCs9N5i2y2p9iBxp3nvEZbe/hZWrOGfD7MX2lxOAlWzlhzj0q2uFwP8avg==",
-      "path": "sixlabors.imagesharp/2.1.1",
-      "hashPath": "sixlabors.imagesharp.2.1.1.nupkg.sha512"
-    },
-    "System.Buffers/4.5.1": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==",
-      "path": "system.buffers/4.5.1",
-      "hashPath": "system.buffers.4.5.1.nupkg.sha512"
-    },
-    "System.Memory/4.5.4": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-1MbJTHS1lZ4bS4FmsJjnuGJOu88ZzTT2rLvrhW7Ygic+pC0NWA+3hgAen0HRdsocuQXCkUTdFn9yHJJhsijDXw==",
-      "path": "system.memory/4.5.4",
-      "hashPath": "system.memory.4.5.4.nupkg.sha512"
-    },
-    "System.Numerics.Vectors/4.5.0": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==",
-      "path": "system.numerics.vectors/4.5.0",
-      "hashPath": "system.numerics.vectors.4.5.0.nupkg.sha512"
-    },
-    "System.Reflection.Emit.ILGeneration/4.7.0": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-AucBYo3DSI0IDxdUjKksBcQJXPHyoPyrCXYURW1WDsLI4M65Ar/goSHjdnHOAY9MiYDNKqDlIgaYm+zL2hA1KA==",
-      "path": "system.reflection.emit.ilgeneration/4.7.0",
-      "hashPath": "system.reflection.emit.ilgeneration.4.7.0.nupkg.sha512"
-    },
-    "System.Reflection.Emit.Lightweight/4.7.0": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-a4OLB4IITxAXJeV74MDx49Oq2+PsF6Sml54XAFv+2RyWwtDBcabzoxiiJRhdhx+gaohLh4hEGCLQyBozXoQPqA==",
-      "path": "system.reflection.emit.lightweight/4.7.0",
-      "hashPath": "system.reflection.emit.lightweight.4.7.0.nupkg.sha512"
-    },
-    "System.Runtime.CompilerServices.Unsafe/5.0.0": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==",
-      "path": "system.runtime.compilerservices.unsafe/5.0.0",
-      "hashPath": "system.runtime.compilerservices.unsafe.5.0.0.nupkg.sha512"
-    },
-    "System.Runtime.Numerics/4.0.0": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-aAYGEOE01nabQLufQ4YO8WuSyZzOqGcksi8m1BRW8ppkmssR7en8TqiXcBkB2gTkCnKG/Ai2NQY8CgdmgZw/fw==",
-      "path": "system.runtime.numerics/4.0.0",
-      "hashPath": "system.runtime.numerics.4.0.0.nupkg.sha512"
-    },
-    "System.Text.Encoding.CodePages/5.0.0": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-NyscU59xX6Uo91qvhOs2Ccho3AR2TnZPomo1Z0K6YpyztBPM/A5VbkzOO19sy3A3i1TtEnTxA7bCe3Us+r5MWg==",
-      "path": "system.text.encoding.codepages/5.0.0",
-      "hashPath": "system.text.encoding.codepages.5.0.0.nupkg.sha512"
-    },
-    "zlib.net/1.0.4": {
-      "type": "package",
-      "serviceable": true,
-      "sha512": "sha512-ywKkVY1y20tGQsUnYgKupYm91L8GVrVgoEOFTjfR1Bb5Xiy5tBJu5SV9liIiW2h8/KQUBefE45vSythtNMmahQ==",
-      "path": "zlib.net/1.0.4",
-      "hashPath": "zlib.net.1.0.4.nupkg.sha512"
-    }
-  }
-}

+ 0 - 7
Assets/Plugins/o0Lib/o0NetLib.deps.json.meta

@@ -1,7 +0,0 @@
-fileFormatVersion: 2
-guid: 4593cc48cb43a58429a34a9705539735
-TextScriptImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

BIN
Assets/Plugins/o0Lib/o0NetLib.dll


BIN
Assets/Plugins/o0Lib/o0NetLib.pdb


+ 2 - 2
ProjectSettings/ProjectSettings.asset

@@ -242,7 +242,7 @@ PlayerSettings:
   useCustomBaseGradleTemplate: 0
   useCustomGradlePropertiesTemplate: 0
   useCustomProguardFile: 0
-  AndroidTargetArchitectures: 2
+  AndroidTargetArchitectures: 1
   AndroidSplashScreenScale: 0
   androidSplashScreen: {fileID: 0}
   AndroidKeystoreName: "{inproject}: Doc/App\u79C1\u94A5/2022-11-17/smartbow.keystore"
@@ -694,7 +694,7 @@ PlayerSettings:
   additionalCompilerArguments: {}
   platformArchitecture: {}
   scriptingBackend:
-    Android: 1
+    Android: 0
     Standalone: 0
   il2cppCompilerConfiguration:
     Standalone: 1