public override IEnumerable <(string, SchemaType.Context)> Process() { var ctx = SchemaProcessing.LoadSchemaContext(SchemaUri); ctx.IgnoredByCodeEmitter("glTF Property"); yield return("ext.TextureWEBP.g", ctx); }
private static SchemaType.Context ProcessNode() { var ctx = SchemaProcessing.LoadSchemaContext(NodeSchemaUri); ctx.IgnoredByCodeEmitter("glTF Property"); ctx.IgnoredByCodeEmitter("glTF Child of Root Property"); return(ctx); }
public override IEnumerable <(string, SchemaType.Context)> Process() { var ctx = SchemaProcessing.LoadSchemaContext(SchemaUri); ctx.IgnoredByCodeEmitter("glTF Property"); ctx.IgnoredByCodeEmitter("glTF Child of Root Property"); yield return("ext.MeshGpuInstancing.g", ctx); }
public override IEnumerable <(string TargetFileName, SchemaType.Context Schema)> Process() { // load and process schema var ctx = SchemaProcessing.LoadSchemaContext(Constants.MainSchemaFile); // Ignore "glTF Property" because it is completely hand coded. ctx.IgnoredByCodeEmitter("glTF Property"); // We will mimeType "anyof" as a plain string. ctx.Remove("image/jpeg-image/png"); // replace Image.mimeType type from an Enum to String, so we can serialize it with more formats if required ctx.FindClass("Image") .GetField("mimeType") .FieldType = ctx.UseString(); // replace Node.Matrix, Node.Rotation, Node.Scale and Node.Translation with System.Numerics.Vectors types var node = ctx.FindClass("Node"); node.GetField("matrix").SetDataType(typeof(System.Numerics.Matrix4x4), true).RemoveDefaultValue().SetItemsRange(0); node.GetField("rotation").SetDataType(typeof(System.Numerics.Quaternion), true).RemoveDefaultValue().SetItemsRange(0); node.GetField("scale").SetDataType(typeof(System.Numerics.Vector3), true).RemoveDefaultValue().SetItemsRange(0); node.GetField("translation").SetDataType(typeof(System.Numerics.Vector3), true).RemoveDefaultValue().SetItemsRange(0); // replace Material.emissiveFactor with System.Numerics.Vectors types ctx.FindClass("Material") .GetField("emissiveFactor") .SetDataType(typeof(System.Numerics.Vector3), true) .SetDefaultValue("Vector3.Zero") .SetItemsRange(0); // replace Material.baseColorFactor with System.Numerics.Vectors types ctx.FindClass("Material PBR Metallic Roughness") .GetField("baseColorFactor") .SetDataType(typeof(System.Numerics.Vector4), true) .SetDefaultValue("Vector4.One") .SetItemsRange(0); ctx.FindEnum("LINEAR-NEAREST") .SetValue("DEFAULT", 0); ctx.FindEnum("LINEAR-LINEAR_MIPMAP_LINEAR-LINEAR_MIPMAP_NEAREST-NEAREST-NEAREST_MIPMAP_LINEAR-NEAREST_MIPMAP_NEAREST") .SetValue("DEFAULT", 0); // Accessor.type is declared as AnyOfEnum, but also as a STRING, // which can be used by extensions to store non standard values like MAT4x3 ctx.FindClass("Accessor") .GetField("type").SetDataType(typeof(string), true); // Since DimensionType can have additional values other than the ones defined by the schema // we need a "special" value to define it ctx.FindEnum("MAT2-MAT3-MAT4-SCALAR-VEC2-VEC3-VEC4") .SetValue("CUSTOM", 0); yield return("gltf.g", ctx); }
public override IEnumerable <(string, SchemaType.Context)> Process() { var ctx = SchemaProcessing.LoadSchemaContext(SchemaUri); ctx.IgnoredByCodeEmitter("glTF Property"); ctx.IgnoredByCodeEmitter("glTF Child of Root Property"); // ctx.IgnoredByCodeEmitter("Texture Info"); // ctx.IgnoredByCodeEmitter("Material Normal Texture Info"); yield return("ext.Ior.g", ctx); }
private static SchemaType.Context ProcessRoot() { var ctx = SchemaProcessing.LoadSchemaContext(RootSchemaUri); ctx.IgnoredByCodeEmitter("glTF Property"); ctx.IgnoredByCodeEmitter("glTF Child of Root Property"); ctx.FindClass("Articulation") .GetField("pointingVector") .SetDataType(typeof(System.Numerics.Vector3), true) .SetItemsRange(0); return(ctx); }
public override IEnumerable <(string, SchemaType.Context)> Process() { var ctx = SchemaProcessing.LoadSchemaContext(SchemaUri); ctx.IgnoredByCodeEmitter("glTF Property"); ctx.IgnoredByCodeEmitter("glTF Child of Root Property"); ctx.IgnoredByCodeEmitter("Texture Info"); var cls = ctx.FindClass("KHR_materials_emissive_strength glTF extension"); // straightforward extension, nothing to do yield return("ext.MaterialsEmissiveStrength.g", ctx); }
static void Main(string[] args) { SchemaDownload.Syncronize(Constants.RemoteSchemaRepo, Constants.LocalRepoDirectory); var processors = new List <SchemaProcessor>(); // ---------------------------------------------- Add Main Schema processors.Add(new MainSchemaProcessor()); // ---------------------------------------------- Add extensions // material extensions processors.Add(new UnlitExtension()); processors.Add(new IorExtension()); processors.Add(new SheenExtension()); processors.Add(new VolumeExtension()); processors.Add(new SpecularExtension()); processors.Add(new ClearCoatExtension()); processors.Add(new TransmissionExtension()); processors.Add(new EmissiveStrengthExtension()); processors.Add(new SpecularGlossinessExtension()); // lights processors.Add(new LightsPunctualExtension()); // gpu mesh instancing processors.Add(new MeshGpuInstancingExtension()); // textures processors.Add(new TextureTransformExtension()); processors.Add(new TextureDDSExtension()); processors.Add(new TextureWebpExtension()); processors.Add(new TextureKtx2Extension()); processors.Add(new AgiArticulationsExtension()); processors.Add(new AgiStkMetadataExtension()); // ---------------------------------------------- process all files var processes = processors.SelectMany(item => item.Process()); foreach (var(targetFileName, schema) in processes) { System.Console.WriteLine($"Emitting {targetFileName}..."); SchemaProcessing.EmitCodeFromSchema(targetFileName, schema, processors); } }
private static SchemaType.Context ProcessModel() { var ctx = SchemaProcessing.LoadSchemaContext(RootSchemaUri); ctx.IgnoredByCodeEmitter("glTF Property"); ctx.IgnoredByCodeEmitter("glTF Child of Root Property"); ctx.FindClass("light") .GetField("color") .SetDataType(typeof(System.Numerics.Vector3), true) .SetDefaultValue("Vector3.One") .SetItemsRange(0); return(ctx); }
public override IEnumerable <(string, SchemaType.Context)> Process() { var ctx = SchemaProcessing.LoadSchemaContext(SchemaUri); ctx.IgnoredByCodeEmitter("glTF Property"); ctx.IgnoredByCodeEmitter("glTF Child of Root Property"); ctx.IgnoredByCodeEmitter("Texture Info"); ctx.IgnoredByCodeEmitter("Material Normal Texture Info"); ctx.FindClass("KHR_materials_specular glTF extension") .GetField("specularColorFactor") .SetDataType(typeof(System.Numerics.Vector3), true) .SetDefaultValue("Vector3.One") .SetItemsRange(0); yield return("ext.pbrSpecular.g", ctx); }
public override IEnumerable <(string, SchemaType.Context)> Process() { var ctx = SchemaProcessing.LoadSchemaContext(SchemaUri); ctx.IgnoredByCodeEmitter("glTF Property"); ctx.IgnoredByCodeEmitter("glTF Child of Root Property"); var tex = ctx.FindClass("KHR_texture_transform textureInfo extension"); tex.GetField("offset") .SetDataType(typeof(System.Numerics.Vector2), true) .SetDefaultValue("Vector2.Zero") .SetItemsRange(0); tex.GetField("scale") .SetDataType(typeof(System.Numerics.Vector2), true) .SetDefaultValue("Vector2.One") .SetItemsRange(0); yield return("ext.TextureTransform.g", ctx); }