diff --git a/src/cs/Vim.G3dNext.Tests/Vim.G3dNext.Tests.csproj b/src/cs/Vim.G3dNext.Tests/Vim.G3dNext.Tests.csproj
deleted file mode 100644
index 032e77f2..00000000
--- a/src/cs/Vim.G3dNext.Tests/Vim.G3dNext.Tests.csproj
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- net6.0
- enable
- enable
-
- false
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
-
-
-
-
-
diff --git a/src/cs/Vim.G3dNext.Tests/VimG3dNextTests.cs b/src/cs/Vim.G3dNext.Tests/VimG3dNextTests.cs
deleted file mode 100644
index 2d357abd..00000000
--- a/src/cs/Vim.G3dNext.Tests/VimG3dNextTests.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using NUnit.Framework;
-using NUnit.Framework.Internal;
-using Vim.BFastLib;
-using Vim.Util.Tests;
-
-namespace Vim.G3dNext.Tests
-{
- [TestFixture]
- public static class VimG3dNextTests
- {
- [Test]
- public static void Can_Read_G3d_From_Vim()
- {
- var g3d = G3dVim.FromVim(TestUtils.ResidencePath);
- Assert.IsNotNull(g3d);
- }
-
- [Test]
- public static void Can_Ignore_Extra_Attributes()
- {
- // Both G3dVim and G3dMaterial share 3 attributes
- // G3dVim contains many more attributes
- // We create a g3dMaterial from the bytes of a g3dVim
- // Shows that extra attributes are ignored as they should.
-
- var g3d = G3dNextTestUtils.CreateTestG3d();
- var g3dMats = new G3dMaterials(g3d.ToBFast());
-
- Assert.IsNotNull(g3dMats);
- Assert.AreEqual(g3d.MaterialColors, g3dMats.MaterialColors);
- Assert.AreEqual(g3d.MaterialGlossiness, g3dMats.MaterialGlossiness);
- Assert.AreEqual(g3d.MaterialSmoothness, g3dMats.MaterialSmoothness);
- }
-
- [Test]
- public static void Can_Write_And_Read()
- {
- var expected = G3dNextTestUtils.CreateTestG3d();
- var g3d = new G3dVim(expected.ToBFast());
- Assert.IsTrue(g3d.Equals(expected));
- }
-
- [Test]
- public static void Can_Merge_two_g3d()
- {
- var g3d = G3dNextTestUtils.CreateTestG3d();
- var merged = g3d.Merge(g3d);
-
- var expected = new G3dVim(
- instanceTransforms: g3d.InstanceTransforms.Concat(g3d.InstanceTransforms).ToArray(),
- instanceMeshes: g3d.InstanceMeshes.Concat(g3d.InstanceMeshes.Select(i => i + g3d.GetMeshCount())).ToArray(),
- instanceParents: g3d.InstanceParents.Concat(g3d.InstanceParents).ToArray(),
- instanceFlags: null,
- meshSubmeshOffsets: g3d.MeshSubmeshOffsets.Concat(g3d.MeshSubmeshOffsets.Select(i => g3d.GetSubmeshCount())).ToArray(),
- submeshIndexOffsets: g3d.SubmeshIndexOffsets.Concat(g3d.SubmeshIndexOffsets.Select(i => i + g3d.GetIndexCount())).ToArray(),
- submeshMaterials: g3d.SubmeshMaterials.Concat(g3d.SubmeshMaterials.Select(i => i + g3d.GetMaterialCount())).ToArray(),
- indices: g3d.Indices.Concat(g3d.Indices.Select(i => i + g3d.Positions.Length)).ToArray(),
- positions: g3d.Positions.Concat(g3d.Positions).ToArray(),
- materialColors: g3d.MaterialColors.Concat(g3d.MaterialColors).ToArray(),
- materialGlossiness: g3d.MaterialGlossiness.Concat(g3d.MaterialGlossiness).ToArray(),
- materialSmoothness: g3d.MaterialSmoothness.Concat(g3d.MaterialSmoothness).ToArray(),
- shapeColors: null,
- shapeWidths: null,
- shapeVertices: null,
- shapeVertexOffsets: null
- );
- Assert.IsTrue(merged.Equals(expected));
- }
- }
-}
-
diff --git a/src/cs/bfast/Vim.BFast/Buffers/BufferExtensions.cs b/src/cs/bfast/Vim.BFast/Buffers/BufferExtensions.cs
index 6260c22b..91fd57c4 100644
--- a/src/cs/bfast/Vim.BFast/Buffers/BufferExtensions.cs
+++ b/src/cs/bfast/Vim.BFast/Buffers/BufferExtensions.cs
@@ -86,5 +86,15 @@ public static Buffer ReadBuffer(this Stream stream, int numBytes)
public static void Write(this Stream stream, IBuffer buffer)
=> buffer.Write(stream);
+
+ public static NamedBuffer Fill(this NamedBuffer buffer, T value) where T : unmanaged
+ {
+ var array = new T[buffer.Data.Length];
+ for (var i = 0; i < array.Length; i++)
+ {
+ array[i] = value;
+ }
+ return array.ToNamedBuffer(buffer.Name);
+ }
}
}
diff --git a/src/cs/g3d/Vim.G3d.AssimpWrapper/AssimpExtensions.cs b/src/cs/g3d/Vim.G3d.AssimpWrapper/AssimpExtensions.cs
deleted file mode 100644
index 80e26239..00000000
--- a/src/cs/g3d/Vim.G3d.AssimpWrapper/AssimpExtensions.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System;
-using System.Linq;
-using Assimp;
-using Vim.LinqArray;
-using Vim.Math3d;
-
-namespace Vim.G3d.AssimpWrapper
-{
- public static class AssimpExtensions
- {
- public static Vector2 ToMath3D(this Vector2D v)
- => new Vector2(v.X, v.Y);
-
- public static Vector3 ToMath3D(this Vector3D v)
- => new Vector3(v.X, v.Y, v.Z);
-
- public static Vector3 ToMath3D(this Color3D v)
- => new Vector3(v.R, v.G, v.B);
-
- public static Vector4 ToMath3D(this Color4D v)
- => new Vector4(v.R, v.G, v.B, v.A);
-
- public static Math3d.Matrix4x4 ToMath3D(this Assimp.Matrix4x4 m)
- => new Math3d.Matrix4x4(
- m.A1, m.A2, m.A3, m.A4,
- m.B1, m.B2, m.B3, m.B4,
- m.C1, m.C2, m.C3, m.C4,
- m.D1, m.D2, m.D3, m.D4);
-
- public static bool IsTriangular(this Mesh mesh)
- => mesh.Faces.All(f => f.IndexCount == 3);
-
- public static G3D ToG3d(this Scene scene)
- {
- var meshes = scene.Meshes.Select(m => m.ToG3D()).ToIArray();
- var nodes = scene.GetNodes().ToIArray();
- if (nodes.Count == 0 || nodes.Count == 1)
- return meshes.Count > 0 ? meshes[0] : G3D.Empty;
-
- var mergedAttributes = meshes.Merge().Attributes.ToList();
-
- var subGeoTransforms = nodes.Select(n => n.Transform.ToMath3D()).ToInstanceTransformAttribute();
- mergedAttributes.Add(subGeoTransforms);
-
- var meshIndices = nodes.Select(n => n.MeshIndex).ToInstanceMeshAttribute();
- mergedAttributes.Add(meshIndices);
-
- return mergedAttributes.ToG3d();
- }
-
- public static G3D ToG3D(this Mesh mesh)
- {
- // The Assimp mesh must be triangulated
- if (mesh.FaceCount == 0)
- return G3D.Empty;
-
- var bldr = new G3DBuilder();
-
- // Note: should be at most 3 for meses, but could 2 for lines, or 1 for point clouds
- var numCornersPerFace = mesh.Faces[0].IndexCount;
- if (numCornersPerFace > 3)
- throw new Exception("The Assimp mesh must be triangulated as a post-process");
- if (numCornersPerFace <= 0)
- throw new Exception("The Assimp mesh has faces without indices");
- foreach (var f in mesh.Faces)
- {
- if (f.IndexCount != numCornersPerFace)
- throw new Exception($"Each face of the assimp mesh must have {numCornersPerFace} corners, but found one with {f.IndexCount}");
- }
- bldr.SetObjectFaceSize(numCornersPerFace);
-
- var indices = mesh.GetIndices();
- if (indices.Length % numCornersPerFace != 0)
- throw new Exception($"The mesh index buffer length {indices.Length} is not divisible by {numCornersPerFace}");
-
- bldr.AddVertices(mesh.Vertices.ToIArray().Select(ToMath3D));
- bldr.AddIndices(indices);
-
- if (mesh.HasTangentBasis)
- bldr.Add(mesh.BiTangents.ToIArray().Select(ToMath3D).ToVertexBitangentAttribute());
-
- if (mesh.HasTangentBasis)
- bldr.Add(mesh.Tangents.ToIArray().Select(x => ToMath3D(x).ToVector4()).ToVertexTangentAttribute());
-
- if (mesh.HasNormals)
- bldr.Add(mesh.Normals.ToIArray().Select(ToMath3D).ToVertexNormalAttribute());
-
- for (var i = 0; i < mesh.TextureCoordinateChannelCount; ++i)
- {
- var uvChannel = mesh.TextureCoordinateChannels[i];
- bldr.Add(uvChannel.ToIArray().Select(ToMath3D).ToVertexUvwAttribute(i));
- }
-
- for (var i = 0; i < mesh.VertexColorChannelCount; ++i)
- {
- var vcChannel = mesh.VertexColorChannels[i];
- bldr.Add(vcChannel.ToIArray().Select(ToMath3D).ToVertexColorAttribute(i));
- }
-
- return bldr.ToG3D();
- }
- }
-}
diff --git a/src/cs/g3d/Vim.G3d.AssimpWrapper/AssimpLoader.cs b/src/cs/g3d/Vim.G3d.AssimpWrapper/AssimpLoader.cs
deleted file mode 100644
index bb0387be..00000000
--- a/src/cs/g3d/Vim.G3d.AssimpWrapper/AssimpLoader.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using Assimp;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using Vim.LinqArray;
-
-namespace Vim.G3d.AssimpWrapper
-{
- public static class AssimpLoader
- {
- public static AssimpContext Context = new AssimpContext();
-
- public class AssimpNode
- {
- public int MeshIndex { get; }
- public Matrix4x4 Transform { get; }
- public AssimpNode(int index, Matrix4x4 transform)
- => (MeshIndex, Transform) = (index, transform);
- }
-
- public static IEnumerable GetNodes(this Scene scene)
- => scene == null || scene.RootNode == null
- ? Enumerable.Empty()
- : GetNodes(scene, scene.RootNode, scene.RootNode.Transform);
-
- public static IEnumerable GetNodes(this Scene scene, Node node, Matrix4x4 transform)
- => node.MeshIndices.Select(idx => new AssimpNode(idx, node.Transform))
- .Concat(node.Children.SelectMany(c => GetNodes(scene, c, transform * c.Transform)));
-
- public static Scene Load(string filePath, bool triangulate = true)
- => Context.ImportFile(filePath, triangulate ? PostProcessSteps.Triangulate : PostProcessSteps.None);
-
- public static bool CanLoad(string filePath)
- => Context.IsImportFormatSupported(Path.GetExtension(filePath));
- }
-}
diff --git a/src/cs/g3d/Vim.G3d.AssimpWrapper/Vim.G3d.AssimpWrapper.csproj b/src/cs/g3d/Vim.G3d.AssimpWrapper/Vim.G3d.AssimpWrapper.csproj
deleted file mode 100644
index 3b567b9f..00000000
--- a/src/cs/g3d/Vim.G3d.AssimpWrapper/Vim.G3d.AssimpWrapper.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- netstandard2.0
- Vim.G3d.AssimpWrapper
-
-
-
-
-
-
-
-
-
-
-
- True
-
-
-
-
diff --git a/src/cs/g3d/Vim.G3dNext.CodeGen/CodeBuilder.cs b/src/cs/g3d/Vim.G3d.CodeGen/CodeBuilder.cs
similarity index 98%
rename from src/cs/g3d/Vim.G3dNext.CodeGen/CodeBuilder.cs
rename to src/cs/g3d/Vim.G3d.CodeGen/CodeBuilder.cs
index 8dd3283a..41013d8f 100644
--- a/src/cs/g3d/Vim.G3dNext.CodeGen/CodeBuilder.cs
+++ b/src/cs/g3d/Vim.G3d.CodeGen/CodeBuilder.cs
@@ -2,7 +2,7 @@
using System.Linq;
using System.Text;
-namespace Vim.G3dNext.CodeGen
+namespace Vim.G3d.CodeGen
{
public class CodeBuilder
{
diff --git a/src/cs/g3d/Vim.G3dNext.CodeGen/Definitions.cs b/src/cs/g3d/Vim.G3d.CodeGen/Definitions.cs
similarity index 99%
rename from src/cs/g3d/Vim.G3dNext.CodeGen/Definitions.cs
rename to src/cs/g3d/Vim.G3d.CodeGen/Definitions.cs
index 9eb47307..8d53e40b 100644
--- a/src/cs/g3d/Vim.G3dNext.CodeGen/Definitions.cs
+++ b/src/cs/g3d/Vim.G3d.CodeGen/Definitions.cs
@@ -1,6 +1,6 @@
using Vim.Math3d;
-namespace Vim.G3dNext.CodeGen
+namespace Vim.G3d.CodeGen
{
internal class Definitions
{
diff --git a/src/cs/g3d/Vim.G3dNext.CodeGen/G3dBuffer.cs b/src/cs/g3d/Vim.G3d.CodeGen/G3dBuffer.cs
similarity index 97%
rename from src/cs/g3d/Vim.G3dNext.CodeGen/G3dBuffer.cs
rename to src/cs/g3d/Vim.G3d.CodeGen/G3dBuffer.cs
index 97cf4ce1..e3763042 100644
--- a/src/cs/g3d/Vim.G3dNext.CodeGen/G3dBuffer.cs
+++ b/src/cs/g3d/Vim.G3d.CodeGen/G3dBuffer.cs
@@ -1,7 +1,7 @@
using System;
using System.Diagnostics;
-namespace Vim.G3dNext.CodeGen
+namespace Vim.G3d.CodeGen
{
public enum BufferType
{
diff --git a/src/cs/g3d/Vim.G3dNext.CodeGen/G3dCodeGen.cs b/src/cs/g3d/Vim.G3d.CodeGen/G3dCodeGen.cs
similarity index 89%
rename from src/cs/g3d/Vim.G3dNext.CodeGen/G3dCodeGen.cs
rename to src/cs/g3d/Vim.G3d.CodeGen/G3dCodeGen.cs
index 5724b22f..773342cc 100644
--- a/src/cs/g3d/Vim.G3dNext.CodeGen/G3dCodeGen.cs
+++ b/src/cs/g3d/Vim.G3d.CodeGen/G3dCodeGen.cs
@@ -2,7 +2,7 @@
using System.IO;
using System.Linq;
-namespace Vim.G3dNext.CodeGen
+namespace Vim.G3d.CodeGen
{
public static class G3dCodeGen
{
@@ -16,7 +16,7 @@ public static void WriteDocument(string filePath)
cb.AppendLine("// ReSharper disable All");
cb.AppendLine("using Vim.BFastLib;");
cb.AppendLine();
- cb.AppendLine("namespace Vim.G3dNext");
+ cb.AppendLine("namespace Vim.G3d");
cb.AppendLine("{");
WriteEntities(cb);
cb.AppendLine("}");
@@ -85,6 +85,11 @@ public BFast ToBFast()
return bfast;
}}
+ public {entity.ClassName} Clone()
+ {{
+ return this.MemberwiseClone() as {entity.ClassName};
+ }}
+
public bool Equals({entity.ClassName} other )
{{
return {string.Join(" && \n \t\t\t", entity.Buffers.Select(b =>
@@ -113,6 +118,14 @@ public bool Equals({entity.ClassName} other )
);
}}
+ public int CountOf(string name)
+ {{
+ {string.Join("\n \t\t\t", entity.Buffers.Select(c => {
+ return $"if(name == \"{c.BufferName}\") return {c.MemberName}?.Length ?? -1;";
+ }))}
+ return -1;
+ }}
+
public void Validate()
{{
// Ensure all the indices are either -1 or within the bounds of the attributes they are indexing into.
diff --git a/src/cs/g3d/Vim.G3dNext.CodeGen/G3dEntity.cs b/src/cs/g3d/Vim.G3d.CodeGen/G3dEntity.cs
similarity index 96%
rename from src/cs/g3d/Vim.G3dNext.CodeGen/G3dEntity.cs
rename to src/cs/g3d/Vim.G3d.CodeGen/G3dEntity.cs
index 2be5f9e7..5c224c31 100644
--- a/src/cs/g3d/Vim.G3dNext.CodeGen/G3dEntity.cs
+++ b/src/cs/g3d/Vim.G3d.CodeGen/G3dEntity.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
-namespace Vim.G3dNext.CodeGen
+namespace Vim.G3d.CodeGen
{
///
/// Holds the data to generate the code for a g3d entity.
diff --git a/src/cs/g3d/Vim.G3dNext.CodeGen/Program.cs b/src/cs/g3d/Vim.G3d.CodeGen/Program.cs
similarity index 85%
rename from src/cs/g3d/Vim.G3dNext.CodeGen/Program.cs
rename to src/cs/g3d/Vim.G3d.CodeGen/Program.cs
index 5470fb2f..6bf7d644 100644
--- a/src/cs/g3d/Vim.G3dNext.CodeGen/Program.cs
+++ b/src/cs/g3d/Vim.G3d.CodeGen/Program.cs
@@ -1,4 +1,4 @@
-namespace Vim.G3dNext.CodeGen
+namespace Vim.G3d.CodeGen
{
public static class Program
{
diff --git a/src/cs/g3d/Vim.G3dNext.CodeGen/Vim.G3dNext.CodeGen.csproj b/src/cs/g3d/Vim.G3d.CodeGen/Vim.G3d.CodeGen.csproj
similarity index 79%
rename from src/cs/g3d/Vim.G3dNext.CodeGen/Vim.G3dNext.CodeGen.csproj
rename to src/cs/g3d/Vim.G3d.CodeGen/Vim.G3d.CodeGen.csproj
index 41239fb1..74a5126c 100644
--- a/src/cs/g3d/Vim.G3dNext.CodeGen/Vim.G3dNext.CodeGen.csproj
+++ b/src/cs/g3d/Vim.G3d.CodeGen/Vim.G3d.CodeGen.csproj
@@ -7,7 +7,7 @@
Exe
- Vim.G3dNext.CodeGen.Program
+ Vim.G3d.CodeGen.Program
@@ -15,7 +15,7 @@
-
+
diff --git a/src/cs/Vim.G3dNext.Tests/G3dNextTestUtils.cs b/src/cs/g3d/Vim.G3d.Tests/G3dTestUtils.cs
similarity index 94%
rename from src/cs/Vim.G3dNext.Tests/G3dNextTestUtils.cs
rename to src/cs/g3d/Vim.G3d.Tests/G3dTestUtils.cs
index 118167fb..9bd3b033 100644
--- a/src/cs/Vim.G3dNext.Tests/G3dNextTestUtils.cs
+++ b/src/cs/g3d/Vim.G3d.Tests/G3dTestUtils.cs
@@ -1,8 +1,8 @@
using Vim.Math3d;
-namespace Vim.G3dNext.Tests
+namespace Vim.G3d.Tests
{
- public static class G3dNextTestUtils
+ public static class G3dTestUtils
{
public static G3dVim CreateTestG3d()
{
diff --git a/src/cs/g3d/Vim.G3d.Tests/G3dTests.cs b/src/cs/g3d/Vim.G3d.Tests/G3dTests.cs
index fa9f38ed..c23b45e0 100644
--- a/src/cs/g3d/Vim.G3d.Tests/G3dTests.cs
+++ b/src/cs/g3d/Vim.G3d.Tests/G3dTests.cs
@@ -1,315 +1,81 @@
-using Assimp;
using NUnit.Framework;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using NUnit.Framework.Internal;
using Vim.BFastLib;
-using Vim.G3d.AssimpWrapper;
-using Vim.LinqArray;
-using Vim.Math3d;
+using Vim.Util.Tests;
namespace Vim.G3d.Tests
{
[TestFixture]
- public static class G3dTests
+ public static class VimG3dTests
{
- public class FileLoadData
- {
- public FileLoadData(string filePath)
- => SourceFile = new FileInfo(filePath);
-
- public string ShortName => Path.GetFileName(SourceFile.FullName);
- public int NumMeshes => Scene?.MeshCount ?? 0;
- public FileInfo SourceFile;
- public FileInfo G3DFile;
- public long MSecToOpen;
- public long MSecToSaveG3d;
- public long MSecToOpenG3d;
- public long MSecToConvert;
- public long MemoryConsumption;
- public long MemoryConsumptionG3d;
- public Exception Error;
- public Scene Scene;
- public G3D G3d;
- }
-
- public static readonly string ProjectFolder = new DirectoryInfo(Properties.Resources.ProjDir.Trim()).FullName;
- public static string RootFolder = Path.Combine(ProjectFolder, "..", "..", "..", "..");
- public static string TestInputFolder = Path.Combine(RootFolder, "data", "g3d-test-data", "models");
- public static string TestOutputFolder = Path.Combine(RootFolder, "data", "g3d-test-data", "output");
-
- [SetUp]
- public static void Setup()
- {
- if (!Directory.Exists(RootFolder))
- {
- Directory.CreateDirectory(RootFolder);
- }
- if (!Directory.Exists(TestInputFolder))
- {
- Directory.CreateDirectory(TestInputFolder);
- }
- if (!Directory.Exists(TestOutputFolder))
- {
- Directory.CreateDirectory(TestOutputFolder);
- }
- }
-
- public static IEnumerable GetInputFiles()
- => Directory.GetFiles(TestInputFolder, "*.*", SearchOption.AllDirectories);
-
- public static void ValidateSame(Object a, Object b, string name = "")
- {
- if (!a.Equals(b))
- throw new Exception($"Values {a} and {b} are different {name}");
- }
-
- public static void ValidateSameG3D(G3D g1, G3D g2)
+ [Test]
+ public static void Can_Read_G3d_From_Vim()
{
- ValidateSame(g1.NumCornersPerFace, g2.NumCornersPerFace, "NumCornersPerFace");
- ValidateSame(g1.NumFaces, g2.NumFaces, "NumFaces");
- ValidateSame(g1.NumCorners, g2.NumCorners, "NumCorners");
- ValidateSame(g1.NumVertices, g2.NumVertices, "NumVertices");
- ValidateSame(g1.NumInstances, g2.NumInstances, "NumInstances");
- ValidateSame(g1.NumMeshes, g2.NumMeshes, "NumMeshes");
- ValidateSame(g1.Attributes.Count, g2.Attributes.Count, "NumAttributes");
- for (var i = 0; i < g1.Attributes.Count; ++i)
- {
- var attr1 = g1.Attributes[i];
- var attr2 = g2.Attributes[i];
- ValidateSame(attr1.Name, attr2.Name, $"Attribute[{i}].Name");
- ValidateSame(attr1.GetByteSize(), attr2.GetByteSize(), $"Attribute[{i}].ByteSize");
- ValidateSame(attr1.ElementCount, attr2.ElementCount, $"Attribute[{i}].ElementCount");
- }
+ var g3d = G3dVim.FromVim(TestUtils.ResidencePath);
+ Assert.IsNotNull(g3d);
}
[Test]
- [Platform(Exclude = "Linux,Unix", Reason = "AssimpNet is failing to load its dependency on 'libdl.so'.")]
- public static void OpenAndConvertAssimpFiles()
+ public static void Can_Ignore_Extra_Attributes()
{
- var files = GetInputFiles()
- .Where(AssimpLoader.CanLoad)
- .Select(f => new FileLoadData(f))
- .ToArray();
-
- // Load all the files
- foreach (var f in files)
- {
- try
- {
- (f.MemoryConsumption, f.MSecToOpen) =
- Util.GetMemoryConsumptionAndMSecElapsed(() =>
- f.Scene = AssimpLoader.Load(f.SourceFile.FullName));
- }
- catch (Exception e)
- {
- f.Error = e;
- }
- }
-
- // Convert all the Assimp scenes to G3D
- foreach (var f in files)
- {
- if (f.Scene == null) continue;
-
- try
- {
- f.MSecToConvert = Util.GetMSecElapsed(() =>
- f.G3d = f.Scene.ToG3d());
- }
- catch (Exception e)
- {
- f.Error = e;
- }
- }
-
- // Save all the G3D scenes
- Util.CreateAndClearDirectory(TestOutputFolder);
- foreach (var f in files)
- {
- if (f.G3d == null) continue;
-
- try
- {
- var outputFilePath = Path.Combine(TestOutputFolder, f.ShortName + ".g3d");
- f.G3DFile = new FileInfo(outputFilePath);
-
- f.MSecToSaveG3d = Util.GetMSecElapsed(() =>
- f.G3d.ToBFast().Write(outputFilePath));
- }
- catch (Exception e)
- {
- f.Error = e;
- }
- }
-
- // Try reading back in all of the G3D scenes, measure load times and the memory consumption
- foreach (var f in files)
- {
- if (f.G3DFile == null) continue;
-
- try
- {
- G3D localG3d = null;
-
- (f.MemoryConsumptionG3d, f.MSecToOpenG3d) =
- Util.GetMemoryConsumptionAndMSecElapsed(() =>
- localG3d = G3D.Read(f.G3DFile.FullName));
-
- ValidateSameG3D(f.G3d, localG3d);
- }
- catch (Exception e)
- {
- f.Error = e;
- }
- }
-
- // Output the header for data
- Console.WriteLine(
- "Importer," +
- "Extension," +
- "File Name," +
- "File Size(KB)," +
- "Load Time(s)," +
- "Memory(KB)," +
- "# Meshes," +
- "Time to Convert," +
- "Time to Write G3D," +
- "G3D File Size(KB)," +
- "G3D Memory(KB)",
- "G3D Load Time(s)",
- "Error");
-
- // Output the data rows
- foreach (var f in files)
- {
- Console.WriteLine(
- "Assimp," +
- $"{Path.GetExtension(f.ShortName)}," +
- $"{f.ShortName}," +
- $"{f.SourceFile?.Length / 1000}," +
- $"{f.MSecToOpen / 100f}," +
- $"{f.MemoryConsumption / 1000}," +
- $"{f.NumMeshes}," +
- $"{f.MSecToConvert / 100f}," +
- $"{f.MSecToSaveG3d / 100f}," +
- $"{f.G3DFile?.Length / 1000}," +
- $"{f.MemoryConsumptionG3d / 1000}," +
- $"{f.MSecToOpenG3d / 100f}," +
- $"{f.Error}");
- }
-
- Assert.AreEqual(0, files.Count(f => f.Error != null), "Errors occurred");
+ // Both G3dVim and G3dMaterial share 3 attributes
+ // G3dVim contains many more attributes
+ // We create a g3dMaterial from the bytes of a g3dVim
+ // Shows that extra attributes are ignored as they should.
+
+ var g3d = G3dTestUtils.CreateTestG3d();
+ var g3dMats = new G3dMaterials(g3d.ToBFast());
+
+ Assert.IsNotNull(g3dMats);
+ Assert.AreEqual(g3d.MaterialColors, g3dMats.MaterialColors);
+ Assert.AreEqual(g3d.MaterialGlossiness, g3dMats.MaterialGlossiness);
+ Assert.AreEqual(g3d.MaterialSmoothness, g3dMats.MaterialSmoothness);
}
[Test]
- public static void TriangleTest()
+ public static void Can_Write_And_Read()
{
- // Serialize a triangle g3d as bytes and read it back.
- var vertices = new[]
- {
- new Vector3(0, 0, 0),
- new Vector3(0, 1, 0),
- new Vector3(0, 1, 1)
- };
-
- var indices = new[] { 0, 1, 2 };
- var materialIndices = new[] { 5 };
-
- var g3d = new G3DBuilder()
- .AddVertices(vertices.ToIArray())
- .AddIndices(indices.ToIArray())
- .Add(materialIndices.ToIArray().ToFaceMaterialAttribute())
- .ToG3D();
-
- var bfast = g3d.ToBFast();
- var g = G3D.Read(bfast);
-
- Assert.IsNotNull(g);
-
- Assert.AreEqual(3, g.NumVertices);
- Assert.AreEqual(3, g.NumCorners);
- Assert.AreEqual(1, g.NumFaces);
- Assert.AreEqual(3, g.NumCornersPerFace);
- Assert.AreEqual(0, g.NumMeshes);
- Assert.AreEqual(0, g.NumInstances);
-
- Assert.AreEqual(vertices, g.Vertices.ToArray());
- Assert.AreEqual(indices, g.Indices.ToArray());
- Assert.AreEqual(materialIndices, g.FaceMaterials.ToArray());
+ var expected = G3dTestUtils.CreateTestG3d();
+ var g3d = new G3dVim(expected.ToBFast());
+ Assert.IsTrue(g3d.Equals(expected));
}
- [Test]
- public static void UnexpectedAttributes_Are_Ignored()
- {
- var bfast = new BFast();
- bfast.SetArray("g3d:instance:potato:0:int32:1", new int[] { 5 });
- var g = G3D.Read(bfast);
- var parsedInstanceAttrs = g.Attributes.Where(ga => ga.Descriptor.Association == Association.assoc_instance).ToArray();
- var parsedPotatoAttr = parsedInstanceAttrs.Single(ga => ga.Descriptor.Semantic == "potato");
- Assert.AreEqual(new [] { 5 }, parsedPotatoAttr.AsType().Data.ToArray());
- }
- public static G3D LoadAssimpFile(string filePath)
+ [Test]
+ public static void Can_Merge_two_g3d()
{
- using (var context = new AssimpContext())
- {
- var scene = context.ImportFile(filePath);
- Assert.AreEqual(1, scene.Meshes.Count);
- return scene.Meshes[0].ToG3D();
- }
+ var g3d = G3dTestUtils.CreateTestG3d();
+ var merged = g3d.Merge(g3d);
+
+ var expected = new G3dVim(
+ instanceTransforms: g3d.InstanceTransforms.Concat(g3d.InstanceTransforms).ToArray(),
+ instanceMeshes: g3d.InstanceMeshes.Concat(g3d.InstanceMeshes.Select(i => i + g3d.GetMeshCount())).ToArray(),
+ instanceParents: g3d.InstanceParents.Concat(g3d.InstanceParents).ToArray(),
+ instanceFlags: null,
+ meshSubmeshOffsets: g3d.MeshSubmeshOffsets.Concat(g3d.MeshSubmeshOffsets.Select(i => g3d.GetSubmeshCount())).ToArray(),
+ submeshIndexOffsets: g3d.SubmeshIndexOffsets.Concat(g3d.SubmeshIndexOffsets.Select(i => i + g3d.GetIndexCount())).ToArray(),
+ submeshMaterials: g3d.SubmeshMaterials.Concat(g3d.SubmeshMaterials.Select(i => i + g3d.GetMaterialCount())).ToArray(),
+ indices: g3d.Indices.Concat(g3d.Indices.Select(i => i + g3d.Positions.Length)).ToArray(),
+ positions: g3d.Positions.Concat(g3d.Positions).ToArray(),
+ materialColors: g3d.MaterialColors.Concat(g3d.MaterialColors).ToArray(),
+ materialGlossiness: g3d.MaterialGlossiness.Concat(g3d.MaterialGlossiness).ToArray(),
+ materialSmoothness: g3d.MaterialSmoothness.Concat(g3d.MaterialSmoothness).ToArray(),
+ shapeColors: null,
+ shapeWidths: null,
+ shapeVertices: null,
+ shapeVertexOffsets: null
+ );
+ Assert.IsTrue(merged.Equals(expected));
}
- // NOTE: can't be run as part of NUnit because it requires the GC
- public static void BigFileTest()
- {
- var nVerts = (300 * 1000 * 1000); // 300 * 12 = 3.6 GB
- var vertices = nVerts.Select(i => new Vector3(i, i, i));
- var bldr = new G3DBuilder();
- bldr.AddVertices(vertices);
-
- var expectedG3d = bldr.ToG3D();
- Assert.AreEqual(nVerts, expectedG3d.NumVertices);
- var bfast = expectedG3d.ToBFast();
- var resultG3d = G3D.Read(bfast);
-
- ValidateSameG3D(expectedG3d, resultG3d);
- }
- [Test, Explicit]
- [Platform(Exclude = "Linux,Unix", Reason = "AssimpNet is failing to load its dependency on 'libdl.so'.")]
- public static void TestWriters()
+ [Test]
+ public static void Clone_IsEqual()
{
- var fileName = Path.Combine(TestInputFolder, "PLY", "Wuson.ply");
-
- var outputFileName = @"test";
- outputFileName = Path.Combine(TestOutputFolder, outputFileName);
-
- var g3d = LoadAssimpFile(fileName);
-
- g3d.WritePly(outputFileName + ".ply");
- g3d.WriteObj(outputFileName + ".obj");
-
- // TODO compare the PLY, the OBJ and the original file.
-
- var g3dFromPly = LoadAssimpFile(outputFileName + ".ply");
- //var g3dFromObj = LoadAssimpFile(outputFileName + ".obj");
-
- {
- var g1 = g3d;
- var g2 = g3dFromPly;
- Assert.AreEqual(g1.NumCornersPerFace, g2.NumCornersPerFace);
- Assert.AreEqual(g1.NumFaces, g2.NumFaces);
- Assert.AreEqual(g1.NumCorners, g2.NumCorners);
- Assert.AreEqual(g1.NumVertices, g2.NumVertices);
- Assert.AreEqual(g1.NumInstances, g2.NumInstances);
- Assert.AreEqual(g1.NumMeshes, g2.NumMeshes);
- }
-
- // BUG: Assimp ignores the OBJ index buffer. God knows why.
- //CompareG3D(g3d, g3dFromObj);
+ var g3d = G3dTestUtils.CreateTestG3d();
+ Assert.IsTrue(g3d.Equals(g3d.Clone()));
}
}
}
+
diff --git a/src/cs/g3d/Vim.G3d.Tests/Properties/Resources.Designer.cs b/src/cs/g3d/Vim.G3d.Tests/Properties/Resources.Designer.cs
deleted file mode 100644
index dba826c3..00000000
--- a/src/cs/g3d/Vim.G3d.Tests/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace Vim.G3d.Tests.Properties {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Vim.G3d.Tests.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to C:\Users\Rober\Desktop\Vim\vim-format\src\cs\g3d\Vim.G3d.Tests\
- ///.
- ///
- internal static string ProjDir {
- get {
- return ResourceManager.GetString("ProjDir", resourceCulture);
- }
- }
- }
-}
diff --git a/src/cs/g3d/Vim.G3d.Tests/Properties/Resources.resx b/src/cs/g3d/Vim.G3d.Tests/Properties/Resources.resx
deleted file mode 100644
index 579dd3b6..00000000
--- a/src/cs/g3d/Vim.G3d.Tests/Properties/Resources.resx
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- ..\Resources\ProjDir.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
-
-
\ No newline at end of file
diff --git a/src/cs/g3d/Vim.G3d.Tests/Resources/.gitignore b/src/cs/g3d/Vim.G3d.Tests/Resources/.gitignore
deleted file mode 100644
index d8fff56a..00000000
--- a/src/cs/g3d/Vim.G3d.Tests/Resources/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-ProjDir.txt
\ No newline at end of file
diff --git a/src/cs/g3d/Vim.G3d.Tests/Util.cs b/src/cs/g3d/Vim.G3d.Tests/Util.cs
deleted file mode 100644
index 2ff62684..00000000
--- a/src/cs/g3d/Vim.G3d.Tests/Util.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-
-namespace Vim.G3d.Tests
-{
- public static class Util
- {
- public static (long, long) GetMemoryConsumptionAndMSecElapsed(Action action)
- {
- var time = 0L;
- var mem = GetMemoryConsumption(
- () => time = GetMSecElapsed(action));
- return (mem, time);
- }
-
- public static long GetMSecElapsed(Action action)
- {
- var sw = Stopwatch.StartNew();
- action();
- return sw.ElapsedMilliseconds;
- }
-
- ///
- /// Creates a directory if needed, or clears all of its contents otherwise
- ///
- public static string CreateAndClearDirectory(string dirPath)
- {
- if (!Directory.Exists(dirPath))
- Directory.CreateDirectory(dirPath);
- else
- DeleteFolderContents(dirPath);
- return dirPath;
- }
-
- ///
- /// Deletes all contents in a folder
- ///
- ///
- /// https://stackoverflow.com/questions/1288718/how-to-delete-all-files-and-folders-in-a-directory
- ///
- private static void DeleteFolderContents(string folderPath)
- {
- var di = new DirectoryInfo(folderPath);
- foreach (var dir in di.EnumerateDirectories().AsParallel())
- DeleteFolderAndAllContents(dir.FullName);
- foreach (var file in di.EnumerateFiles().AsParallel())
- file.Delete();
- }
-
- ///
- /// Deletes everything in a folder and then the folder.
- ///
- private static void DeleteFolderAndAllContents(string folderPath)
- {
- if (!Directory.Exists(folderPath))
- return;
-
- DeleteFolderContents(folderPath);
- Directory.Delete(folderPath);
- }
-
- // NOTE: Calling a function generates additional memory
- private static long GetMemoryConsumption(Action action)
- {
- GC.Collect();
- GC.WaitForPendingFinalizers();
- var memBefore = GC.GetTotalMemory(true);
- action();
- GC.Collect();
- GC.WaitForPendingFinalizers();
- return GC.GetTotalMemory(true) - memBefore;
- }
- }
-}
\ No newline at end of file
diff --git a/src/cs/g3d/Vim.G3d.Tests/Vim.G3d.Tests.csproj b/src/cs/g3d/Vim.G3d.Tests/Vim.G3d.Tests.csproj
index ae2d33e9..e56190a6 100644
--- a/src/cs/g3d/Vim.G3d.Tests/Vim.G3d.Tests.csproj
+++ b/src/cs/g3d/Vim.G3d.Tests/Vim.G3d.Tests.csproj
@@ -1,45 +1,29 @@
-
- net6.0
- false
-
+
+ net6.0
+ enable
+ enable
-
-
-
-
-
+ false
+ true
+
-
-
-
-
-
-
+
+
+
+
+
-
-
- True
- True
- Resources.resx
-
-
+
+
+
+
+
+
+ True
+
+
+
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
-
-
-
-
-
-
- True
-
-
-
diff --git a/src/cs/g3d/Vim.G3d/AttributeDescriptor.cs b/src/cs/g3d/Vim.G3d/AttributeDescriptor.cs
deleted file mode 100644
index a2f48840..00000000
--- a/src/cs/g3d/Vim.G3d/AttributeDescriptor.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-using System;
-
-namespace Vim.G3d
-{
- ///
- /// Provides information about identifying the role and parsing the data within an attribute data buffer.
- /// This is encoded using a string in a particular URN form.
- ///
- public class AttributeDescriptor
- {
- public Association Association { get; }
- public string Semantic { get; }
- public DataType DataType { get; }
- public int DataArity { get; }
- public int Index { get; }
-
- public int DataElementSize { get; }
- public int DataTypeSize { get; }
- public string Name { get; }
-
- public AttributeDescriptor(Association association, string semantic, DataType dataType, int dataArity, int index = 0)
- {
- Association = association;
- if (semantic.Contains(":"))
- throw new Exception("The semantic must not contain a semicolon");
- Semantic = semantic;
- DataType = dataType;
- DataArity = dataArity;
- Index = index;
- DataTypeSize = GetDataTypeSize(DataType);
- DataElementSize = DataTypeSize * DataArity;
- Name = $"g3d:{AssociationString}:{Semantic}:{Index}:{DataTypeString}:{DataArity}";
- }
-
- ///
- /// Generates a URN representation of the attribute descriptor
- ///
- public override string ToString()
- => Name;
-
- ///
- /// Returns true if the attribute descriptor has been successfully parsed.
- ///
- public static bool TryParse(string urn, out AttributeDescriptor attributeDescriptor)
- {
- attributeDescriptor = null;
- try
- {
- attributeDescriptor = Parse(urn);
- }
- catch
- {
- // do nothing.
- }
-
- return attributeDescriptor != null;
- }
-
- ///
- /// Parses a URN representation of the attribute descriptor to generate an actual attribute descriptor
- ///
- public static AttributeDescriptor Parse(string urn)
- {
- var vals = urn.Split(':');
- if (vals.Length != 6) throw new Exception("Expected 6 parts to the attribute descriptor URN");
- if (vals[0] != "g3d") throw new Exception("First part of URN must be g3d");
- return new AttributeDescriptor(
- ParseAssociation(vals[1]),
- vals[2],
- ParseDataType(vals[4]),
- int.Parse(vals[5]),
- int.Parse(vals[3])
- );
- }
-
- public bool Validate()
- {
- var urn = ToString();
- var tmp = Parse(urn);
- if (!Equals(tmp))
- throw new Exception("Invalid attribute descriptor (or internal error in the parsing/string conversion");
- return true;
- }
-
- public bool Equals(AttributeDescriptor other)
- => ToString() == other.ToString();
-
- public static int GetDataTypeSize(DataType dt)
- {
- switch (dt)
- {
- case DataType.dt_uint8:
- case DataType.dt_int8:
- return 1;
- case DataType.dt_uint16:
- case DataType.dt_int16:
- return 2;
- case DataType.dt_uint32:
- case DataType.dt_int32:
- return 4;
- case DataType.dt_uint64:
- case DataType.dt_int64:
- return 8;
- case DataType.dt_float32:
- return 4;
- case DataType.dt_float64:
- return 8;
- default:
- throw new ArgumentOutOfRangeException(nameof(dt), dt, null);
- }
- }
-
- public string AssociationString
- => Association.ToString().Substring("assoc_".Length);
-
- public static Association ParseAssociation(string s)
- {
- switch (s)
- {
- case "all":
- return Association.assoc_all;
- case "corner":
- return Association.assoc_corner;
- case "edge":
- return Association.assoc_edge;
- case "face":
- return Association.assoc_face;
- case "instance":
- return Association.assoc_instance;
- case "vertex":
- return Association.assoc_vertex;
- case "shapevertex":
- return Association.assoc_shapevertex;
- case "shape":
- return Association.assoc_shape;
- case "material":
- return Association.assoc_material;
- case "mesh":
- return Association.assoc_mesh;
- case "submesh":
- return Association.assoc_submesh;
-
- // Anything else we just treat as unknown
- default:
- return Association.assoc_none;
- }
- }
-
- public string DataTypeString
- => DataType.ToString()?.Substring("dt_".Length) ?? null;
-
- public static DataType ParseDataType(string s)
- => (DataType)Enum.Parse(typeof(DataType), "dt_" + s);
-
- public AttributeDescriptor SetIndex(int index)
- => new AttributeDescriptor(Association, Semantic, DataType, DataArity, index);
- }
-}
diff --git a/src/cs/g3d/Vim.G3d/AttributeExtensions.cs b/src/cs/g3d/Vim.G3d/AttributeExtensions.cs
deleted file mode 100644
index 98fb02fa..00000000
--- a/src/cs/g3d/Vim.G3d/AttributeExtensions.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using Vim.LinqArray;
-using Vim.Math3d;
-
-namespace Vim.G3d
-{
- public static class AttributeExtensions
- {
- public static GeometryAttribute CheckArity(this GeometryAttribute self, int arity) where T : unmanaged
- => self?.Descriptor?.DataArity == arity ? self : null;
-
- public static GeometryAttribute CheckAssociation(this GeometryAttribute self, Association assoc) where T : unmanaged
- => self?.Descriptor?.Association == assoc ? self : null;
-
- public static GeometryAttribute CheckArityAndAssociation(this GeometryAttribute self, int arity, Association assoc) where T : unmanaged
- => self?.CheckArity(arity)?.CheckAssociation(assoc);
-
- public static GeometryAttribute ToAttribute(this IList self, string desc) where T : unmanaged
- => self.ToIArray().ToAttribute(desc);
-
- public static GeometryAttribute ToAttribute(this IList self, AttributeDescriptor desc) where T : unmanaged
- => self.ToIArray().ToAttribute(desc);
-
- public static GeometryAttribute ToAttribute(this IArray self, AttributeDescriptor desc) where T : unmanaged
- => new GeometryAttribute(self, desc);
-
- public static GeometryAttribute ToAttribute(this IArray self, string desc) where T : unmanaged
- => self.ToAttribute(AttributeDescriptor.Parse(desc));
-
- public static GeometryAttribute ToAttribute(this IArray self, string desc, int index) where T : unmanaged
- => self.ToAttribute(AttributeDescriptor.Parse(desc).SetIndex(index));
-
- public static IArray AttributeToColors(this GeometryAttribute attr)
- {
- var desc = attr.Descriptor;
- if (desc.DataType == DataType.dt_float32)
- {
- if (desc.DataArity == 4)
- return attr.AsType().Data;
- if (desc.DataArity == 3)
- return attr.AsType().Data.Select(vc => new Vector4(vc, 1f));
- if (desc.DataArity == 2)
- return attr.AsType().Data.Select(vc => new Vector4(vc.X, vc.Y, 0, 1f));
- if (desc.DataArity == 1)
- return attr.AsType().Data.Select(vc => new Vector4(vc, vc, vc, 1f));
- }
- if (desc.DataType == DataType.dt_int8)
- {
- if (desc.DataArity == 4)
- return attr.AsType().Data.Select(b => new Vector4(b.X / 255f, b.Y / 255f, b.Z / 255f, b.W / 255f));
- if (desc.DataArity == 3)
- return attr.AsType().Data.Select(b => new Vector4(b.X / 255f, b.Y / 255f, b.Z / 255f, 1f));
- if (desc.DataArity == 2)
- return attr.AsType().Data.Select(b => new Vector4(b.X / 255f, b.Y / 255f, 0f, 1f));
- if (desc.DataArity == 1)
- return attr.AsType().Data.Select(b => new Vector4(b / 255f, b / 255f, b / 255f, 1f));
- }
- Debug.WriteLine($"Failed to recongize color format {attr.Descriptor}");
- return null;
- }
-
- public static GeometryAttribute ToDefaultAttribute(this AttributeDescriptor desc, int count)
- {
- switch (desc.DataType)
- {
- // TODO: TECH DEBT - Add unsigned tuple objects to Math3d
- case DataType.dt_uint8:
- if (desc.DataArity == 1)
- return default(byte).Repeat(count).ToAttribute(desc);
- break;
- case DataType.dt_int8:
- if (desc.DataArity == 1)
- return default(byte).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 2)
- return default(Byte2).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 3)
- return default(Byte3).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 4)
- return default(Byte4).Repeat(count).ToAttribute(desc);
- break;
- case DataType.dt_uint16:
- if (desc.DataArity == 1)
- return default(ushort).Repeat(count).ToAttribute(desc);
- break;
- case DataType.dt_int16:
- if (desc.DataArity == 1)
- return default(short).Repeat(count).ToAttribute(desc);
- break;
- case DataType.dt_uint32:
- if (desc.DataArity == 1)
- return default(uint).Repeat(count).ToAttribute(desc);
- break;
- case DataType.dt_int32:
- if (desc.DataArity == 1)
- return default(int).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 2)
- return default(Int2).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 3)
- return default(Int3).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 4)
- return default(Int4).Repeat(count).ToAttribute(desc);
- break;
- case DataType.dt_uint64:
- if (desc.DataArity == 1)
- return default(ulong).Repeat(count).ToAttribute(desc);
- break;
- case DataType.dt_int64:
- if (desc.DataArity == 1)
- return default(long).Repeat(count).ToAttribute(desc);
- break;
- case DataType.dt_float32:
- if (desc.DataArity == 1)
- return default(float).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 2)
- return default(Vector2).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 3)
- return default(Vector3).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 4)
- return default(Vector4).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 16)
- return default(Matrix4x4).Repeat(count).ToAttribute(desc);
- break;
- case DataType.dt_float64:
- if (desc.DataArity == 1)
- return default(double).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 2)
- return default(DVector2).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 3)
- return default(DVector3).Repeat(count).ToAttribute(desc);
- if (desc.DataArity == 4)
- return default(DVector4).Repeat(count).ToAttribute(desc);
- break;
- }
-
- throw new Exception($"Could not create a default attribute for {desc}");
- }
-
- public static long GetByteSize(this GeometryAttribute attribute)
- => (long)attribute.ElementCount * attribute.Descriptor.DataElementSize;
-
- public static GeometryAttribute Merge(this IEnumerable attributes)
- => attributes.FirstOrDefault()?.Merge(attributes.Skip(1));
-
- public static GeometryAttribute Merge(this IArray attributes)
- => attributes.ToEnumerable().Merge();
- }
-}
diff --git a/src/cs/g3d/Vim.G3dNext/BufferMethods.cs b/src/cs/g3d/Vim.G3d/BufferMethods.cs
similarity index 98%
rename from src/cs/g3d/Vim.G3dNext/BufferMethods.cs
rename to src/cs/g3d/Vim.G3d/BufferMethods.cs
index e4f74d70..c7330f7e 100644
--- a/src/cs/g3d/Vim.G3dNext/BufferMethods.cs
+++ b/src/cs/g3d/Vim.G3d/BufferMethods.cs
@@ -2,7 +2,7 @@
using System.IO;
using System.Linq;
-namespace Vim.G3dNext
+namespace Vim.G3d
{
public static class BufferMethods
{
diff --git a/src/cs/g3d/Vim.G3d/CommonAttributes.cs b/src/cs/g3d/Vim.G3d/CommonAttributes.cs
deleted file mode 100644
index da835913..00000000
--- a/src/cs/g3d/Vim.G3d/CommonAttributes.cs
+++ /dev/null
@@ -1,231 +0,0 @@
-
-// AUTOGENERATED FILE: DO NOT EDIT
-// This file is generated from CommonAttributeExtensions.tt
-
-
-using Vim.LinqArray;
-using Vim.Math3d;
-
-namespace Vim.G3d
-{
- public static class CommonAttributes
- {
-
- public const string ObjectFaceSize = "g3d:all:facesize:0:int32:1";
- public const string Index = "g3d:corner:index:0:int32:1";
- public const string Position = "g3d:vertex:position:0:float32:3";
- public const string VertexUv = "g3d:vertex:uv:0:float32:2";
- public const string VertexUvw = "g3d:vertex:uv:0:float32:3";
- public const string VertexNormal = "g3d:vertex:normal:0:float32:3";
- public const string VertexColor = "g3d:vertex:color:0:float32:4";
- public const string VertexColor8Bit = "g3d:vertex:color:0:int8:4";
- public const string VertexBitangent = "g3d:vertex:bitangent:0:float32:3";
- public const string VertexTangent = "g3d:vertex:tangent:0:float32:4";
- public const string VertexSelectionWeight = "g3d:vertex:weight:0:float32:1";
- public const string FaceColor = "g3d:face:color:0:float32:4";
- public const string FaceMaterial = "g3d:face:material:0:int32:1";
- public const string FaceNormal = "g3d:face:normal:0:float32:3";
- public const string MeshSubmeshOffset = "g3d:mesh:submeshoffset:0:int32:1";
- public const string InstanceTransform = "g3d:instance:transform:0:float32:16";
- public const string InstanceParent = "g3d:instance:parent:0:int32:1";
- public const string InstanceMesh = "g3d:instance:mesh:0:int32:1";
- public const string InstanceFlags = "g3d:instance:flags:0:uint16:1";
- public const string LineTangentIn = "g3d:vertex:tangent:0:float32:3";
- public const string LineTangentOut = "g3d:vertex:tangent:1:float32:3";
- public const string ShapeVertex = "g3d:shapevertex:position:0:float32:3";
- public const string ShapeVertexOffset = "g3d:shape:vertexoffset:0:int32:1";
- public const string ShapeColor = "g3d:shape:color:0:float32:4";
- public const string ShapeWidth = "g3d:shape:width:0:float32:1";
- public const string MaterialColor = "g3d:material:color:0:float32:4";
- public const string MaterialGlossiness = "g3d:material:glossiness:0:float32:1";
- public const string MaterialSmoothness = "g3d:material:smoothness:0:float32:1";
- public const string SubmeshIndexOffset = "g3d:submesh:indexoffset:0:int32:1";
- public const string SubmeshMaterial = "g3d:submesh:material:0:int32:1";
- }
-
- public static class CommonAttributeExtensions
- {
-
- public static GeometryAttribute ToObjectFaceSizeAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.ObjectFaceSize, index);
- public static GeometryAttribute ToObjectFaceSizeAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.ObjectFaceSize);
- public static GeometryAttribute ToObjectFaceSizeAttribute(this int[] xs, int index) => xs.ToIArray().ToObjectFaceSizeAttribute(index);
- public static GeometryAttribute ToObjectFaceSizeAttribute(this int[] xs) => xs.ToIArray().ToObjectFaceSizeAttribute();
- public static GeometryAttribute GetAttributeObjectFaceSize(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.ObjectFaceSize);
- public static IArray GetAttributeDataObjectFaceSize(this IGeometryAttributes self) => self.GetAttributeObjectFaceSize()?.Data;
- public static GeometryAttribute ToIndexAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.Index, index);
- public static GeometryAttribute ToIndexAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.Index);
- public static GeometryAttribute ToIndexAttribute(this int[] xs, int index) => xs.ToIArray().ToIndexAttribute(index);
- public static GeometryAttribute ToIndexAttribute(this int[] xs) => xs.ToIArray().ToIndexAttribute();
- public static GeometryAttribute GetAttributeIndex(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.Index);
- public static IArray GetAttributeDataIndex(this IGeometryAttributes self) => self.GetAttributeIndex()?.Data;
- public static GeometryAttribute ToPositionAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.Position, index);
- public static GeometryAttribute ToPositionAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.Position);
- public static GeometryAttribute ToPositionAttribute(this Vector3[] xs, int index) => xs.ToIArray().ToPositionAttribute(index);
- public static GeometryAttribute ToPositionAttribute(this Vector3[] xs) => xs.ToIArray().ToPositionAttribute();
- public static GeometryAttribute GetAttributePosition(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.Position);
- public static IArray GetAttributeDataPosition(this IGeometryAttributes self) => self.GetAttributePosition()?.Data;
- public static GeometryAttribute ToVertexUvAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.VertexUv, index);
- public static GeometryAttribute ToVertexUvAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.VertexUv);
- public static GeometryAttribute ToVertexUvAttribute(this Vector2[] xs, int index) => xs.ToIArray().ToVertexUvAttribute(index);
- public static GeometryAttribute ToVertexUvAttribute(this Vector2[] xs) => xs.ToIArray().ToVertexUvAttribute();
- public static GeometryAttribute GetAttributeVertexUv(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.VertexUv);
- public static IArray GetAttributeDataVertexUv(this IGeometryAttributes self) => self.GetAttributeVertexUv()?.Data;
- public static GeometryAttribute ToVertexUvwAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.VertexUvw, index);
- public static GeometryAttribute ToVertexUvwAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.VertexUvw);
- public static GeometryAttribute ToVertexUvwAttribute(this Vector3[] xs, int index) => xs.ToIArray().ToVertexUvwAttribute(index);
- public static GeometryAttribute ToVertexUvwAttribute(this Vector3[] xs) => xs.ToIArray().ToVertexUvwAttribute();
- public static GeometryAttribute GetAttributeVertexUvw(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.VertexUvw);
- public static IArray GetAttributeDataVertexUvw(this IGeometryAttributes self) => self.GetAttributeVertexUvw()?.Data;
- public static GeometryAttribute ToVertexNormalAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.VertexNormal, index);
- public static GeometryAttribute ToVertexNormalAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.VertexNormal);
- public static GeometryAttribute ToVertexNormalAttribute(this Vector3[] xs, int index) => xs.ToIArray().ToVertexNormalAttribute(index);
- public static GeometryAttribute ToVertexNormalAttribute(this Vector3[] xs) => xs.ToIArray().ToVertexNormalAttribute();
- public static GeometryAttribute GetAttributeVertexNormal(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.VertexNormal);
- public static IArray GetAttributeDataVertexNormal(this IGeometryAttributes self) => self.GetAttributeVertexNormal()?.Data;
- public static GeometryAttribute ToVertexColorAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.VertexColor, index);
- public static GeometryAttribute ToVertexColorAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.VertexColor);
- public static GeometryAttribute ToVertexColorAttribute(this Vector4[] xs, int index) => xs.ToIArray().ToVertexColorAttribute(index);
- public static GeometryAttribute ToVertexColorAttribute(this Vector4[] xs) => xs.ToIArray().ToVertexColorAttribute();
- public static GeometryAttribute GetAttributeVertexColor(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.VertexColor);
- public static IArray GetAttributeDataVertexColor(this IGeometryAttributes self) => self.GetAttributeVertexColor()?.Data;
- public static GeometryAttribute ToVertexColor8BitAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.VertexColor8Bit, index);
- public static GeometryAttribute ToVertexColor8BitAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.VertexColor8Bit);
- public static GeometryAttribute ToVertexColor8BitAttribute(this Byte4[] xs, int index) => xs.ToIArray().ToVertexColor8BitAttribute(index);
- public static GeometryAttribute ToVertexColor8BitAttribute(this Byte4[] xs) => xs.ToIArray().ToVertexColor8BitAttribute();
- public static GeometryAttribute GetAttributeVertexColor8Bit(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.VertexColor8Bit);
- public static IArray GetAttributeDataVertexColor8Bit(this IGeometryAttributes self) => self.GetAttributeVertexColor8Bit()?.Data;
- public static GeometryAttribute ToVertexBitangentAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.VertexBitangent, index);
- public static GeometryAttribute ToVertexBitangentAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.VertexBitangent);
- public static GeometryAttribute ToVertexBitangentAttribute(this Vector3[] xs, int index) => xs.ToIArray().ToVertexBitangentAttribute(index);
- public static GeometryAttribute ToVertexBitangentAttribute(this Vector3[] xs) => xs.ToIArray().ToVertexBitangentAttribute();
- public static GeometryAttribute GetAttributeVertexBitangent(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.VertexBitangent);
- public static IArray GetAttributeDataVertexBitangent(this IGeometryAttributes self) => self.GetAttributeVertexBitangent()?.Data;
- public static GeometryAttribute ToVertexTangentAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.VertexTangent, index);
- public static GeometryAttribute ToVertexTangentAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.VertexTangent);
- public static GeometryAttribute ToVertexTangentAttribute(this Vector4[] xs, int index) => xs.ToIArray().ToVertexTangentAttribute(index);
- public static GeometryAttribute ToVertexTangentAttribute(this Vector4[] xs) => xs.ToIArray().ToVertexTangentAttribute();
- public static GeometryAttribute GetAttributeVertexTangent(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.VertexTangent);
- public static IArray GetAttributeDataVertexTangent(this IGeometryAttributes self) => self.GetAttributeVertexTangent()?.Data;
- public static GeometryAttribute ToVertexSelectionWeightAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.VertexSelectionWeight, index);
- public static GeometryAttribute ToVertexSelectionWeightAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.VertexSelectionWeight);
- public static GeometryAttribute ToVertexSelectionWeightAttribute(this float[] xs, int index) => xs.ToIArray().ToVertexSelectionWeightAttribute(index);
- public static GeometryAttribute ToVertexSelectionWeightAttribute(this float[] xs) => xs.ToIArray().ToVertexSelectionWeightAttribute();
- public static GeometryAttribute GetAttributeVertexSelectionWeight(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.VertexSelectionWeight);
- public static IArray GetAttributeDataVertexSelectionWeight(this IGeometryAttributes self) => self.GetAttributeVertexSelectionWeight()?.Data;
- public static GeometryAttribute ToFaceColorAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.FaceColor, index);
- public static GeometryAttribute ToFaceColorAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.FaceColor);
- public static GeometryAttribute ToFaceColorAttribute(this Vector4[] xs, int index) => xs.ToIArray().ToFaceColorAttribute(index);
- public static GeometryAttribute ToFaceColorAttribute(this Vector4[] xs) => xs.ToIArray().ToFaceColorAttribute();
- public static GeometryAttribute GetAttributeFaceColor(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.FaceColor);
- public static IArray GetAttributeDataFaceColor(this IGeometryAttributes self) => self.GetAttributeFaceColor()?.Data;
- public static GeometryAttribute ToFaceMaterialAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.FaceMaterial, index);
- public static GeometryAttribute ToFaceMaterialAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.FaceMaterial);
- public static GeometryAttribute ToFaceMaterialAttribute(this int[] xs, int index) => xs.ToIArray().ToFaceMaterialAttribute(index);
- public static GeometryAttribute ToFaceMaterialAttribute(this int[] xs) => xs.ToIArray().ToFaceMaterialAttribute();
- public static GeometryAttribute GetAttributeFaceMaterial(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.FaceMaterial);
- public static IArray GetAttributeDataFaceMaterial(this IGeometryAttributes self) => self.GetAttributeFaceMaterial()?.Data;
- public static GeometryAttribute ToFaceNormalAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.FaceNormal, index);
- public static GeometryAttribute ToFaceNormalAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.FaceNormal);
- public static GeometryAttribute ToFaceNormalAttribute(this Vector3[] xs, int index) => xs.ToIArray().ToFaceNormalAttribute(index);
- public static GeometryAttribute ToFaceNormalAttribute(this Vector3[] xs) => xs.ToIArray().ToFaceNormalAttribute();
- public static GeometryAttribute GetAttributeFaceNormal(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.FaceNormal);
- public static IArray GetAttributeDataFaceNormal(this IGeometryAttributes self) => self.GetAttributeFaceNormal()?.Data;
- public static GeometryAttribute ToMeshSubmeshOffsetAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.MeshSubmeshOffset, index);
- public static GeometryAttribute ToMeshSubmeshOffsetAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.MeshSubmeshOffset);
- public static GeometryAttribute ToMeshSubmeshOffsetAttribute(this int[] xs, int index) => xs.ToIArray().ToMeshSubmeshOffsetAttribute(index);
- public static GeometryAttribute ToMeshSubmeshOffsetAttribute(this int[] xs) => xs.ToIArray().ToMeshSubmeshOffsetAttribute();
- public static GeometryAttribute GetAttributeMeshSubmeshOffset(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.MeshSubmeshOffset);
- public static IArray GetAttributeDataMeshSubmeshOffset(this IGeometryAttributes self) => self.GetAttributeMeshSubmeshOffset()?.Data;
- public static GeometryAttribute ToInstanceTransformAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.InstanceTransform, index);
- public static GeometryAttribute ToInstanceTransformAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.InstanceTransform);
- public static GeometryAttribute ToInstanceTransformAttribute(this Matrix4x4[] xs, int index) => xs.ToIArray().ToInstanceTransformAttribute(index);
- public static GeometryAttribute ToInstanceTransformAttribute(this Matrix4x4[] xs) => xs.ToIArray().ToInstanceTransformAttribute();
- public static GeometryAttribute GetAttributeInstanceTransform(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.InstanceTransform);
- public static IArray GetAttributeDataInstanceTransform(this IGeometryAttributes self) => self.GetAttributeInstanceTransform()?.Data;
- public static GeometryAttribute ToInstanceParentAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.InstanceParent, index);
- public static GeometryAttribute ToInstanceParentAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.InstanceParent);
- public static GeometryAttribute ToInstanceParentAttribute(this int[] xs, int index) => xs.ToIArray().ToInstanceParentAttribute(index);
- public static GeometryAttribute ToInstanceParentAttribute(this int[] xs) => xs.ToIArray().ToInstanceParentAttribute();
- public static GeometryAttribute GetAttributeInstanceParent(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.InstanceParent);
- public static IArray GetAttributeDataInstanceParent(this IGeometryAttributes self) => self.GetAttributeInstanceParent()?.Data;
- public static GeometryAttribute ToInstanceMeshAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.InstanceMesh, index);
- public static GeometryAttribute ToInstanceMeshAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.InstanceMesh);
- public static GeometryAttribute ToInstanceMeshAttribute(this int[] xs, int index) => xs.ToIArray().ToInstanceMeshAttribute(index);
- public static GeometryAttribute ToInstanceMeshAttribute(this int[] xs) => xs.ToIArray().ToInstanceMeshAttribute();
- public static GeometryAttribute GetAttributeInstanceMesh(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.InstanceMesh);
- public static IArray GetAttributeDataInstanceMesh(this IGeometryAttributes self) => self.GetAttributeInstanceMesh()?.Data;
- public static GeometryAttribute ToInstanceFlagsAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.InstanceFlags, index);
- public static GeometryAttribute ToInstanceFlagsAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.InstanceFlags);
- public static GeometryAttribute ToInstanceFlagsAttribute(this ushort[] xs, int index) => xs.ToIArray().ToInstanceFlagsAttribute(index);
- public static GeometryAttribute ToInstanceFlagsAttribute(this ushort[] xs) => xs.ToIArray().ToInstanceFlagsAttribute();
- public static GeometryAttribute GetAttributeInstanceFlags(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.InstanceFlags);
- public static IArray GetAttributeDataInstanceFlags(this IGeometryAttributes self) => self.GetAttributeInstanceFlags()?.Data;
- public static GeometryAttribute ToLineTangentInAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.LineTangentIn, index);
- public static GeometryAttribute ToLineTangentInAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.LineTangentIn);
- public static GeometryAttribute ToLineTangentInAttribute(this Vector3[] xs, int index) => xs.ToIArray().ToLineTangentInAttribute(index);
- public static GeometryAttribute ToLineTangentInAttribute(this Vector3[] xs) => xs.ToIArray().ToLineTangentInAttribute();
- public static GeometryAttribute GetAttributeLineTangentIn(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.LineTangentIn);
- public static IArray GetAttributeDataLineTangentIn(this IGeometryAttributes self) => self.GetAttributeLineTangentIn()?.Data;
- public static GeometryAttribute ToLineTangentOutAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.LineTangentOut, index);
- public static GeometryAttribute ToLineTangentOutAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.LineTangentOut);
- public static GeometryAttribute ToLineTangentOutAttribute(this Vector3[] xs, int index) => xs.ToIArray().ToLineTangentOutAttribute(index);
- public static GeometryAttribute ToLineTangentOutAttribute(this Vector3[] xs) => xs.ToIArray().ToLineTangentOutAttribute();
- public static GeometryAttribute GetAttributeLineTangentOut(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.LineTangentOut);
- public static IArray GetAttributeDataLineTangentOut(this IGeometryAttributes self) => self.GetAttributeLineTangentOut()?.Data;
- public static GeometryAttribute ToShapeVertexAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.ShapeVertex, index);
- public static GeometryAttribute ToShapeVertexAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.ShapeVertex);
- public static GeometryAttribute ToShapeVertexAttribute(this Vector3[] xs, int index) => xs.ToIArray().ToShapeVertexAttribute(index);
- public static GeometryAttribute ToShapeVertexAttribute(this Vector3[] xs) => xs.ToIArray().ToShapeVertexAttribute();
- public static GeometryAttribute GetAttributeShapeVertex(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.ShapeVertex);
- public static IArray GetAttributeDataShapeVertex(this IGeometryAttributes self) => self.GetAttributeShapeVertex()?.Data;
- public static GeometryAttribute ToShapeVertexOffsetAttribute(this IArray xs, int index) => xs.ToAttribute(CommonAttributes.ShapeVertexOffset, index);
- public static GeometryAttribute ToShapeVertexOffsetAttribute(this IArray xs) => xs.ToAttribute(CommonAttributes.ShapeVertexOffset);
- public static GeometryAttribute ToShapeVertexOffsetAttribute(this int[] xs, int index) => xs.ToIArray().ToShapeVertexOffsetAttribute(index);
- public static GeometryAttribute ToShapeVertexOffsetAttribute(this int[] xs) => xs.ToIArray().ToShapeVertexOffsetAttribute();
- public static GeometryAttribute GetAttributeShapeVertexOffset(this IGeometryAttributes self) => self.GetAttribute(CommonAttributes.ShapeVertexOffset);
- public static IArray