|
@@ -1,20 +1,17 @@
|
|
|
using SharpGLTF.Validation;
|
|
using SharpGLTF.Validation;
|
|
|
-using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace SharpGLTF.Schema2
|
|
namespace SharpGLTF.Schema2
|
|
|
{
|
|
{
|
|
|
public partial class EXTStructuralMetaDataRoot
|
|
public partial class EXTStructuralMetaDataRoot
|
|
|
{
|
|
{
|
|
|
|
|
+ private ModelRoot modelRoot;
|
|
|
|
|
+
|
|
|
internal EXTStructuralMetaDataRoot(ModelRoot modelRoot)
|
|
internal EXTStructuralMetaDataRoot(ModelRoot modelRoot)
|
|
|
{
|
|
{
|
|
|
this.modelRoot = modelRoot;
|
|
this.modelRoot = modelRoot;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private ModelRoot modelRoot;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
internal List<PropertyTable> PropertyTables
|
|
internal List<PropertyTable> PropertyTables
|
|
|
{
|
|
{
|
|
|
get { return _propertyTables; }
|
|
get { return _propertyTables; }
|
|
@@ -40,15 +37,17 @@ namespace SharpGLTF.Schema2
|
|
|
_classes = new Dictionary<string, StructuralMetadataClass>();
|
|
_classes = new Dictionary<string, StructuralMetadataClass>();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public Dictionary<string, StructuralMetadataClass> Classes { get; set; }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
partial class PropertyTable
|
|
partial class PropertyTable
|
|
|
{
|
|
{
|
|
|
- public PropertyTable()
|
|
|
|
|
|
|
+ public PropertyTable(string PropertyTableName, int numberOfFeatures)
|
|
|
{
|
|
{
|
|
|
|
|
+ _class = PropertyTableName;
|
|
|
|
|
+ _count = numberOfFeatures;
|
|
|
_properties = new Dictionary<string, PropertyTableProperty>();
|
|
_properties = new Dictionary<string, PropertyTableProperty>();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
partial class PropertyTableProperty
|
|
partial class PropertyTableProperty
|
|
@@ -69,8 +68,34 @@ namespace SharpGLTF.Schema2
|
|
|
|
|
|
|
|
public static class ExtStructuralMetadata
|
|
public static class ExtStructuralMetadata
|
|
|
{
|
|
{
|
|
|
|
|
+ // Creates EXTStructuralMetaData with Schema and 1 PropertyTable
|
|
|
|
|
+ public static void InitializeMetadataExtension(this ModelRoot modelRoot, string propertyTableName, int numberOfFeatures)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (propertyTableName == null) { modelRoot.RemoveExtensions<EXTStructuralMetaDataRoot>(); return; }
|
|
|
|
|
+
|
|
|
|
|
+ var ext = modelRoot.UseExtension<EXTStructuralMetaDataRoot>();
|
|
|
|
|
+
|
|
|
|
|
+ var schema = GetInitialSchema(propertyTableName);
|
|
|
|
|
+ ext.Schema = schema;
|
|
|
|
|
+ var propertyTable = new PropertyTable(propertyTableName, numberOfFeatures);
|
|
|
|
|
+ ext.PropertyTables = new List<PropertyTable>() { propertyTable };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static void AddMetadata<T>(this ModelRoot modelRoot, string fieldname, List<T> values)
|
|
public static void AddMetadata<T>(this ModelRoot modelRoot, string fieldname, List<T> values)
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private static StructuralMetadataSchema GetInitialSchema(string schemaName)
|
|
|
|
|
+ {
|
|
|
|
|
+ var structuralMetadataSchema = new StructuralMetadataSchema();
|
|
|
|
|
+ var structuralMetadataClass = new StructuralMetadataClass();
|
|
|
|
|
+
|
|
|
|
|
+ structuralMetadataSchema.Classes = new Dictionary<string, StructuralMetadataClass>
|
|
|
|
|
+ {
|
|
|
|
|
+ { schemaName , structuralMetadataClass }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ return structuralMetadataSchema;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|