Init
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
public class ComponentName
|
||||
{
|
||||
private string _pkg;
|
||||
private string _cls;
|
||||
private string _flattenToShortString;
|
||||
private string _getShortClassName;
|
||||
private string _toShortString;
|
||||
private string _toString;
|
||||
|
||||
public ComponentName(string pkg, string cls)
|
||||
{
|
||||
_pkg = pkg;
|
||||
_cls = cls;
|
||||
}
|
||||
|
||||
public ComponentName(string pkg, string cls, string flattenToShortString, string getShortClassName, string toShortString, string toString)
|
||||
{
|
||||
_pkg = pkg;
|
||||
_cls = cls;
|
||||
_flattenToShortString = flattenToShortString;
|
||||
_getShortClassName = getShortClassName;
|
||||
_toShortString = toShortString;
|
||||
_toString = toString;
|
||||
}
|
||||
|
||||
public string getPackageName()
|
||||
{
|
||||
return _pkg;
|
||||
}
|
||||
|
||||
public string getClassName()
|
||||
{
|
||||
return _cls;
|
||||
}
|
||||
|
||||
public string flattenToShortString()
|
||||
{
|
||||
return _flattenToShortString;
|
||||
}
|
||||
|
||||
public string getShortClassName()
|
||||
{
|
||||
return _getShortClassName;
|
||||
}
|
||||
|
||||
public string toShortString()
|
||||
{
|
||||
return _toShortString;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return _toString;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f27e4ace8184aa899a9b7f6849e3c72
|
||||
timeCreated: 1742452121
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
public class PXRCapture
|
||||
{
|
||||
public const string VALUE_TRUE = "1";
|
||||
public const string VALUE_FALSE = "0";
|
||||
public const string KEY_MCTF = "enable-mctf";
|
||||
public const string KEY_EIS = "enable-eis";
|
||||
public const string KEY_MFNR = "enable-mfnr";
|
||||
public const string KEY_ENABLE_MVHEVC = "enable-mvhevc";
|
||||
public const string KEY_OUTPUT_CAMERA_RAW_DATA = "output-camera-raw-data";
|
||||
//与视频录制有关,目前暂不支持
|
||||
public const string KEY_VIDEO_FPS = "video-fps";
|
||||
public const string KEY_VIDEO_WIDTH = "video-width";
|
||||
public const string KEY_VIDEO_HEIGHT = "video-height";
|
||||
public const string KEY_VIDEO_BITRATE = "video-bit-rate";
|
||||
public const string KEY_WRITE_DEPTH_DATA = "write-depth-data";
|
||||
public const string KEY_WRITE_POSE_DATA = "write-pose-data";
|
||||
public const string KEY_WRITE_CAMERA_PARAMS_DATA = "write-camera-params-data";
|
||||
|
||||
|
||||
public const int CAPTURE_STATUS_STREAM_TIME_OUT = -100;
|
||||
public const int CAPTURE_STATUS_PREPROCESS_ERROR = -99;
|
||||
public const int CAPTURE_STATUS_RECORD_ERROR = -98;
|
||||
public const int CAPTURE_STATUS_NO_PERMISSION = -97;
|
||||
public const int CAPTURE_STATUS_SERVER_DIED = -96;
|
||||
public const int CAPTURE_STATUS_UNKNOWN = -95;
|
||||
public const int CAPTURE_STATUS_OK = 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73b8e45c73404959ba2f68cd312a907f
|
||||
timeCreated: 1752739063
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
[Serializable]
|
||||
public class HandStateAlg
|
||||
{
|
||||
public const int Hand_MaxBones = 26;
|
||||
public const int Hand_MaxPinch = 5;
|
||||
public const int Hand_MaxFingers = 5;
|
||||
public const int Hand_Pinch_Num = 4;
|
||||
public short status;
|
||||
public HandJointsLocation rootPose;
|
||||
public HandJointsLocation[] bonePose ;
|
||||
public short pinches;
|
||||
public float[] pinchStrength ;
|
||||
public float clickStrength;
|
||||
public Pose pointerPose;
|
||||
public float handScale;
|
||||
public int handConfidence;
|
||||
public int[] fingerConfidence ;
|
||||
public long requestedTimeStamp;
|
||||
public long sampleTimeStamp;
|
||||
public long outputTimeStamp;
|
||||
public short poseType = 0;
|
||||
public int handType ;
|
||||
public Pose rootPoseVel;
|
||||
public Pose[] bonePoseVel ;
|
||||
public Pose rootPoseAcc;
|
||||
public Pose[] bonePoseAcc;
|
||||
public short clickType ;
|
||||
public bool[] pinchActionReadyOpenxr ;
|
||||
public bool aimActionReadyOpenxr;
|
||||
public bool gripActionReadyOpenxr;
|
||||
public float[] pinchActionValueOpenxr ;
|
||||
public float aimActionValueOpenxr;
|
||||
public float gripActionValueOpenxr;
|
||||
public Pose[] pinchPoseOpenxr ;
|
||||
public Pose aimPoseOpenxr;
|
||||
public Pose pokePoseOpenxr;
|
||||
public Pose gripPoseOpenxr;
|
||||
public Pose gripSurfacePoseOpenxr;
|
||||
|
||||
public HandStateAlg()
|
||||
{
|
||||
status = 0;
|
||||
rootPose = new HandJointsLocation();
|
||||
bonePose = new HandJointsLocation[Hand_MaxBones];
|
||||
for (int i = 0; i < Hand_MaxBones; i++) {
|
||||
bonePose[i] = new HandJointsLocation();
|
||||
}
|
||||
pinches = 0;
|
||||
pinchStrength = new float[Hand_MaxPinch];
|
||||
clickStrength = 0f;
|
||||
pointerPose = new Pose();
|
||||
handScale = 1f;
|
||||
handConfidence = 0;
|
||||
fingerConfidence = new int[Hand_MaxFingers];
|
||||
requestedTimeStamp = 0;
|
||||
sampleTimeStamp = 0;
|
||||
outputTimeStamp = 0;
|
||||
poseType = 0;
|
||||
handType = -1;
|
||||
rootPoseVel = new Pose();
|
||||
bonePoseVel = new Pose[Hand_MaxBones];
|
||||
rootPoseAcc = new Pose();
|
||||
bonePoseAcc = new Pose[Hand_MaxBones];
|
||||
clickType = -1;
|
||||
pinchActionReadyOpenxr = new bool[Hand_Pinch_Num];
|
||||
aimActionReadyOpenxr = false;
|
||||
gripActionReadyOpenxr = false;
|
||||
pinchActionValueOpenxr = new float[Hand_Pinch_Num];
|
||||
aimActionValueOpenxr = 0f;
|
||||
gripActionValueOpenxr = 0f;
|
||||
pinchPoseOpenxr = new Pose[Hand_Pinch_Num];
|
||||
aimPoseOpenxr = new Pose();
|
||||
pokePoseOpenxr = new Pose();
|
||||
gripPoseOpenxr = new Pose();
|
||||
gripSurfacePoseOpenxr = new Pose();
|
||||
}
|
||||
|
||||
|
||||
public static string ToJson(HandStateAlg data)
|
||||
{
|
||||
// 注意:JsonUtility 序列化数组时需包裹在对象中,这里直接序列化根对象即可
|
||||
return JsonUtility.ToJson(data, true); // 第二个参数为 true 时输出格式化的 JSON
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public class HandJointsLocation
|
||||
{
|
||||
public long locationFloags;
|
||||
public Pose pose;
|
||||
public float radius;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69863a27ce994e6697f6b7ff45e7b032
|
||||
timeCreated: 1748339838
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
[Serializable]
|
||||
public class IMUData
|
||||
{
|
||||
public long timestamp;
|
||||
public double vx;
|
||||
public double vy;
|
||||
public double vz;
|
||||
public double ax;
|
||||
public double ay;
|
||||
public double az;
|
||||
public double wx;
|
||||
public double wy;
|
||||
public double wz;
|
||||
public double w_ax;
|
||||
public double w_ay;
|
||||
public double w_az;
|
||||
public List<int> reservedInt;
|
||||
public List<double> reservedDouble;
|
||||
public IMUData()
|
||||
{
|
||||
timestamp = 0;
|
||||
vx = vy = vz = 0.0;
|
||||
ax = ay = az = 0.0;
|
||||
wx = wy = wz = 0.0;
|
||||
w_ax = w_ay = w_az = 0.0;
|
||||
reservedInt = new List<int>();
|
||||
reservedDouble = new List<double>();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class IMUDataListWrapper
|
||||
{
|
||||
public List<IMUData> IMUDatas;
|
||||
}
|
||||
public partial class JsonParser
|
||||
{
|
||||
public static IMUData ParseIMUDataFromJson(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonUtility.FromJson<IMUData>(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"JSON 解析出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static List<IMUData> ParseIMUDatasFromJson(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 先解析到包装类
|
||||
IMUDataListWrapper wrapper = JsonUtility.FromJson<IMUDataListWrapper>(json);
|
||||
if (wrapper != null && wrapper.IMUDatas != null)
|
||||
{
|
||||
return wrapper.IMUDatas;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"JSON 解析出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static string IMUDataToJson(IMUData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonUtility.ToJson(data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"对象转 JSON 出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static string IMUDataArrayToJson(List<IMUData> datas)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 创建包装类实例
|
||||
IMUDataListWrapper wrapper = new IMUDataListWrapper
|
||||
{
|
||||
IMUDatas = datas
|
||||
};
|
||||
// 使用 JsonUtility.ToJson 方法将包装类对象转换为 JSON 字符串
|
||||
return JsonUtility.ToJson(wrapper);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"对象数组转 JSON 出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e5b2760ae0040efa99b7c803b07de50
|
||||
timeCreated: 1748317798
|
||||
@@ -0,0 +1,132 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
public class Intent
|
||||
{
|
||||
private string Componentpkg = "";
|
||||
private string Componentcls = "";
|
||||
private string Action = "";
|
||||
private string type = "";
|
||||
private string url = "";
|
||||
|
||||
List<string> categoryList = new List<string>();
|
||||
Dictionary<string, string> stringPairs = new Dictionary<string, string>();
|
||||
Dictionary<string, bool> boolPairs = new Dictionary<string, bool>();
|
||||
Dictionary<string, int> intPairs = new Dictionary<string, int>();
|
||||
Dictionary<string, float> floatPairs = new Dictionary<string, float>();
|
||||
Dictionary<string, double> doublePairs = new Dictionary<string, double>();
|
||||
|
||||
public void setComponent(string pkg, string cls)
|
||||
{
|
||||
Componentpkg = pkg;
|
||||
Componentcls = cls;
|
||||
}
|
||||
|
||||
public void setAction(string _Action)
|
||||
{
|
||||
Action = _Action;
|
||||
}
|
||||
|
||||
public void setType(string _type)
|
||||
{
|
||||
type = _type;
|
||||
}
|
||||
|
||||
public void setData(string _url)
|
||||
{
|
||||
url = _url;
|
||||
}
|
||||
|
||||
public void addCategory(string _category)
|
||||
{
|
||||
categoryList.Add(_category);
|
||||
}
|
||||
|
||||
public void putExtra(string name, string value)
|
||||
{
|
||||
stringPairs.Add(name, value);
|
||||
}
|
||||
|
||||
public void putExtra(string name, int value)
|
||||
{
|
||||
intPairs.Add(name, value);
|
||||
}
|
||||
|
||||
public void putExtra(string name, float value)
|
||||
{
|
||||
floatPairs.Add(name, value);
|
||||
}
|
||||
|
||||
public void putExtra(string name, double value)
|
||||
{
|
||||
doublePairs.Add(name, value);
|
||||
}
|
||||
|
||||
public void putExtra(string name, bool value)
|
||||
{
|
||||
boolPairs.Add(name, value);
|
||||
}
|
||||
|
||||
public AndroidJavaObject getIntent()
|
||||
{
|
||||
AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent");
|
||||
if (!string.IsNullOrEmpty(Componentpkg) && !string.IsNullOrEmpty(Componentcls))
|
||||
{
|
||||
AndroidJavaObject componentName =
|
||||
new AndroidJavaObject("android.content.ComponentName", Componentpkg, Componentcls);
|
||||
intent.Call<AndroidJavaObject>("setComponent", componentName);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Action))
|
||||
{
|
||||
intent.Call<AndroidJavaObject>("setAction", Action);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(type))
|
||||
{
|
||||
intent.Call<AndroidJavaObject>("setType", type);
|
||||
}
|
||||
|
||||
// mIntent.setData(Uri.parse(""));
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); // 对应的安卓调用函数是Uri.parse()
|
||||
AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", url);
|
||||
intent.Call<AndroidJavaObject>("setData", uriObject);
|
||||
}
|
||||
|
||||
if (categoryList.Count != 0)
|
||||
{
|
||||
for (int i = 0; i < categoryList.Count; i++)
|
||||
{
|
||||
intent.Call<AndroidJavaObject>("addCategory", categoryList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, string> kvp in stringPairs)
|
||||
{
|
||||
intent.Call<AndroidJavaObject>("putExtra", kvp.Key, kvp.Value);
|
||||
}
|
||||
foreach (KeyValuePair<string, int> kvp in intPairs)
|
||||
{
|
||||
intent.Call<AndroidJavaObject>("putExtra", kvp.Key, kvp.Value);
|
||||
}
|
||||
foreach (KeyValuePair<string, bool> kvp in boolPairs)
|
||||
{
|
||||
intent.Call<AndroidJavaObject>("putExtra", kvp.Key, kvp.Value);
|
||||
}
|
||||
foreach (KeyValuePair<string, float> kvp in floatPairs)
|
||||
{
|
||||
intent.Call<AndroidJavaObject>("putExtra", kvp.Key, kvp.Value);
|
||||
}
|
||||
foreach (KeyValuePair<string, double> kvp in doublePairs)
|
||||
{
|
||||
intent.Call<AndroidJavaObject>("putExtra", kvp.Key, kvp.Value);
|
||||
}
|
||||
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e2fc05a295c4d17bf17cf1784ef3059
|
||||
timeCreated: 1709199569
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
public class LargeSpaceBoundsInfo
|
||||
{
|
||||
public const int TYPE_IN_SITU_SAFETY_ZONE = 10;
|
||||
public const int TYPE_OBSTACLE = 2;
|
||||
public const int TYPE_CUSTOMIZE_SECURITY_ZONE = 1;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"LargeSpaceBoundsInfo{{type= {type}, bounds= {string.Join(", ", bounds)} }}";
|
||||
}
|
||||
|
||||
private int type;
|
||||
private List<Point3D> bounds = new List<Point3D>();
|
||||
|
||||
public List<Point3D> getBounds()
|
||||
{
|
||||
return this.bounds;
|
||||
}
|
||||
|
||||
public void setType(int type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void addPoint3D(Point3D point3D)
|
||||
{
|
||||
this.bounds.Add(point3D);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d34bae0bdbf4862981e6029b5552dfe
|
||||
timeCreated: 1742457676
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
public class LargeSpaceQuickModeInfo
|
||||
{
|
||||
public bool status;
|
||||
public int length;
|
||||
public int width;
|
||||
public int originType;
|
||||
|
||||
public LargeSpaceQuickModeInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return
|
||||
$"{nameof(status)}: {status}, {nameof(length)}: {length}, {nameof(width)}: {width}, {nameof(originType)}: {originType}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb0961e0f2e64cd5bfff021b5f334bea
|
||||
timeCreated: 1715673498
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
public class MarkerInfo
|
||||
{
|
||||
// position
|
||||
public double posX;
|
||||
public double posY;
|
||||
public double posZ;
|
||||
|
||||
// rotation
|
||||
public double rotationX;
|
||||
public double rotationY;
|
||||
public double rotationZ;
|
||||
public double rotationW;
|
||||
|
||||
// 标志位:识别无效=0,识别有效=1
|
||||
public int validFlag;
|
||||
|
||||
// 类型:静态=1/动态=0
|
||||
public int markerType;
|
||||
|
||||
// marker id
|
||||
public int iMarkerId;
|
||||
|
||||
// 检测图像的时间戳
|
||||
public double dTimestamp;
|
||||
|
||||
// 预留标志位
|
||||
public float[] reserve;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(posX)}: {posX}, {nameof(posY)}: {posY}, {nameof(posZ)}: {posZ}, {nameof(rotationX)}: {rotationX}, {nameof(rotationY)}: {rotationY}, {nameof(rotationZ)}: {rotationZ}, {nameof(rotationW)}: {rotationW}, {nameof(validFlag)}: {validFlag}, {nameof(markerType)}: {markerType}, {nameof(iMarkerId)}: {iMarkerId}, {nameof(dTimestamp)}: {dTimestamp}, {nameof(reserve)}: {string.Join(" ", reserve)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f68848d9c705ba340a11b2713ae79b83
|
||||
timeCreated: 1686224373
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
public class OffLineSystemUpdateConfig
|
||||
{
|
||||
//OTA压缩包路径
|
||||
public String otaFilePath = null;
|
||||
//升级完成后是否自动重启
|
||||
public Boolean autoReboot = true;
|
||||
//升级过程中是否显示进度
|
||||
public Boolean showProgress = false;
|
||||
public OffLineSystemUpdateConfig()
|
||||
{
|
||||
}
|
||||
|
||||
public OffLineSystemUpdateConfig(string otaFilePath, bool autoReboot, bool showProgress)
|
||||
{
|
||||
this.otaFilePath = otaFilePath;
|
||||
this.autoReboot = autoReboot;
|
||||
this.showProgress = showProgress;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1bacf34f0a1d4af78e887965627b33eb
|
||||
timeCreated: 1721372797
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
public class Point3D
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
|
||||
public Point3D()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Point3D:{nameof(x)}: {x}, {nameof(y)}: {y}, {nameof(z)}: {z}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4808a326866641fdbd01f82a39e44aaf
|
||||
timeCreated: 1715150347
|
||||
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
|
||||
// 包装 Pose 列表的类,用于 JsonUtility 解析
|
||||
[Serializable]
|
||||
public class PoseListWrapper
|
||||
{
|
||||
public List<Pose> Poses;
|
||||
}
|
||||
[Serializable]
|
||||
public class Pose
|
||||
{
|
||||
public long timestamp;
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public double rw;
|
||||
public double rx;
|
||||
public double ry;
|
||||
public double rz;
|
||||
public int type;
|
||||
public int confidence;
|
||||
public int poseError;
|
||||
public List<int> reservedInt;
|
||||
public List<double> reservedDouble;
|
||||
|
||||
|
||||
public Pose()
|
||||
{
|
||||
timestamp = 0;
|
||||
x = 0.0;
|
||||
y = 0.0;
|
||||
z = 0.0;
|
||||
rw = 0.0;
|
||||
rx = 0.0;
|
||||
ry = 0.0;
|
||||
rz = 0.0;
|
||||
type = 0;
|
||||
confidence = 0;
|
||||
poseError = 0;
|
||||
reservedInt = new List<int>();
|
||||
reservedDouble = new List<double>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public partial class JsonParser
|
||||
{
|
||||
public static Pose ParsePoseFromJson(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 使用 Unity 的 JsonUtility 解析 JSON 字符串为 Pose 对象
|
||||
return JsonUtility.FromJson<Pose>(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"JSON 解析出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static List<Pose> ParsePoseArrayFromJson(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 先解析到包装类
|
||||
PoseListWrapper wrapper = JsonUtility.FromJson<PoseListWrapper>(json);
|
||||
if (wrapper != null && wrapper.Poses != null)
|
||||
{
|
||||
return wrapper.Poses;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"JSON 解析出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// 新增方法:将 Pose 对象转换为 JSON 字符串
|
||||
public static string PoseToJson(Pose pose)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 使用 JsonUtility.ToJson 方法将 Pose 对象转换为 JSON 字符串
|
||||
return JsonUtility.ToJson(pose);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"对象转 JSON 出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 新增方法:将 Pose 数组转换为 JSON 字符串
|
||||
public static string PoseArrayToJson(List<Pose> poses)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 创建包装类实例
|
||||
PoseListWrapper wrapper = new PoseListWrapper
|
||||
{
|
||||
Poses =poses
|
||||
};
|
||||
// 使用 JsonUtility.ToJson 方法将包装类对象转换为 JSON 字符串
|
||||
return JsonUtility.ToJson(wrapper);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"对象数组转 JSON 出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5ce8d9b73c44f868c21ed1793aa87b5
|
||||
timeCreated: 1748311214
|
||||
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SwiftDevice
|
||||
{
|
||||
public const int STATUS_OFFLINE = 0;
|
||||
public const int STATUS_ONLINE = 1;
|
||||
public const int POSITION_UNDEFINED = 0;
|
||||
public const int POSITION_LEFT = 1;
|
||||
public const int POSITION_RIGHT = 2;
|
||||
public const int POSITION_CENTER = 3;
|
||||
public const int BIND_NONE = 0;
|
||||
public const int BIND_DONE = 1;
|
||||
public const int ID_ALL = 0;
|
||||
public const int ID_T1 = 1;
|
||||
public const int ID_T2 = 2;
|
||||
public const int ID_T3 = 3;
|
||||
public const int CHARGE_STATUS_NONE = 0;
|
||||
public const int CHARGE_STATUS_PRE = 1;
|
||||
public const int CHARGE_STATUS_GOING = 2;
|
||||
public const int CHARGE_STATUS_DONE = 3;
|
||||
public const int BATTERY_LOW = 0;
|
||||
|
||||
|
||||
public int connectState;
|
||||
public int position;
|
||||
public int bindState;
|
||||
public int id;
|
||||
public string fwVersion;
|
||||
public string hwVersion;
|
||||
public string sn;
|
||||
public string addr;
|
||||
public int chargeStatus;
|
||||
public int battery;
|
||||
public int imuType;
|
||||
public int generation;
|
||||
public SwiftDevice()
|
||||
{
|
||||
connectState = 0;
|
||||
position = 0;
|
||||
bindState = 0;
|
||||
id = 0;
|
||||
fwVersion = string.Empty;
|
||||
hwVersion = string.Empty;
|
||||
sn = string.Empty;
|
||||
addr = string.Empty;
|
||||
chargeStatus = 0;
|
||||
battery = 0;
|
||||
imuType = 0;
|
||||
generation = 0;
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public class SwiftDeviceListWrapper
|
||||
{
|
||||
public List<SwiftDevice> SwiftDevices;
|
||||
}
|
||||
public partial class JsonParser
|
||||
{
|
||||
public static SwiftDevice ParseSwiftDeviceFromJson(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 使用 Unity 的 JsonUtility 解析 JSON 字符串为 Pose 对象
|
||||
return JsonUtility.FromJson<SwiftDevice>(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"JSON 解析出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static List<SwiftDevice> ParseSwiftDeviceArrayFromJson(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 先解析到包装类
|
||||
SwiftDeviceListWrapper wrapper = JsonUtility.FromJson<SwiftDeviceListWrapper>(json);
|
||||
if (wrapper != null && wrapper.SwiftDevices != null)
|
||||
{
|
||||
return wrapper.SwiftDevices;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"JSON 解析出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static string SwiftDeviceArrayToJson(List<SwiftDevice> devices)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 创建包装类实例
|
||||
SwiftDeviceListWrapper wrapper = new SwiftDeviceListWrapper
|
||||
{
|
||||
SwiftDevices = devices
|
||||
};
|
||||
// 使用 JsonUtility.ToJson 方法将包装类对象转换为 JSON 字符串
|
||||
return JsonUtility.ToJson(wrapper);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"对象数组转 JSON 出错: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0d01db5d714456bafa586dce096e79d
|
||||
timeCreated: 1748333820
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
public class WifiConfiguration
|
||||
{
|
||||
public WifiConfiguration(string ssid, string password, bool isClient=true)
|
||||
{
|
||||
this.ssid = ssid;
|
||||
this.password = password;
|
||||
this.isClient = isClient;
|
||||
}
|
||||
public WifiConfiguration()
|
||||
{
|
||||
this.ssid = "";
|
||||
this.password = "";
|
||||
this.isClient = true;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(ssid)}: {ssid}, {nameof(password)}: {password}, {nameof(isClient)}: {isClient}";
|
||||
}
|
||||
|
||||
public string ssid;
|
||||
public string password;
|
||||
public bool isClient;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 125a220e1cca49a38fb1bc398371735b
|
||||
timeCreated: 1727247563
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Unity.XR.PICO.TOBSupport
|
||||
{
|
||||
public class WifiDisplayModel
|
||||
{
|
||||
public static int STATUS_NOT_CONNECT = -1;
|
||||
public static int STATUS_NONE = 0;
|
||||
public static int STATUS_SCANNING = 1;
|
||||
public static int STATUS_CONNECTING = 2;
|
||||
public static int STATUS_AVAILABLE = 3;
|
||||
public static int STATUS_NOT_AVAILABLE = 4;
|
||||
public static int STATUS_IN_USE = 5;
|
||||
public static int STATUS_CONNECTED = 6;
|
||||
|
||||
public string deviceAddress;
|
||||
public string deviceName;
|
||||
public bool isAvailable;
|
||||
public bool canConnect;
|
||||
public bool isRemembered;
|
||||
public int statusCode;
|
||||
public string status;
|
||||
public string description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39f5fd05aee2d0047932945fab6f46a1
|
||||
timeCreated: 1686050281
|
||||
Reference in New Issue
Block a user