Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cesium ext structural metadata #206

Merged
merged 61 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
fdb0680
initial coding ext_structural_metadata
bertt Nov 29, 2023
8611594
got ext_structural_ematdata code generated
bertt Nov 29, 2023
9a893a7
update branch
bertt Nov 30, 2023
fbd3d06
start testing ext_structural_metadata
bertt Nov 30, 2023
cac94fe
adding first ext_structural_metadata test
bertt Nov 30, 2023
2f7d29a
update branch
bertt Dec 5, 2023
dd29197
code cleanup in EXT_Instance_Features
bertt Dec 5, 2023
4b4a974
got the ext_structural_metada - propertyTable working
bertt Dec 5, 2023
8cef54a
add binarytable tests
bertt Dec 6, 2023
22c9b41
add StructuralMetadataSchema
bertt Dec 6, 2023
02f51f3
add more metadata testing
bertt Dec 7, 2023
cf54bdf
code cleanup
bertt Dec 8, 2023
64c3782
add pointcloud test
bertt Dec 12, 2023
d58067b
trying to add color
bertt Dec 13, 2023
1e3de30
implement setColor and MaxColors to 1
bertt Dec 13, 2023
02780d7
fix the pointcloud colors
bertt Dec 13, 2023
1691d5d
get the pointcloud demo with custom attributes working
bertt Dec 13, 2023
9f86549
use schema or schemaUri
bertt Dec 13, 2023
98b56c4
start multiple classes test
bertt Dec 13, 2023
9097ac7
update branch
bertt Dec 13, 2023
06b5950
change null check
bertt Dec 13, 2023
1702dd7
add more to MultipleClasses test
bertt Dec 13, 2023
efb9534
fix the test
bertt Dec 13, 2023
f62c3ef
using OneOf
bertt Dec 14, 2023
dbbf989
improve check one of schema versus schemaUri
bertt Dec 14, 2023
0d4d8dd
refactor propertyTables
bertt Dec 14, 2023
14958a6
fix tests
bertt Dec 14, 2023
dc2ea46
finsih MultipleTables test
bertt Dec 14, 2023
84c7a40
starting with complextypes test
bertt Dec 14, 2023
46a033e
fix tests
bertt Dec 14, 2023
877af01
add first complex type array of byte
bertt Dec 15, 2023
b0e9423
fix the tests
bertt Dec 15, 2023
acfe0b1
add booleans complex types
bertt Dec 15, 2023
4e2344d
add array strings complex type
bertt Dec 18, 2023
98363a6
Merge branch 'master' into add_cesium_ext_structural_metadata
bertt Dec 19, 2023
242ee28
add trimming attribute to custom vertices
bertt Dec 19, 2023
099ea51
add enum complex type
bertt Dec 19, 2023
0feba60
add vector2/vector3/vector4 attributes
bertt Dec 19, 2023
c24b072
add Matrix4x4 as attribute
bertt Dec 19, 2023
09f3ffd
add some tests for binary conversion
bertt Dec 19, 2023
4459b77
add test with multiple feature ids and properties
bertt Dec 19, 2023
815e7c7
fix tests
bertt Dec 19, 2023
965d2a0
fix test 2
bertt Dec 19, 2023
c16d6e6
add textures and propertytable test
bertt Dec 20, 2023
b9a8e7f
fix the test
bertt Dec 20, 2023
3dab41c
add checks for textures
bertt Dec 20, 2023
bce7499
fix simplepropertytexture
bertt Dec 20, 2023
2afa25e
add StructuralMetadataPrimitive
bertt Dec 21, 2023
9d85738
fix the tests
bertt Dec 21, 2023
bd754e3
working on validation
bertt Dec 21, 2023
72a56be
refactor validation
bertt Dec 21, 2023
41a265b
refactor validation
bertt Dec 22, 2023
0183497
use WithMetallicRoughness(imageBuilder)
bertt Dec 22, 2023
5bd1e1a
fixed null checks
bertt Dec 22, 2023
67694cc
add validation on count
bertt Dec 22, 2023
c570bd5
fix references check in ext_instance_features
bertt Dec 22, 2023
13fd9d7
fix verbose codegen project
bertt Dec 27, 2023
187e405
remove Activator.CreateInstance to get size
bertt Dec 27, 2023
6dfc9a2
use RuntimeHelpers.IsReferenceOrContainsReferences<T>
bertt Dec 27, 2023
e75dd9d
reverse target framework netstandard20 check
bertt Dec 27, 2023
a9af095
move BinaryTable class to Memory workspace
bertt Dec 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions build/SharpGLTF.CodeGen/Ext.EXT_Structural_Metadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using SharpGLTF.CodeGen;
using SharpGLTF.SchemaReflection;
using System.Collections.Generic;

namespace SharpGLTF
{
class ExtStructuralMetadataExtension : SchemaProcessor
{
public override string GetTargetProject() { return Constants.CesiumProjectDirectory; }

const string ExtensionPropertyTexturePropertyName = "Property Texture Property in EXT_structural_metadata";

private static string RootSchemaUri => Constants.CustomExtensionsPath("EXT_structural_metadata", "glTF.EXT_structural_metadata.schema.json");
private static string MeshPrimitiveSchemaUri => Constants.CustomExtensionsPath("EXT_structural_metadata", "mesh.primitive.EXT_structural_metadata.schema.json");

public override void PrepareTypes(CSharpEmitter newEmitter, SchemaType.Context ctx)
{
newEmitter.SetRuntimeName("EXT_structural_metadata glTF extension", "EXTStructuralMetaData");
newEmitter.SetRuntimeName("Property Table in EXT_structural_metadata", "PropertyTable");
newEmitter.SetRuntimeName("Schema in EXT_structural_metadata", "StructuralMetadataSchema");
newEmitter.SetRuntimeName("Property Table Property in EXT_structural_metadata", "PropertyTableProperty");
newEmitter.SetRuntimeName("Property Texture in EXT_structural_metadata", "PropertyTexture");
newEmitter.SetRuntimeName("Property Texture Property in EXT_structural_metadata", "PropertyTextureProperty");
newEmitter.SetRuntimeName("Property Attribute Property in EXT_structural_metadata", "PropertyAttributeProperty");
newEmitter.SetRuntimeName("Class Property in EXT_structural_metadata", "ClassProperty");
newEmitter.SetRuntimeName("Class in EXT_structural_metadata", "StructuralMetadataClass");
newEmitter.SetRuntimeName("Enum Value in EXT_structural_metadata", "EnumValue");
newEmitter.SetRuntimeName("Enum in EXT_structural_metadata", "StructuralMetadataEnum");

newEmitter.SetRuntimeName("BOOLEAN-ENUM-MAT2-MAT3-MAT4-SCALAR-STRING-VEC2-VEC3-VEC4", "ElementType");
newEmitter.SetRuntimeName("FLOAT32-FLOAT64-INT16-INT32-INT64-INT8-UINT16-UINT32-UINT64-UINT8", "DataType");
newEmitter.SetRuntimeName("INT16-INT32-INT64-INT8-UINT16-UINT32-UINT64-UINT8", "IntegerType");
newEmitter.SetRuntimeName("UINT16-UINT32-UINT64-UINT8", "StringOffsets");
}

public override IEnumerable<(string TargetFileName, SchemaType.Context Schema)> Process()
{
yield return ("Ext.CESIUM_ext_structural_metadata_root.g", ProcessRoot());
yield return ("Ext.CESIUM_ext_structural_metadata_primitive.g", ProcessMeshPrimitive());
}

private static SchemaType.Context ProcessRoot()
{
var ctx = SchemaProcessing.LoadSchemaContext(RootSchemaUri);
ctx.IgnoredByCodeEmitter("glTF Property");
ctx.IgnoredByCodeEmitter("glTF Child of Root Property");
ctx.IgnoredByCodeEmitter("Texture Info");
var fld = ctx.FindClass(ExtensionPropertyTexturePropertyName).GetField("channels");

// for now we simply remove the default value, it can be set
// in the constructor or on demand when the APIs are Called.
fld.RemoveDefaultValue();


return ctx;
}

private static SchemaType.Context ProcessMeshPrimitive()
{
var ctx = SchemaProcessing.LoadSchemaContext(MeshPrimitiveSchemaUri);
ctx.IgnoredByCodeEmitter("glTF Property");
ctx.IgnoredByCodeEmitter("glTF Child of Root Property");
ctx.IgnoredByCodeEmitter("Texture Info");
return ctx;
}


}
}
3 changes: 3 additions & 0 deletions build/SharpGLTF.CodeGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ static void Main(string[] args)

processors.Add(new ExtInstanceFeaturesExtension());

processors.Add(new ExtStructuralMetadataExtension());


// ---------------------------------------------- process all files

foreach (var processor in processors)
Expand Down
1 change: 1 addition & 0 deletions build/SharpGLTF.CodeGen/SchemaProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static SchemaType.Context LoadSchemaContext(string srcSchema)

var settings = new NJsonSchema.CodeGeneration.CSharp.CSharpGeneratorSettings
{

Namespace = "glTf.POCO",
ClassStyle = NJsonSchema.CodeGeneration.CSharp.CSharpClassStyle.Poco
};
Expand Down
Loading
Loading