public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture(); material.MetallicRoughnessMaterial.BaseColorTexture.Sampler = new Runtime.Sampler(); foreach (Property req in requiredProperty) { if (req.name == Propertyname.BaseColorTexture) { material.MetallicRoughnessMaterial.BaseColorTexture.Source = req.value; } } foreach (Property req in specialProperties) { if (req.name == Propertyname.TexCoord) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets[0] = req.value; } } foreach (Property property in combo) { if (property.name == Propertyname.MagFilter_Nearest || property.name == Propertyname.MagFilter_Linear) { material.MetallicRoughnessMaterial.BaseColorTexture.Sampler.MagFilter = property.value; } else if (property.name == Propertyname.MinFilter_Nearest || property.name == Propertyname.MinFilter_Linear || property.name == Propertyname.MinFilter_NearestMipmapNearest || property.name == Propertyname.MinFilter_LinearMipmapNearest || property.name == Propertyname.MinFilter_NearestMipmapLinear || property.name == Propertyname.MinFilter_LinearMipmapLinear) { material.MetallicRoughnessMaterial.BaseColorTexture.Sampler.MinFilter = property.value; } else if (property.name == Propertyname.WrapS_ClampToEdge || property.name == Propertyname.WrapS_MirroredRepeat || property.name == Propertyname.WrapS_Repeat) { material.MetallicRoughnessMaterial.BaseColorTexture.Sampler.WrapS = property.value; } else if (property.name == Propertyname.WrapT_ClampToEdge || property.name == Propertyname.WrapT_MirroredRepeat || property.name == Propertyname.WrapT_Repeat) { material.MetallicRoughnessMaterial.BaseColorTexture.Sampler.WrapT = property.value; } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Switch from the flat plane to a model with multiple nodes wrapper = Common.MultiNode(); var nodeList = new List <Runtime.Node>(); nodeList.Add(wrapper.Scenes[0].Nodes[0]); nodeList.Add(wrapper.Scenes[0].Nodes[0].Children[0]); // Add a new child node that will inherit the transformations nodeList.Add((DeepCopy.CloneObject(wrapper.Scenes[0].Nodes[0]))); nodeList[2].Name = "Node1"; nodeList[2].Children = null; nodeList[1].Children = new List <Runtime.Node>(); nodeList[1].Children.Add(nodeList[2]); // Clear the vertex normal and tangent values already in the model foreach (var node in nodeList) { node.Mesh.MeshPrimitives[0].Normals = null; node.Mesh.MeshPrimitives[0].Tangents = null; } foreach (Property property in combo) { if (property.name == Propertyname.Matrix) { nodeList[1].Matrix = specialProperties[0].value; } else if (property.name == Propertyname.Translation || property.name == Propertyname.Translation_X || property.name == Propertyname.Translation_Y || property.name == Propertyname.Translation_Z) { nodeList[1].Translation = property.value; } else if (property.name == Propertyname.Rotation) { nodeList[1].Rotation = specialProperties[1].value; } else if (property.name == Propertyname.Scale) { nodeList[1].Scale = property.value; } } // Apply the material to each node foreach (var node in nodeList) { node.Mesh.MeshPrimitives[0].Material = material; } return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Remove the base model's UV0 on the empty set if (combo.Count < 0) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets.RemoveAt(0); material.MetallicRoughnessMaterial = null; } foreach (Property property in combo) { if (property.name == Propertyname.BaseColorTexture) { if (material.MetallicRoughnessMaterial == null) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture(); } material.MetallicRoughnessMaterial.BaseColorTexture.Source = property.value; material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 0; } else if (property.name == Propertyname.VertexNormal) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Normals = property.value; } else if (property.name == Propertyname.NormalTexture) { material.NormalTexture = new Runtime.Texture(); material.NormalTexture.Source = property.value; material.NormalTexture.TexCoordIndex = 0; } else if (property.name == Propertyname.VertexTangent) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Tangents = property.value; } else if (property.name == Propertyname.VertexUV0_Float || property.name == Propertyname.VertexUV0_Byte || property.name == Propertyname.VertexUV0_Short) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordsComponentType = property.value; } } if (combo.Count > 0) // Don't set the material on the empty set { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; } return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Remove the base model's UV0 wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets.RemoveAt(0); material.MetallicRoughnessMaterial = null; foreach (Property property in combo) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].ColorComponentType = property.value.componentType; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].ColorType = property.value.type; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Colors = property.value.colors; } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { foreach (Property req in requiredProperty) { if (req.name == Propertyname.AlphaMode_Mask) { material.AlphaMode = req.value; } } foreach (Property property in combo) { if (property.propertyGroup == 3) // Alpha Cutoff { material.AlphaCutoff = property.value; } else if (property.name == Propertyname.BaseColorFactor) { if (material.MetallicRoughnessMaterial == null) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); } material.MetallicRoughnessMaterial.BaseColorFactor = property.value; } else if (property.name == Propertyname.BaseColorTexture) { if (material.MetallicRoughnessMaterial == null) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); } material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture(); material.MetallicRoughnessMaterial.BaseColorTexture.Source = property.value; } else if (property.name == Propertyname.VertexColor_Vector4_Float) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.FLOAT; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC4; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Colors = property.value; } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { foreach (Property req in requiredProperty) { if (req.name == Propertyname.DoubleSided) { material.DoubleSided = req.value; } } foreach (Property property in combo) { if (property.name == Propertyname.DoubleSided) { material.DoubleSided = property.value; } else if (property.name == Propertyname.VertexNormal) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Normals = property.value; } else if (property.name == Propertyname.VertexTangent) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Tangents = property.value; } else if (property.name == Propertyname.NormalTexture) { material.NormalTexture = new Runtime.Texture(); material.NormalTexture.Source = property.value; material.NormalTexture.TexCoordIndex = 0; } else if (property.name == Propertyname.BaseColorTexture) { if (material.MetallicRoughnessMaterial == null) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); } material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture(); material.MetallicRoughnessMaterial.BaseColorTexture.Source = property.value; } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Remove the UVs wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = null; foreach (Property property in combo) { if (property.name == Propertyname.MinVersion) { wrapper.Asset.MinVersion = property.value; } else if (property.name == Propertyname.Version || property.name == Propertyname.Version_Current) { wrapper.Asset.Version = property.value; } else if (property.name == Propertyname.Description_ExtensionRequired) { wrapper.ExtensionsRequired = new List <string>(); wrapper.ExtensionsRequired.Add("EXT_QuantumRendering"); material.MetallicRoughnessMaterial = null; material.Extensions = new List <Runtime.Extensions.Extension>(); material.Extensions.Add(new Runtime.Extensions.EXT_QuantumRendering()); var extension = material.Extensions[0] as Runtime.Extensions.EXT_QuantumRendering; extension.PlanckFactor = new Vector4(0.2f, 0.2f, 0.2f, 0.8f); extension.CopenhagenTexture = new Runtime.Texture(); extension.EntanglementFactor = new Vector3(0.4f, 0.4f, 0.4f); extension.ProbabilisticFactor = 0.3f; extension.SuperpositionCollapseTexture = new Runtime.Texture(); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; } else if (property.name == Propertyname.Description_WithFallback) { // Fallback alpha mode will be set in the PostRuntimeChanges function } } return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Enabled interleaved buffers wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Interleave = true; foreach (Property req in requiredProperty) { if (req.name == Propertyname.BaseColorTexture) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture(); material.MetallicRoughnessMaterial.BaseColorTexture.Sampler = new Runtime.Sampler(); material.MetallicRoughnessMaterial.BaseColorTexture.Source = req.value; } } foreach (Property property in combo) { if (property.name == Propertyname.VertexColor_Vector3_Float | property.name == Propertyname.VertexColor_Vector3_Byte | property.name == Propertyname.VertexColor_Vector3_Short) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].ColorComponentType = property.value.componentType; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].ColorType = property.value.type; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Colors = property.value.colors; } else if (property.name == Propertyname.VertexUV0_Float || property.name == Propertyname.VertexUV0_Byte || property.name == Propertyname.VertexUV0_Short) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordsComponentType = property.value; } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { foreach (var req in requiredProperty) { if (req.name == Propertyname.ExtensionUsed_SpecularGlossiness) { // Initialize SpecGloss for every set material.Extensions = new List <Runtime.Extensions.Extension>(); material.Extensions.Add(new Runtime.Extensions.PbrSpecularGlossiness()); if (wrapper.ExtensionsUsed == null) { wrapper.ExtensionsUsed = new List <string>(); } wrapper.ExtensionsUsed = wrapper.ExtensionsUsed.Union( new string[] { "KHR_materials_pbrSpecularGlossiness" }).ToList(); } else if (req.name == Propertyname.BaseColorTexture) { // Apply the fallback MetallicRoughness for every set material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { BaseColorTexture = new Runtime.Texture { Source = req.value } }; } } var extension = material.Extensions[0] as Runtime.Extensions.PbrSpecularGlossiness; foreach (Property property in combo) { switch (property.name) { case Propertyname.DiffuseFactor: extension.DiffuseFactor = property.value; break; case Propertyname.SpecularFactor: extension.SpecularFactor = property.value; break; case Propertyname.SpecularFactor_Override: extension.SpecularFactor = property.value; break; case Propertyname.GlossinessFactor: extension.GlossinessFactor = property.value; break; case Propertyname.DiffuseTexture: extension.DiffuseTexture = new Runtime.Texture(); extension.DiffuseTexture.Source = property.value; break; case Propertyname.SpecularGlossinessTexture: extension.SpecularGlossinessTexture = new Runtime.Texture(); extension.SpecularGlossinessTexture.Source = property.value; break; case Propertyname.OcclusionTexture: material.OcclusionTexture = new Runtime.Texture(); material.OcclusionTexture.Source = property.value; break; case Propertyname.VertexColor_Vector3_Float: wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.FLOAT; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC3; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Colors = property.value; break; case Propertyname.ExtensionUsed_SpecularGlossiness: if (wrapper.ExtensionsUsed == null) { wrapper.ExtensionsUsed = new List <string>(); } wrapper.ExtensionsUsed = wrapper.ExtensionsUsed.Union( new string[] { "KHR_materials_pbrSpecularGlossiness" }).ToList(); break; } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Determines which of the primitives will have the material and attributes applied to it var splitType = combo.Find(e => e.propertyGroup == 1); foreach (Property property in combo) { if (property.name == Propertyname.Primitives_Split1 || property.name == Propertyname.Primitives_Split2 || property.name == Propertyname.Primitives_Split3 || property.name == Propertyname.Primitives_Split4) { // Same plane, but split into two triangle primitives var primitive0 = specialProperties.Find(e => e.name == Propertyname.Primitive_0); var primitive1 = specialProperties.Find(e => e.name == Propertyname.Primitive_1); Runtime.MeshPrimitive prim0 = new Runtime.MeshPrimitive { Positions = primitive0.value.Positions, Indices = primitive0.value.Indices, }; Runtime.MeshPrimitive prim1 = new Runtime.MeshPrimitive { Positions = primitive1.value.Positions, Indices = primitive1.value.Indices, }; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives = new List <Runtime.MeshPrimitive> { prim0, prim1 }; } if (property.name == Propertyname.BaseColorTexture) { if (material.MetallicRoughnessMaterial == null) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture(); } material.MetallicRoughnessMaterial.BaseColorTexture.Source = property.value; material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 0; } if (property.name == Propertyname.NormalTexture) { if (material.NormalTexture == null) { material.NormalTexture = new Runtime.Texture(); } material.NormalTexture.Source = property.value; material.NormalTexture.TexCoordIndex = 0; } // Attributes set for only the first primitive if (splitType.name == Propertyname.Primitives_Split1) { if (property.name == Propertyname.VertexNormal) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Normals = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Normals = null; } else if (property.name == Propertyname.VertexTangent) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Tangents = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Tangents = null; } else if (property.name == Propertyname.VertexColor_Vector4_Float) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Colors = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Colors = null; } else if (ReadmeStringHelper.GenerateNameWithSpaces(property.name.ToString()) == ReadmeStringHelper.GenerateNameWithSpaces(Propertyname.Primitive0VertexUV0.ToString())) // All UV0 { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = new List <List <Vector2> >(); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive0VertexUV0).value); } else if (ReadmeStringHelper.GenerateNameWithSpaces(property.name.ToString()) == ReadmeStringHelper.GenerateNameWithSpaces(Propertyname.Primitive0VertexUV1.ToString())) // All UV1 { if (wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets == null) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = new List <List <Vector2> >(); } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive0VertexUV1).value); } } // Attributes set for only the second primitive else if (splitType.name == Propertyname.Primitives_Split2) { if (property.name == Propertyname.VertexNormal) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Normals = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Normals = property.value; } else if (property.name == Propertyname.VertexTangent) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Tangents = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Tangents = property.value; } else if (property.name == Propertyname.VertexColor_Vector4_Float) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Colors = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Colors = property.value; } else if (ReadmeStringHelper.GenerateNameWithSpaces(property.name.ToString()) == ReadmeStringHelper.GenerateNameWithSpaces(Propertyname.Primitive1VertexUV0.ToString())) // All UV0 { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets = new List <List <Vector2> >(); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive1VertexUV0).value); } else if (ReadmeStringHelper.GenerateNameWithSpaces(property.name.ToString()) == ReadmeStringHelper.GenerateNameWithSpaces(Propertyname.Primitive1VertexUV1.ToString())) // All UV1 { if (wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets == null) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets = new List <List <Vector2> >(); } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive1VertexUV1).value); } } // Attributes set for both of the primitives else if (splitType.name == Propertyname.Primitives_Split3) { if (property.name == Propertyname.VertexNormal) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Normals = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Normals = property.value; } else if (property.name == Propertyname.VertexTangent) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Tangents = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Tangents = property.value; } else if (property.name == Propertyname.VertexColor_Vector4_Float) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Colors = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Colors = property.value; } else if (property.name == Propertyname.Primitive0VertexUV0) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = new List <List <Vector2> >(); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive0VertexUV0).value); } else if (property.name == Propertyname.Primitive1VertexUV0) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets = new List <List <Vector2> >(); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive1VertexUV0).value); } else if (property.name == Propertyname.Primitive0VertexUV1) { if (wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets == null) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = new List <List <Vector2> >(); } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive0VertexUV1).value); } else if (property.name == Propertyname.Primitive1VertexUV1) { if (wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets == null) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets = new List <List <Vector2> >(); } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive1VertexUV1).value); } } // Attributes set for neither of the primitives else if (splitType.name == Propertyname.Primitives_Split4) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Normals = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Normals = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Tangents = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Tangents = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Colors = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Colors = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = null; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets = null; } } // Material needs to be a deep copy here, or both primitives will get the same Mat. if (material.MetallicRoughnessMaterial != null) { if (splitType.name == Propertyname.Primitives_Split1 || splitType.name == Propertyname.Primitives_Split3) { var mat = DeepCopy.CloneObject(material); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = mat; } if (splitType.name == Propertyname.Primitives_Split2 || splitType.name == Propertyname.Primitives_Split3) { var mat = DeepCopy.CloneObject(material); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Material = mat; } } // Use the second UV if it has been set if (splitType.name != Propertyname.Primitives_Split4) { var prim0UV1 = combo.Find(e => e.name == Propertyname.Primitive0VertexUV1); var prim1UV1 = combo.Find(e => e.name == Propertyname.Primitive1VertexUV1); if (prim0UV1 != null) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0]. Material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 1; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0]. Material.NormalTexture.TexCoordIndex = 1; } if (prim1UV1 != null) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1]. Material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 1; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1]. Material.NormalTexture.TexCoordIndex = 1; } } return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { foreach (Property property in combo) { if (property.name == Propertyname.Mode_Points || property.name == Propertyname.Mode_Lines || property.name == Propertyname.Mode_Line_Loop || property.name == Propertyname.Mode_Line_Strip || property.name == Propertyname.Mode_Triangles || property.name == Propertyname.Mode_Triangle_Strip || property.name == Propertyname.Mode_Triangle_Fan || property.name == Propertyname.Mode_Triangles) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Mode = property.value; // These modes need a different set of indices than provided by the default model Property indices = null; switch (property.name) { case Propertyname.Mode_Points: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_Points); break; } case Propertyname.Mode_Lines: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_Lines); break; } case Propertyname.Mode_Line_Loop: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_LineLoop); break; } case Propertyname.Mode_Line_Strip: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_LineStrip); break; } case Propertyname.Mode_Triangle_Strip: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_TriangleStrip); break; } case Propertyname.Mode_Triangle_Fan: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_TriangleFan); break; } case Propertyname.Mode_Triangles: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_Triangles); break; } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Mode = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Indices = indices.value; } else if (property.name == Propertyname.IndicesComponentType_Byte || property.name == Propertyname.IndicesComponentType_Short || property.name == Propertyname.IndicesComponentType_Int) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].IndexComponentType = property.value; } else if (property.name == Propertyname.IndicesComponentType_None) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Indices = null; var mode = combo.Find(e => e.propertyGroup == 1); var modeVertexes = specialProperties.Find(e => e.name == mode.name); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Positions = modeVertexes.value; } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = null; return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { foreach (Property property in combo) { if (property.name == Propertyname.Mode_Points || property.name == Propertyname.Mode_Lines || property.name == Propertyname.Mode_Line_Loop || property.name == Propertyname.Mode_Line_Strip || property.name == Propertyname.Mode_Triangles || property.name == Propertyname.Mode_Triangle_Strip || property.name == Propertyname.Mode_Triangle_Fan || property.name == Propertyname.Mode_Triangles) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Mode = property.value; // Points uses a different set of vertexes for their base model if (property.name == Propertyname.Mode_Points) { var modeVertexes = specialProperties.Find(e => e.name == property.name); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Positions = modeVertexes.value; } } else if (property.name.ToString().Contains("IndicesValues_") && property.name != Propertyname.IndicesValues_None) { // These modes need a different set of indices than provided by the default model Property indices = null; var mode = combo.Find(e => e.name.ToString().Contains("Mode_")); switch (mode.name) { case Propertyname.Mode_Points: { indices = specialProperties.Find(e => e.name == Propertyname.IndicesValues_Points); break; } case Propertyname.Mode_Lines: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_Lines); break; } case Propertyname.Mode_Line_Loop: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_LineLoop); break; } case Propertyname.Mode_Line_Strip: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_LineStrip); break; } case Propertyname.Mode_Triangle_Strip: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_TriangleStrip); break; } case Propertyname.Mode_Triangle_Fan: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_TriangleFan); break; } case Propertyname.Mode_Triangles: { indices = properties.Find(e => e.name == Propertyname.IndicesValues_Triangles); break; } case Propertyname.IndicesComponentType_None: { indices = null; break; } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Indices = indices.value; } else if (property.name == Propertyname.IndicesComponentType_Byte || property.name == Propertyname.IndicesComponentType_Short || property.name == Propertyname.IndicesComponentType_Int) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].IndexComponentType = property.value; } else if (property.name == Propertyname.IndicesComponentType_None) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Indices = null; // If there are no indicies, some modes need custom vertexes var mode = combo.Find(e => e.name.ToString().Contains("Mode_")); var modeVertexes = specialProperties.Find(e => e.name == mode.name); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Positions = modeVertexes.value; } //else //{ // int index = -1; // if (combo.Find(e => e.name == Propertyname.Mode_Points) != null) // { // index = 0; // } // else if (combo.Find(e => e.name == Propertyname.Mode_Lines) != null) // { // index = 1; // } // if (property.name == Propertyname.VertexUV0_Float) // { // List<List<Vector2>> texCoords = new List<List<Vector2>>(); // if (combo.Find(e => e.name == Propertyname.Mode_Points) != null) // { // texCoords.Add(specialProperties.Find(e => e.name == Propertyname.VertexUV0_Float).value[index]); // } // else if (combo.Find(e => e.name == Propertyname.Mode_Lines) != null) // { // texCoords.Add(specialProperties.Find(e => e.name == Propertyname.VertexUV0_Float).value[index]); // } // wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = texCoords; // } // else if (property.name == Propertyname.VertexNormal) // { // wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Normals = specialProperties.Find(e => e.name == Propertyname.VertexNormal).value[index]; // } // else if (property.name == Propertyname.VertexTangent) // { // wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Tangents = specialProperties.Find(e => e.name == Propertyname.VertexTangent).value[index]; // } // else if (property.name == Propertyname.NormalTexture) // { // material.NormalTexture = new Runtime.Texture(); // material.NormalTexture.Source = property.value; // material.NormalTexture.TexCoordIndex = 0; // } //} } if (material.NormalTexture == null) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = null; } return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Switch from the flat plane to a model with multiple nodes wrapper = Common.MultiNode(); var nodeList = new List <Runtime.Node>(); nodeList.Add(wrapper.Scenes[0].Nodes[0]); nodeList.Add(wrapper.Scenes[0].Nodes[0].Children[0]); // Clear the vertex normal and tangent values already in the model foreach (var node in nodeList) { node.Mesh.MeshPrimitives[0].Normals = null; node.Mesh.MeshPrimitives[0].Tangents = null; } // Apply non-transforming attributes first, so they're copied to the control nodes foreach (Property property in combo) { if (property.name == Propertyname.NormalTexture) { material.NormalTexture = new Runtime.Texture(); material.NormalTexture.Source = property.value; } else if (property.name == Propertyname.BaseColorTexture) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture(); material.MetallicRoughnessMaterial.BaseColorTexture.Source = property.value; } else if (property.name == Propertyname.MetallicRoughnessTexture) { material.MetallicRoughnessMaterial.MetallicRoughnessTexture = new Runtime.Texture(); material.MetallicRoughnessMaterial.MetallicRoughnessTexture.Source = property.value; } else { foreach (var node in nodeList) { if (property.name == Propertyname.VertexNormal) { node.Mesh.MeshPrimitives[0].Normals = property.value; } else if (property.name == Propertyname.VertexTangent) { node.Mesh.MeshPrimitives[0].Tangents = property.value; } } } } foreach (Property property in combo) { if (property.name == Propertyname.Matrix) { nodeList[1].Matrix = specialProperties[0].value; } else if (property.name == Propertyname.Scale) { nodeList[1].Scale = property.value; } } // Apply the material to each node foreach (var node in nodeList) { node.Mesh.MeshPrimitives[0].Material = material; } return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Same plane, but split into two triangle primitives var primitive1 = specialProperties.Find(e => e.name == Propertyname.Primitives_Split1); var primitive2 = specialProperties.Find(e => e.name == Propertyname.Primitives_Split2); Runtime.MeshPrimitive prim0 = new Runtime.MeshPrimitive { Positions = primitive1.value.Positions, Indices = primitive1.value.Indices, }; Runtime.MeshPrimitive prim2 = new Runtime.MeshPrimitive { Positions = primitive2.value.Positions, Indices = primitive2.value.Indices, }; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives = new List <Runtime.MeshPrimitive> { prim0, prim2 }; foreach (Property property in combo) { if (property.name == Propertyname.BaseColorTexture) { if (material.MetallicRoughnessMaterial == null) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture(); } material.MetallicRoughnessMaterial.BaseColorTexture.Source = property.value; material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 0; } if (property.name == Propertyname.NormalTexture) { if (material.NormalTexture == null) { material.NormalTexture = new Runtime.Texture(); } material.NormalTexture.Source = property.value; material.NormalTexture.TexCoordIndex = 0; } if (property.name == Propertyname.VertexNormal) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Normals = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Normals = property.value; } else if (property.name == Propertyname.VertexTangent) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Tangents = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Tangents = property.value; } else if (property.name == Propertyname.VertexColor_Vector4_Float) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Colors = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Colors = property.value; } else if (property.name == Propertyname.Primitive0VertexUV0) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = new List <List <Vector2> >(); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive0VertexUV0).value); } else if (property.name == Propertyname.Primitive1VertexUV0) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets = new List <List <Vector2> >(); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive1VertexUV0).value); } } if (material.MetallicRoughnessMaterial != null) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Material = material; } return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { foreach (var req in requiredProperty) { if (req.name == Propertyname.ExtensionUsed_SpecularGlossiness) { // Initialize SpecGloss for every set material.Extensions = new List <Runtime.Extensions.Extension>(); material.Extensions.Add(new Runtime.Extensions.PbrSpecularGlossiness()); if (wrapper.ExtensionsUsed == null) { wrapper.ExtensionsUsed = new List <string>(); } wrapper.ExtensionsUsed = wrapper.ExtensionsUsed.Union( new string[] { "KHR_materials_pbrSpecularGlossiness" }).ToList(); } else if (req.name == Propertyname.BaseColorTexture) { // Apply the fallback MetallicRoughness for every set material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { BaseColorTexture = new Runtime.Texture { Source = req.value } }; } } var material2 = DeepCopy.CloneObject(material); Runtime.MeshPrimitive prim0 = null; Runtime.MeshPrimitive prim1 = null; foreach (var property in specialProperties) { if (property.name == Propertyname.Primitives_Split1) { prim0 = new Runtime.MeshPrimitive { Positions = property.value.Positions, Indices = property.value.Indices, }; } else if (property.name == Propertyname.Primitives_Split2) { prim1 = new Runtime.MeshPrimitive { Positions = property.value.Positions, Indices = property.value.Indices, }; } else if (property.propertyGroup == 0 ) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives = new List <Runtime.MeshPrimitive> { prim0, prim1 }; } if (property.name == Propertyname.Primitive0VertexUV0) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets = new List <List <Vector2> >(); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive0VertexUV0).value); } else if (property.name == Propertyname.Primitive1VertexUV0) { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets = new List <List <Vector2> >(); wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].TextureCoordSets.Add( specialProperties.Find(e => e.name == Propertyname.Primitive1VertexUV0).value); } } foreach (Property property in combo) { switch (property.name) { case Propertyname.SpecularGlossinessOnMaterial0_Yes: // Default. No changes needed break; case Propertyname.SpecularGlossinessOnMaterial0_No: material.Extensions = null; break; case Propertyname.SpecularGlossinessOnMaterial1_Yes: // Default. No changes needed break; case Propertyname.SpecularGlossinessOnMaterial1_No: material2.Extensions = null; break; } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Material = material2; return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); foreach (Property req in requiredProperty) { if (req.name == Propertyname.MetallicFactor) { material.MetallicRoughnessMaterial.MetallicFactor = req.value; } else if (req.name == Propertyname.BaseColorFactor) { material.MetallicRoughnessMaterial.BaseColorFactor = req.value; } } foreach (Property property in combo) { switch (property.name) { case Propertyname.EmissiveFactor: { material.EmissiveFactor = property.value; break; } case Propertyname.NormalTexture: { material.NormalTexture = new Runtime.Texture(); material.NormalTexture.Source = property.value; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Normals = specialProperties.Find(e => e.name == Propertyname.VertexNormal).value; break; } case Propertyname.Scale: { material.NormalScale = property.value; break; } case Propertyname.OcclusionTexture: { material.OcclusionTexture = new Runtime.Texture(); material.OcclusionTexture.Source = property.value; break; } case Propertyname.Strength: { material.OcclusionStrength = property.value; break; } case Propertyname.EmissiveTexture: { material.EmissiveTexture = new Runtime.Texture(); material.EmissiveTexture.Source = property.value; break; } } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Initialize MetallicRoughness for the empty set if (combo.Count == 0) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); } foreach (Property property in combo) { if (material.MetallicRoughnessMaterial == null) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); } switch (property.name) { case Propertyname.BaseColorFactor: { material.MetallicRoughnessMaterial.BaseColorFactor = property.value; break; } case Propertyname.MetallicFactor: { material.MetallicRoughnessMaterial.MetallicFactor = property.value; break; } case Propertyname.RoughnessFactor: { material.MetallicRoughnessMaterial.RoughnessFactor = property.value; break; } case Propertyname.BaseColorTexture: { material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture(); material.MetallicRoughnessMaterial.BaseColorTexture.Source = property.value; break; } case Propertyname.MetallicRoughnessTexture: { material.MetallicRoughnessMaterial.MetallicRoughnessTexture = new Runtime.Texture(); material.MetallicRoughnessMaterial.MetallicRoughnessTexture.Source = property.value; break; } case Propertyname.VertexColor_Vector3_Float: { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.FLOAT; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].ColorType = Runtime.MeshPrimitive.ColorTypeEnum.VEC3; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Colors = property.value; break; } } } wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material; return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Switch from the flat plane to a model with multiple nodes wrapper = Common.MultiNode(); var nodeList = new List <Runtime.Node>(); nodeList.Add(wrapper.Scenes[0].Nodes[0]); nodeList.Add(wrapper.Scenes[0].Nodes[0].Children[0]); // Clear the vertex normal and tangent values already in the model foreach (var node in nodeList) { node.Mesh.MeshPrimitives[0].Normals = null; node.Mesh.MeshPrimitives[0].Tangents = null; } foreach (Property req in requiredProperty) { if (req.name == Propertyname.NormalTexture) { material.NormalTexture = new Runtime.Texture(); material.NormalTexture.Source = req.value; } else if (req.name == Propertyname.BaseColorTexture) { material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture(); material.MetallicRoughnessMaterial.BaseColorTexture.Source = req.value; } else if (req.name == Propertyname.MetallicRoughnessTexture) { material.MetallicRoughnessMaterial.MetallicRoughnessTexture = new Runtime.Texture(); material.MetallicRoughnessMaterial.MetallicRoughnessTexture.Source = req.value; } else if (req.name == Propertyname.Translation_Y) { if (combo.Find(e => e.name == Propertyname.Matrix_X) == null && combo.Find(e => e.name == Propertyname.Matrix_XY) == null && combo.Find(e => e.name == Propertyname.Matrix_XYZ) == null) // The matrixs have their own translation { nodeList[1].Translation = req.value; } } } foreach (Property property in combo) { foreach (var node in nodeList) { if (property.name == Propertyname.VertexNormal) { node.Mesh.MeshPrimitives[0].Normals = property.value; } else if (property.name == Propertyname.VertexTangent) { node.Mesh.MeshPrimitives[0].Tangents = property.value; } } if (property.name == Propertyname.Matrix_X || property.name == Propertyname.Matrix_XY || property.name == Propertyname.Matrix_XYZ) { nodeList[1].Matrix = property.value; } else if (property.name == Propertyname.Scale_X || property.name == Propertyname.Scale_XY || property.name == Propertyname.Scale_XYZ) { nodeList[1].Scale = property.value; } } // Apply the material to each node foreach (var node in nodeList) { node.Mesh.MeshPrimitives[0].Material = material; } return(wrapper); }
public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material0, List <Property> combo, ref glTFLoader.Schema.Gltf gltf) { // Same plane, but split into two triangle primitives var primitive1 = specialProperties.Find(e => e.name == Propertyname.Primitives_Split1); var primitive2 = specialProperties.Find(e => e.name == Propertyname.Primitives_Split2); Runtime.MeshPrimitive prim0 = new Runtime.MeshPrimitive { Positions = primitive1.value.Positions, Indices = primitive1.value.Indices, }; Runtime.MeshPrimitive prim2 = new Runtime.MeshPrimitive { Positions = primitive2.value.Positions, Indices = primitive2.value.Indices, }; wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives = new List <Runtime.MeshPrimitive> { prim0, prim2 }; // Make a second material var material1 = DeepCopy.CloneObject(material0); // Set the base color factor on both materials material0.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); material1.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); material0.MetallicRoughnessMaterial.BaseColorFactor = requiredProperty.Find(e => e.name == Propertyname.Material0WithBaseColorFactor).value; material1.MetallicRoughnessMaterial.BaseColorFactor = requiredProperty.Find(e => e.name == Propertyname.Material1WithBaseColorFactor).value; foreach (Property property in combo) { switch (property.name) { case Propertyname.Primitive0_Material0BaseColorFactor: { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material0; break; } case Propertyname.Primitive0_Material1BaseColorFactor: { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[0].Material = material1; break; } case Propertyname.Primitive1_Material0BaseColorFactor: { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Material = material0; break; } case Propertyname.Primitive1_Material1BaseColorFactor: { wrapper.Scenes[0].Nodes[0].Mesh.MeshPrimitives[1].Material = material1; break; } } } return(wrapper); }