Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Collections;
using UnityEngine;
public class AnchorTrackableReferenceNode : MonoBehaviour
{
/// <summary>
/// UUID of the node or trackable
/// </summary>
public string _ARFNodeUUID;
// Start is called before the first frame update
IEnumerator Start()
{
yield return new WaitForSeconds(5.0f);
int validity = 100000; //10s
System.Guid subscriptionUUID;
// wait for initialization : not perfect way
WorldAnalysisInterface.Instance.SubscribeToPose(null, new System.Guid(_ARFNodeUUID) , ETSI.ARF.OpenAPI.WorldAnalysis.Mode_WorldAnalysis.DEVICE_TO_TRACKABLES, PoseCallback, ref validity, out subscriptionUUID); //TODO : find a value for the token parameter.
}
/// <summary>
/// The callback function used in the susbscription method. It instantiate a prefab or update its pose based on the current situation.
/// </summary>
/// <param name="result"></param>
/// <param name="pose"> The pose to update in the SM</param>
public void PoseCallback(WorldAnalysisInterface.PoseEstimationResult result, ETSI.ARF.OpenAPI.WorldAnalysis.Pose pose)
{
if (pose.Value.Type == ETSI.ARF.OpenAPI.WorldAnalysis.PoseValueType.VECTOR_QUATERNION)
{
ETSI.ARF.OpenAPI.WorldAnalysis.VectorQuaternionPoseValue value = (ETSI.ARF.OpenAPI.WorldAnalysis.VectorQuaternionPoseValue)pose.Value;
transform.position = WorldAnalysisUnityHelper.ConvertETSIVector3ToUnity(value.Position);
transform.rotation = WorldAnalysisUnityHelper.ConvertETSIARFQuaternionToUnity(value.Rotation);
}
else
{
Debug.LogWarning("Pose value type not supported yet :" + pose.Value.Type); // Todo : manage other types
}
}
}