public GLTFMaterial(GLTFMaterial material, GLTFRoot gltfRoot) : base(material, gltfRoot) { if (material == null) { return; } if (material.PbrMetallicRoughness != null) { PbrMetallicRoughness = new PbrMetallicRoughness(material.PbrMetallicRoughness, gltfRoot); } if (material.NormalTexture != null) { NormalTexture = new NormalTextureInfo(material.NormalTexture, gltfRoot); } if (material.OcclusionTexture != null) { OcclusionTexture = new OcclusionTextureInfo(material.OcclusionTexture, gltfRoot); } if (material.EmissiveTexture != null) { EmissiveTexture = new TextureInfo(material.EmissiveTexture, gltfRoot); } EmissiveFactor = material.EmissiveFactor; AlphaMode = material.AlphaMode; AlphaCutoff = material.AlphaCutoff; DoubleSided = material.DoubleSided; }
public static PbrMetallicRoughness Deserialize(GLTFRoot root, JsonReader reader) { var metallicRoughness = new PbrMetallicRoughness(); if (reader.Read() && reader.TokenType != JsonToken.StartObject) { throw new Exception("Asset must be an object."); } while (reader.Read() && reader.TokenType == JsonToken.PropertyName) { var curProp = reader.Value.ToString(); switch (curProp) { case "baseColorFactor": metallicRoughness.BaseColorFactor = reader.ReadAsRGBAColor(); break; case "baseColorTexture": metallicRoughness.BaseColorTexture = TextureInfo.Deserialize(root, reader); break; case "metallicFactor": metallicRoughness.MetallicFactor = reader.ReadAsDouble().Value; break; case "roughnessFactor": metallicRoughness.RoughnessFactor = reader.ReadAsDouble().Value; break; case "metallicRoughnessTexture": metallicRoughness.MetallicRoughnessTexture = TextureInfo.Deserialize(root, reader); break; default: metallicRoughness.DefaultPropertyDeserializer(root, reader); break; } } return(metallicRoughness); }
public PbrMetallicRoughness(PbrMetallicRoughness pbrMetallicRoughness, GLTFRoot gltfRoot) : base(pbrMetallicRoughness) { if (pbrMetallicRoughness == null) { return; } BaseColorFactor = pbrMetallicRoughness.BaseColorFactor; if (pbrMetallicRoughness.BaseColorTexture != null) { BaseColorTexture = new TextureInfo(pbrMetallicRoughness.BaseColorTexture, gltfRoot); } MetallicFactor = pbrMetallicRoughness.MetallicFactor; RoughnessFactor = pbrMetallicRoughness.RoughnessFactor; if (pbrMetallicRoughness.MetallicRoughnessTexture != null) { MetallicRoughnessTexture = new TextureInfo(pbrMetallicRoughness.MetallicRoughnessTexture, gltfRoot); } }