Ext.KHR_Sheen.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using SharpGLTF.SchemaReflection;
  5. namespace SharpGLTF
  6. {
  7. class SheenExtension : SchemaProcessor
  8. {
  9. private static string SchemaUri => Constants.KhronosExtensionPath("KHR_materials_sheen", "material.KHR_materials_sheen.schema.json");
  10. private const string ExtensionRootClassName = "KHR_materials_sheen glTF Material Extension";
  11. public override IEnumerable<(string, SchemaType.Context)> Process()
  12. {
  13. var ctx = SchemaProcessing.LoadSchemaContext(SchemaUri);
  14. ctx.IgnoredByCodeEmitter("glTF Property");
  15. ctx.IgnoredByCodeEmitter("glTF Child of Root Property");
  16. ctx.IgnoredByCodeEmitter("Texture Info");
  17. ctx.IgnoredByCodeEmitter("Material Normal Texture Info");
  18. ctx.FindClass(ExtensionRootClassName)
  19. .GetField("sheenColorFactor")
  20. .SetDataType(typeof(System.Numerics.Vector3), true)
  21. .SetDefaultValue("Vector3.Zero")
  22. .SetItemsRange(0);
  23. ctx.FindClass(ExtensionRootClassName)
  24. .GetField("sheenRoughnessFactor")
  25. .SetDataType(typeof(float), true)
  26. .SetItemsRange(0);
  27. yield return ("ext.Sheen.g", ctx);
  28. }
  29. public override void PrepareTypes(CodeGen.CSharpEmitter newEmitter, SchemaType.Context ctx)
  30. {
  31. newEmitter.SetRuntimeName(ExtensionRootClassName, "MaterialSheen");
  32. }
  33. }
  34. }