From e8fc6a0f395a9305a002fb183e7ef45223c0369f Mon Sep 17 00:00:00 2001 From: joreg Date: Tue, 21 Nov 2023 15:45:04 +0100 Subject: [PATCH] added oscv3 and pleiades protocols --- VL.Augmenta.vl | 2207 +++++++++++++---- help/How To Receive Augmenta Pleiades data.vl | 906 +++++++ help/HowTo Receive Augmenta data via OSCv3.vl | 610 +++++ ...> HowTo Receive Augmenta data via TUIO.vl} | 918 +++---- help/shaders/DrawColoredParticles_DrawFX.sdsl | 55 + src/Augmenta.csproj | 10 + src/Augmenta.sln | 25 + src/PObject.cs | 170 ++ src/PleiadesClient.cs | 92 + src/Utils.cs | 32 + 10 files changed, 4118 insertions(+), 907 deletions(-) create mode 100644 help/How To Receive Augmenta Pleiades data.vl create mode 100644 help/HowTo Receive Augmenta data via OSCv3.vl rename help/{HowTo Receive Augmenta data.vl => HowTo Receive Augmenta data via TUIO.vl} (71%) create mode 100644 help/shaders/DrawColoredParticles_DrawFX.sdsl create mode 100644 src/Augmenta.csproj create mode 100644 src/Augmenta.sln create mode 100644 src/PObject.cs create mode 100644 src/PleiadesClient.cs create mode 100644 src/Utils.cs diff --git a/VL.Augmenta.vl b/VL.Augmenta.vl index 1e9f468..faac2e1 100644 --- a/VL.Augmenta.vl +++ b/VL.Augmenta.vl @@ -1,481 +1,1728 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9 - Link - - - - - - - - 9 - Comment - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + Link + + + + + + + + 9 + Comment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + Link + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + High + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + Link + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/help/How To Receive Augmenta Pleiades data.vl b/help/How To Receive Augmenta Pleiades data.vl new file mode 100644 index 0000000..198b88f --- /dev/null +++ b/help/How To Receive Augmenta Pleiades data.vl @@ -0,0 +1,906 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + High + + + + + + + + + + + + + + + + + + + + + + + + + + + + High + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Toggle + + + + + + + + + + + + Enter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + High + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/help/HowTo Receive Augmenta data via OSCv3.vl b/help/HowTo Receive Augmenta data via OSCv3.vl new file mode 100644 index 0000000..64277d1 --- /dev/null +++ b/help/HowTo Receive Augmenta data via OSCv3.vl @@ -0,0 +1,610 @@ + + + + + + + + + + + + + + + + + + + High + + + + + + + + + + + + + + + + + + + + + + + + + + + + High + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Toggle + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + 10 + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/help/HowTo Receive Augmenta data.vl b/help/HowTo Receive Augmenta data via TUIO.vl similarity index 71% rename from help/HowTo Receive Augmenta data.vl rename to help/HowTo Receive Augmenta data via TUIO.vl index 0565781..45815b3 100644 --- a/help/HowTo Receive Augmenta data.vl +++ b/help/HowTo Receive Augmenta data via TUIO.vl @@ -1,428 +1,492 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0, 0, 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Toggle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + High + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + High + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Toggle + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/help/shaders/DrawColoredParticles_DrawFX.sdsl b/help/shaders/DrawColoredParticles_DrawFX.sdsl new file mode 100644 index 0000000..ab9d7d7 --- /dev/null +++ b/help/shaders/DrawColoredParticles_DrawFX.sdsl @@ -0,0 +1,55 @@ + +shader DrawColoredParticles_DrawFX : VS_PS_Base, ShaderUtils +{ + StructuredBuffer ParticlesBuffer; + StructuredBuffer ColorBuffer; + + cbuffer PerFrame + { + [Color] + float ParticleSize; + }; + + stream float2 TexCoord; + stream uint VertexID : SV_VertexID; + stream float4 Color; + + // VS ============================================================================== + + stage override void VSMain() + { + uint id = streams.VertexID; + streams.PositionWS = ParticlesBuffer[id]; + streams.Color = ColorBuffer[id]; + } + + // GS ============================================================================== + + stream float Size; + + [maxvertexcount(4)] + stage void GSMain(point Input input[1], inout TriangleStream triangleStream) + { + streams = input[0]; + + for(int i=0; i<4; i++) + { + streams.TexCoord = QuadUV[i].xy; + + float4 posView = mul(streams.PositionWS, WorldView); + posView.xyz += QuadPositions[i].xyz * ParticleSize; + streams.ShadingPosition = mul(posView, Projection); + + triangleStream.Append(streams); + } + } + + + // PS ============================================================================== + + stage override void PSMain() + { + CircleSpriteDiscard(streams.TexCoord); + streams.ColorTarget = streams.Color; + } +}; \ No newline at end of file diff --git a/src/Augmenta.csproj b/src/Augmenta.csproj new file mode 100644 index 0000000..ea608f7 --- /dev/null +++ b/src/Augmenta.csproj @@ -0,0 +1,10 @@ + + + + net6.0 + enable + enable + ..\lib + + + diff --git a/src/Augmenta.sln b/src/Augmenta.sln new file mode 100644 index 0000000..b441445 --- /dev/null +++ b/src/Augmenta.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34031.279 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Augmenta", "Augmenta.csproj", "{BEE32E87-4D44-4F15-B01E-46C5E7C13739}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BEE32E87-4D44-4F15-B01E-46C5E7C13739}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BEE32E87-4D44-4F15-B01E-46C5E7C13739}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BEE32E87-4D44-4F15-B01E-46C5E7C13739}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BEE32E87-4D44-4F15-B01E-46C5E7C13739}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3B490D63-6A8B-4B11-BD53-B6524964E53D} + EndGlobalSection +EndGlobal diff --git a/src/PObject.cs b/src/PObject.cs new file mode 100644 index 0000000..6081603 --- /dev/null +++ b/src/PObject.cs @@ -0,0 +1,170 @@ +using System.Numerics; +using System.Runtime.CompilerServices; + +namespace Augmenta +{ + public class PObject + { + public int objectID; + private Vector3[] pointsA = new Vector3[0]; + private int pointCount; + public ReadOnlyMemory points => new ReadOnlyMemory(pointsA, 0, pointCount); + + public Matrix4x4 transform; + internal Matrix4x4 parentTransform = Matrix4x4.Identity; + + //cluster + public enum State { Enter = 0, Update = 1, Leave = 2, Ghost = 3 }; + public State state; + + public Vector3 centroid; + public Vector3 velocity; + public Vector3 minBounds; + public Vector3 maxBounds; + //[Range(0, 1)] + public float weight; + + float lastUpdateTime; + + public float killDelayTime = 0; + + public float timeSinceGhost; + public bool drawDebug; + + public enum PositionUpdateMode { None, Centroid, BoxCenter } + public PositionUpdateMode posUpdateMode = PositionUpdateMode.Centroid; + + public enum CoordMode { Absolute, Relative } + public CoordMode pointMode = CoordMode.Relative; + + public delegate void OnRemoveEvent(PObject obj); + public event OnRemoveEvent onRemove; + + + // Update is called once per frame + internal void Update(float time) + { + if (time - lastUpdateTime > .5f) + timeSinceGhost = time; + else + timeSinceGhost = -1; + } + + public void updateData(float time, Span data, int offset) + { + var pos = offset + 1 + 2 * sizeof(int); //packet type (1) + packet size (4) + objectID (4) + while (pos < data.Length) + { + var propertyID = Utils.ReadInt(data, pos); + var propertySize = Utils.ReadInt(data, pos + sizeof(int)); + + if (propertySize < 0) + { + //Debug.LogWarning("Error : property size < 0"); + break; + } + + switch (propertyID) + { + case 0: updatePointsData(data, pos + 2 * sizeof(int)); break; + case 1: updateClusterData(data, pos + 2 * sizeof(int)); break; + } + + pos += propertySize; + } + + lastUpdateTime = time; + } + + void updatePointsData(Span data, int offset) + { + pointCount = Utils.ReadInt(data, offset); + var vectors = Utils.ReadVectors(data, offset + sizeof(int), pointCount * Unsafe.SizeOf()); + + if (pointsA.Length < pointCount) + pointsA = new Vector3[(int)(pointCount * 1.5)]; + + if (pointMode == CoordMode.Absolute) + vectors.CopyTo(pointsA.AsSpan()); + else + { + for (int i = 0; i < vectors.Length; i++) + pointsA[i] = Vector3.Transform(vectors[i], parentTransform); + } + } + + void updateClusterData(Span data, int offset) + { + state = (State)Utils.ReadInt(data, offset); + if (state == State.Leave) //Will leave + { + onRemove(this); + return; + } + + var clusterData = new Vector3[4]; + for (int i = 0; i < 4; i++) + { + var si = offset + sizeof(int) + i * Unsafe.SizeOf(); + + var p = Utils.ReadVector(data, si); + if (pointMode == CoordMode.Absolute) + clusterData[i] = clusterData[i] = p; + else + clusterData[i] = Vector3.Transform(p, parentTransform);// parentTransform.InverseTransformPoint(p); + } + + centroid = clusterData[0]; + velocity = clusterData[1]; + minBounds = clusterData[2]; + maxBounds = clusterData[3]; + weight = Utils.ReadFloat(data, offset + 4 + 4 * Unsafe.SizeOf()); + + switch (posUpdateMode) + { + case PositionUpdateMode.None: + break; + case PositionUpdateMode.Centroid: + transform.Translation = centroid; + break; + case PositionUpdateMode.BoxCenter: + transform.Translation = (minBounds + maxBounds) / 2; + break; + } + } + + public void kill() + { + if (killDelayTime == 0) + { + //Destroy(gameObject); + return; + } + + //points = new Vector3[0]; + //StartCoroutine(killForReal(killDelayTime)); + } + + //IEnumerator killForReal(float timeBeforeKill) + //{ + // yield return new WaitForSeconds(timeBeforeKill); + // Destroy(gameObject); + //} + + //void OnDrawGizmos() + //{ + // if (drawDebug) + // { + // Color c = Color.HSVToRGB((objectID * .1f) % 1, 1, 1); //Color.red;// getColor(); + // if (state == State.Ghost) c = Color.gray / 2; + + // Gizmos.color = c; + // foreach (var p in points) Gizmos.DrawLine(p, p + Vector3.forward * .01f); + + // Gizmos.color = c + Color.white * .3f; + // Gizmos.DrawWireSphere(centroid, .03f); + // Gizmos.DrawWireCube((minBounds + maxBounds) / 2, maxBounds - minBounds); + // } + //} + } +} \ No newline at end of file diff --git a/src/PleiadesClient.cs b/src/PleiadesClient.cs new file mode 100644 index 0000000..993ebf8 --- /dev/null +++ b/src/PleiadesClient.cs @@ -0,0 +1,92 @@ +using System.Numerics; + +namespace Augmenta +{ + public class PleiadesClient + { + public Dictionary objects = new Dictionary(); + Matrix4x4 transform; + + //Call once per frame + public void Update(Matrix4x4 transform) + { + this.transform = transform; + + var objectsToRemove = new List(); + foreach (var o in objects.Values) + if (o.timeSinceGhost > 1) + objectsToRemove.Add(o.objectID); + + foreach (var oid in objectsToRemove) + { + var o = objects[oid]; + objects.Remove(oid); + o.kill(); + } + } + + public void processData(float time, Span data, int offset = 0) + { + var type = data[offset]; + + if (type == 255) //bundle + { + var pos = offset + 1; //offset + sizeof(packettype) + while (pos < data.Length - 5) //-sizeof(packettype) - sizeof(packetsize) + { + var packetSize = Utils.ReadInt(data, pos + 1); //pos + sizeof(packettype) + processData(time, data, pos); + pos += packetSize; + } + } + + //Debug.Log("Packet type : " + type); + + switch (type) + { + case 0: //Object + { + processObject(time, data, offset); + } + break; + + case 1: //Zone + { + processZone(time, data, offset); + } + break; + } + } + + private void processObject(float time, Span data, int offset) + { + var objectID = Utils.ReadInt(data, offset + 1 + sizeof(int)); //offset + sizeof(packettype) + sizeof(packetsize) + + PObject o = null; + if (objects.ContainsKey(objectID)) o = objects[objectID]; + if (o == null) + { + o = new PObject(); + o.objectID = objectID; + o.onRemove += onObjectRemove; + objects.Add(objectID, o); + } + + o.Update(time); + o.parentTransform = transform; + o.updateData(time, data, offset); + } + + void processZone(float time, Span data, int offset) + { + + } + + //events + void onObjectRemove(PObject o) + { + objects.Remove(o.objectID); + o.kill(); + } + } +} \ No newline at end of file diff --git a/src/Utils.cs b/src/Utils.cs new file mode 100644 index 0000000..00df4d5 --- /dev/null +++ b/src/Utils.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace Augmenta +{ + internal static class Utils + { + internal static int ReadInt(Span data, int offset) + { + return MemoryMarshal.Cast(data.Slice(offset))[0]; + } + + internal static float ReadFloat(Span data, int offset) + { + return MemoryMarshal.Cast(data.Slice(offset))[0]; + } + + internal static Vector3 ReadVector(Span data, int offset) + { + return MemoryMarshal.Cast(data.Slice(offset))[0]; + } + internal static Span ReadVectors(Span data, int offset, int length) + { + return MemoryMarshal.Cast(data.Slice(offset, length)); + } + } +}