Skip to content
Snippets Groups Projects
Commit f1d0f909 authored by Sylvain Buche's avatar Sylvain Buche
Browse files

WorldAnalysis interface: now a singleton, helper update to manage conversion...

WorldAnalysis interface: now a singleton, helper update to manage conversion between generated code and Unity data structures
parent 29a370a8
No related branches found
No related tags found
1 merge request!1Milestone B merge into main
...@@ -2,6 +2,8 @@ using ETSI.ARF.OpenAPI.WorldAnalysis; ...@@ -2,6 +2,8 @@ using ETSI.ARF.OpenAPI.WorldAnalysis;
public interface WorldAnalysisInterface public interface WorldAnalysisInterface
{ {
public static WorldAnalysisInterface Instance;
#region ResponseCode #region ResponseCode
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class WorldAnalysisUnityHelper public class WorldAnalysisUnityHelper
...@@ -7,7 +8,7 @@ public class WorldAnalysisUnityHelper ...@@ -7,7 +8,7 @@ public class WorldAnalysisUnityHelper
/// Convert a float array of length 3 to a Vector3 /// Convert a float array of length 3 to a Vector3
/// </summary> /// </summary>
/// <param name="value">the values to convert</param> /// <param name="value">the values to convert</param>
/// <returns></returns> /// <returns>Converted Unity Vector3</returns>
/// <exception cref="ArgumentException"></exception> /// <exception cref="ArgumentException"></exception>
public static Vector3 ConvertETSIVector3ToUnity(ETSI.ARF.OpenAPI.WorldAnalysis.Vector3 value) public static Vector3 ConvertETSIVector3ToUnity(ETSI.ARF.OpenAPI.WorldAnalysis.Vector3 value)
{ {
...@@ -19,7 +20,7 @@ public class WorldAnalysisUnityHelper ...@@ -19,7 +20,7 @@ public class WorldAnalysisUnityHelper
/// Convert a float array of length 4 to a Quaternion /// Convert a float array of length 4 to a Quaternion
/// </summary> /// </summary>
/// <param name="value">the values to convert</param> /// <param name="value">the values to convert</param>
/// <returns></returns> /// <returns>Converted Unity Quaternion</returns>
/// <exception cref="ArgumentException"></exception> /// <exception cref="ArgumentException"></exception>
public static Quaternion ConvertETSIARFQuaternionToUnity(ETSI.ARF.OpenAPI.WorldAnalysis.Quaternion value) public static Quaternion ConvertETSIARFQuaternionToUnity(ETSI.ARF.OpenAPI.WorldAnalysis.Quaternion value)
{ {
...@@ -30,9 +31,9 @@ public class WorldAnalysisUnityHelper ...@@ -30,9 +31,9 @@ public class WorldAnalysisUnityHelper
/// <summary> /// <summary>
/// Convert a float array of length 16 to a Matrix /// Convert a float array of length 16 to a Matrix
/// </summary> /// </summary>
/// <param name="matrix"></param> /// <param name="matrix">the values to convert</param>
/// <returns></returns> /// <returns>Converted Unity Matrix</returns>
public static Matrix4x4 ConvertETSIARFTransform3DToUnity(ETSI.ARF.OpenAPI.WorldAnalysis.Transform3D value) public static Matrix4x4 ConvertETSIARFTransform3DToUnity(ETSI.ARF.OpenAPI.WorldStorage.Transform3D value)
{ {
if (value.Count == 16) if (value.Count == 16)
{ {
...@@ -64,4 +65,49 @@ public class WorldAnalysisUnityHelper ...@@ -64,4 +65,49 @@ public class WorldAnalysisUnityHelper
throw new ArgumentException("The numer of floats in the value parameter must be 16!"); throw new ArgumentException("The numer of floats in the value parameter must be 16!");
} }
} }
/// <summary>
/// Function to extract translation from a Matrix4x4
/// </summary>
/// <param name="matrix"></param>
/// <returns></returns>
public static Vector3 ExtractTranslationFromMatrix(Matrix4x4 matrix)
{
return matrix.GetColumn(3);
}
/// <summary>
/// Function to extract rotation from a Matrix4x4
/// </summary>
/// <param name="matrix"></param>
/// <returns></returns>
public static Quaternion ExtractRotationFromMatrix(Matrix4x4 matrix)
{
// Convert the matrix to a Quaternion
return Quaternion.LookRotation(matrix.GetColumn(2), matrix.GetColumn(1));
}
}
namespace ETSI.ARF.OpenAPI.WorldAnalysis
{
/// <summary>
/// Override generated Vector3 constructor
/// </summary>
public partial class Vector3 : System.Collections.ObjectModel.Collection<float>
{
public Vector3(float x, float y, float z) : base(new List<float> { x, y, z })
{
}
}
/// <summary>
/// Override generated Quaternion constructor
/// </summary>
public partial class Quaternion : System.Collections.ObjectModel.Collection<float>
{
public Quaternion(float x, float y, float z, float w) : base(new List<float> { x, y, z, w})
{
}
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment