Browse Source

Try adding some AGI extension schemas.

Ed Mackey 4 years ago
parent
commit
a3ca7d8663

+ 3 - 0
build/SharpGLTF.CodeGen/Constants.cs

@@ -68,6 +68,9 @@ namespace SharpGLTF
             public static string TextureDDS => _Path("MSFT_texture_dds", "glTF.MSFT_texture_dds.schema.json");
             public static string TextureWebp => _Path("EXT_texture_webp", "glTF.EXT_texture_webp.schema.json");
             public static string MeshGpuInstancing => _Path("EXT_mesh_gpu_instancing", "glTF.EXT_mesh_gpu_instancing.schema.json");
+
+            public static string RootAgiArticulations => _Path("AGI_articulations", "glTF.AGI_articulations.schema.json");
+            public static string NodeAgiArticulations => _Path("AGI_articulations", "node.AGI_articulations.schema.json");
         }
 
         #endregion

+ 20 - 1
build/SharpGLTF.CodeGen/Program.cs

@@ -44,11 +44,13 @@ namespace SharpGLTF
             _ProcessKhronosTextureTransformExtension();
             _ProcessMicrosoftTextureDDSExtension();
             _ProcessTextureWebpExtension();
-            _ProcessTextureKtx2Extension();            
+            _ProcessTextureKtx2Extension();
 
             // these extansions are not fully supported and temporarily removed:
             // _ProcessDracoExtension();
             // _ProcessMicrosoftLODExtension();
+
+            _ProcessAgiArticulationsExtension();
         }
 
         #endregion
@@ -307,6 +309,21 @@ namespace SharpGLTF
             ProcessSchema("ext.MeshGpuInstancing.g", ctx);
         }
 
+        private static void _ProcessAgiArticulationsExtension()
+        {
+            var ctx1 = LoadSchemaContext(Constants.VendorExtensions.RootAgiArticulations);
+            ctx1.IgnoredByCodeEmitter("glTF Property");
+            ctx1.IgnoredByCodeEmitter("glTF Child of Root Property");
+
+            ProcessSchema("ext.RootAgiArticulations.g", ctx1);
+
+            var ctx2 = LoadSchemaContext(Constants.VendorExtensions.NodeAgiArticulations);
+            ctx2.IgnoredByCodeEmitter("glTF Property");
+            ctx2.IgnoredByCodeEmitter("glTF Child of Root Property");
+
+            ProcessSchema("ext.NodeAgiArticulations.g", ctx2);
+        }
+
         #endregion
 
         #region code generation
@@ -377,6 +394,8 @@ namespace SharpGLTF
 
             newEmitter.SetRuntimeName("EXT_mesh_gpu_instancing glTF extension", "MeshGpuInstancing");
 
+            newEmitter.SetRuntimeName("uniformScale-xRotate-xScale-xTranslate-yRotate-yScale-yTranslate-zRotate-zScale-zTranslate", "ArticulationTransformType");
+
             var classes = ctx.Classes.ToArray();
             var fields = classes.SelectMany(item => item.Fields).ToArray();
 

+ 60 - 0
src/SharpGLTF.Core/Schema2/Generated/ext.NodeAgiArticulations.g.cs

@@ -0,0 +1,60 @@
+// <auto-generated/>
+
+//------------------------------------------------------------------------------------------------
+//      This file has been programatically generated; DON´T EDIT!
+//------------------------------------------------------------------------------------------------
+
+#pragma warning disable SA1001
+#pragma warning disable SA1027
+#pragma warning disable SA1028
+#pragma warning disable SA1121
+#pragma warning disable SA1205
+#pragma warning disable SA1309
+#pragma warning disable SA1402
+#pragma warning disable SA1505
+#pragma warning disable SA1507
+#pragma warning disable SA1508
+#pragma warning disable SA1652
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Numerics;
+using System.Text.Json;
+
+namespace SharpGLTF.Schema2
+{
+	using Collections;
+
+	/// <summary>
+	/// glTF Extension for an individual node in a glTF model, to associate it with the model's root AGI_articulations object.
+	/// </summary>
+	partial class AGI_articulationsglTFNodeextension : ExtraProperties
+	{
+	
+		private String _articulationName;
+		
+		private Boolean? _isAttachPoint;
+		
+	
+		protected override void SerializeProperties(Utf8JsonWriter writer)
+		{
+			base.SerializeProperties(writer);
+			SerializeProperty(writer, "articulationName", _articulationName);
+			SerializeProperty(writer, "isAttachPoint", _isAttachPoint);
+		}
+	
+		protected override void DeserializeProperty(string jsonPropertyName, ref Utf8JsonReader reader)
+		{
+			switch (jsonPropertyName)
+			{
+				case "articulationName": _articulationName = DeserializePropertyValue<String>(ref reader); break;
+				case "isAttachPoint": _isAttachPoint = DeserializePropertyValue<Boolean?>(ref reader); break;
+				default: base.DeserializeProperty(jsonPropertyName,ref reader); break;
+			}
+		}
+	
+	}
+
+}

+ 154 - 0
src/SharpGLTF.Core/Schema2/Generated/ext.RootAgiArticulations.g.cs

@@ -0,0 +1,154 @@
+// <auto-generated/>
+
+//------------------------------------------------------------------------------------------------
+//      This file has been programatically generated; DON´T EDIT!
+//------------------------------------------------------------------------------------------------
+
+#pragma warning disable SA1001
+#pragma warning disable SA1027
+#pragma warning disable SA1028
+#pragma warning disable SA1121
+#pragma warning disable SA1205
+#pragma warning disable SA1309
+#pragma warning disable SA1402
+#pragma warning disable SA1505
+#pragma warning disable SA1507
+#pragma warning disable SA1508
+#pragma warning disable SA1652
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Numerics;
+using System.Text.Json;
+
+namespace SharpGLTF.Schema2
+{
+	using Collections;
+
+	/// <summary>
+	/// The type of motion applied by this articulation stage.
+	/// </summary>
+	public enum ArticulationTransformType
+	{
+		xTranslate,
+		yTranslate,
+		zTranslate,
+		xRotate,
+		yRotate,
+		zRotate,
+		xScale,
+		yScale,
+		zScale,
+		uniformScale,
+	}
+
+
+	/// <summary>
+	/// One stage of a model articulation definition.
+	/// </summary>
+	partial class ArticulationStage : ExtraProperties
+	{
+	
+		private Double _initialValue;
+		
+		private Double _maximumValue;
+		
+		private Double _minimumValue;
+		
+		private String _name;
+		
+		private ArticulationTransformType _type;
+		
+	
+		protected override void SerializeProperties(Utf8JsonWriter writer)
+		{
+			base.SerializeProperties(writer);
+			SerializeProperty(writer, "initialValue", _initialValue);
+			SerializeProperty(writer, "maximumValue", _maximumValue);
+			SerializeProperty(writer, "minimumValue", _minimumValue);
+			SerializeProperty(writer, "name", _name);
+			SerializePropertyEnumSymbol<ArticulationTransformType>(writer, "type", _type);
+		}
+	
+		protected override void DeserializeProperty(string jsonPropertyName, ref Utf8JsonReader reader)
+		{
+			switch (jsonPropertyName)
+			{
+				case "initialValue": _initialValue = DeserializePropertyValue<Double>(ref reader); break;
+				case "maximumValue": _maximumValue = DeserializePropertyValue<Double>(ref reader); break;
+				case "minimumValue": _minimumValue = DeserializePropertyValue<Double>(ref reader); break;
+				case "name": _name = DeserializePropertyValue<String>(ref reader); break;
+				case "type": _type = DeserializePropertyValue<ArticulationTransformType>(ref reader); break;
+				default: base.DeserializeProperty(jsonPropertyName,ref reader); break;
+			}
+		}
+	
+	}
+
+	/// <summary>
+	/// A model articulation definition.
+	/// </summary>
+	partial class Articulation : ExtraProperties
+	{
+	
+		private String _name;
+		
+		private const int _pointingVectorMinItems = 3;
+		private const int _pointingVectorMaxItems = 3;
+		private List<Double> _pointingVector;
+		
+		private const int _stagesMinItems = 1;
+		private List<ArticulationStage> _stages;
+		
+	
+		protected override void SerializeProperties(Utf8JsonWriter writer)
+		{
+			base.SerializeProperties(writer);
+			SerializeProperty(writer, "name", _name);
+			SerializeProperty(writer, "pointingVector", _pointingVector, _pointingVectorMinItems);
+			SerializeProperty(writer, "stages", _stages, _stagesMinItems);
+		}
+	
+		protected override void DeserializeProperty(string jsonPropertyName, ref Utf8JsonReader reader)
+		{
+			switch (jsonPropertyName)
+			{
+				case "name": _name = DeserializePropertyValue<String>(ref reader); break;
+				case "pointingVector": DeserializePropertyList<Double>(ref reader, _pointingVector); break;
+				case "stages": DeserializePropertyList<ArticulationStage>(ref reader, _stages); break;
+				default: base.DeserializeProperty(jsonPropertyName,ref reader); break;
+			}
+		}
+	
+	}
+
+	/// <summary>
+	/// glTF Extension that defines metadata for applying external analysis or effects to a model.
+	/// </summary>
+	partial class AGI_articulationsglTFextension : ExtraProperties
+	{
+	
+		private const int _articulationsMinItems = 1;
+		private List<Articulation> _articulations;
+		
+	
+		protected override void SerializeProperties(Utf8JsonWriter writer)
+		{
+			base.SerializeProperties(writer);
+			SerializeProperty(writer, "articulations", _articulations, _articulationsMinItems);
+		}
+	
+		protected override void DeserializeProperty(string jsonPropertyName, ref Utf8JsonReader reader)
+		{
+			switch (jsonPropertyName)
+			{
+				case "articulations": DeserializePropertyList<Articulation>(ref reader, _articulations); break;
+				default: base.DeserializeProperty(jsonPropertyName,ref reader); break;
+			}
+		}
+	
+	}
+
+}

+ 24 - 0
src/SharpGLTF.Core/Schema2/agi.Articulations.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SharpGLTF.Schema2
+{
+    public sealed partial class ArticulationStage
+    {
+    }
+
+    public sealed partial class Articulation
+    {
+    }
+
+    public sealed partial class AGI_articulationsglTFextension
+    {
+    }
+
+    public sealed partial class AGI_articulationsglTFNodeextension
+    {
+        public String ArticulationName => _articulationName;
+        public Boolean? IsAttachPoint => _isAttachPoint;
+    }
+}