|
@@ -6,7 +6,7 @@ using Valve.VR;
|
|
using JsonConvert = Valve.Newtonsoft.Json.JsonConvert;
|
|
using JsonConvert = Valve.Newtonsoft.Json.JsonConvert;
|
|
using TrackpointApp;
|
|
using TrackpointApp;
|
|
|
|
|
|
-public class SteamVRTrack : TrackpointMesh
|
|
|
|
|
|
+public class SteamVRTrack : MonoBehaviour
|
|
{
|
|
{
|
|
public string filePath;
|
|
public string filePath;
|
|
public int rotationCorrection;
|
|
public int rotationCorrection;
|
|
@@ -14,6 +14,7 @@ public class SteamVRTrack : TrackpointMesh
|
|
|
|
|
|
private GameObject rotationObject;
|
|
private GameObject rotationObject;
|
|
private GameObject meshObject;
|
|
private GameObject meshObject;
|
|
|
|
+ private List<ActionPoint> actionPoints = new List<ActionPoint>();
|
|
private TrackpointMesh trackpointMesh;
|
|
private TrackpointMesh trackpointMesh;
|
|
private SteamVR_TrackedObject tracking;
|
|
private SteamVR_TrackedObject tracking;
|
|
|
|
|
|
@@ -21,12 +22,15 @@ public class SteamVRTrack : TrackpointMesh
|
|
void Start()
|
|
void Start()
|
|
{
|
|
{
|
|
rotationObject = new GameObject();
|
|
rotationObject = new GameObject();
|
|
|
|
+ rotationObject.name = "TrackingRotation";
|
|
meshObject = new GameObject();
|
|
meshObject = new GameObject();
|
|
|
|
+ meshObject.name = "TrackingMesh";
|
|
rotationObject.transform.parent = this.transform;
|
|
rotationObject.transform.parent = this.transform;
|
|
trackpointMesh = meshObject.AddComponent<TrackpointMesh>();
|
|
trackpointMesh = meshObject.AddComponent<TrackpointMesh>();
|
|
trackpointMesh.transform.parent = rotationObject.transform;
|
|
trackpointMesh.transform.parent = rotationObject.transform;
|
|
trackpointMesh.setup(filePath, TrackingSystem.SteamVRTrack);
|
|
trackpointMesh.setup(filePath, TrackingSystem.SteamVRTrack);
|
|
setupTrackpointTranslationAndRotation();
|
|
setupTrackpointTranslationAndRotation();
|
|
|
|
+ setupActionPoints();
|
|
tracking = gameObject.AddComponent<SteamVR_TrackedObject>();
|
|
tracking = gameObject.AddComponent<SteamVR_TrackedObject>();
|
|
tracking.index = (SteamVR_TrackedObject.EIndex)1;
|
|
tracking.index = (SteamVR_TrackedObject.EIndex)1;
|
|
}
|
|
}
|
|
@@ -49,6 +53,26 @@ public class SteamVRTrack : TrackpointMesh
|
|
Quaternion result = correction * rotateObjectToTrackpoint;
|
|
Quaternion result = correction * rotateObjectToTrackpoint;
|
|
rotationObject.transform.rotation = result;
|
|
rotationObject.transform.rotation = result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ void setupActionPoints()
|
|
|
|
+ {
|
|
|
|
+ string metadata = trackpointMesh.getActionPointMetaData();
|
|
|
|
+ Dictionary<String, trackpoints> metaObject = JsonConvert.DeserializeObject<Dictionary<String, trackpoints>>(metadata);
|
|
|
|
+ foreach (KeyValuePair<String, trackpoints> actionPoint in metaObject)
|
|
|
|
+ {
|
|
|
|
+ GameObject anchor = new GameObject();
|
|
|
|
+ anchor.name = "ActionPoint " + actionPoint.Key;
|
|
|
|
+ anchor.transform.parent = trackpointMesh.transform;
|
|
|
|
+ float[] point = actionPoint.Value.point;
|
|
|
|
+ float[] normal = actionPoint.Value.normal;
|
|
|
|
+ anchor.transform.localPosition = new Vector3(point[0] / divisor, point[1] / divisor, point[2] / divisor);
|
|
|
|
+ Vector3 unityNormal = new Vector3(normal[0], normal[2], normal[1]);
|
|
|
|
+ anchor.transform.rotation = Quaternion.FromToRotation(Vector3.up, unityNormal);
|
|
|
|
+ ActionPoint actionPointObject = anchor.AddComponent<ActionPoint>();
|
|
|
|
+ actionPointObject.setup();
|
|
|
|
+ actionPoints.Add(actionPointObject);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public class trackpoints
|
|
public class trackpoints
|