public IndexedResource <Material> ForceExport(Material mat) { foreach (var h in Hooks) { var r = h.Export(this, mat); if (r != null) { return(r); } } // Maybe, Standard shader... // TODO: Support various shaders var tex = mat.GetTexture("_MainTex") as Texture2D; IndexedResource <Texture2D> textureResource = null; if (tex != null) { textureResource = Textures.Export(tex); } var gltfMaterial = new Types.Material { Name = mat.name, PbrMetallicRoughness = new Types.Material.PbrMetallicRoughnessType { BaseColorTexture = textureResource != null ? new Types.Material.BaseColorTextureInfoType { Index = textureResource.Index, TexCoord = 0, // NOTE: mesh.primitive must have TEXCOORD_<TexCoord>. } : null, // TODO: fix MetallicFactor = 0.0f, // TODO: fix RoughnessFactor = 1.0f, // TODO: fix }, }; return(new IndexedResource <Material> { Index = Types.GltfExtensions.AddMaterial(Gltf, gltfMaterial), Value = mat, }); }
protected override void SolveInstance(IGH_DataAccess DA) { // Get any buffered Material string serializedData = this.GetValue("material", ""); if (serializedData != "") { this.material = (Types.Material)Serialization.Utilities.Deserialize(serializedData, typeof(Types.Material)); } // Declare Variables GH_String path = new GH_String(""); GH_Boolean productionStage = new GH_Boolean(true); GH_Boolean wasteProcessingStage = new GH_Boolean(true); GH_Boolean recyclingPotentialStage = new GH_Boolean(true); GH_Boolean useQuartz = new GH_Boolean(true); GH_Boolean useOekobaudat = new GH_Boolean(false); Stages = new List <Types.LifecycleStage>(); GH_String url = new GH_String(""); if (!DA.GetData <GH_String>("URL", ref url)) { this.Url = ""; } else { this.Url = url.Value; } // Get Data from Ports DA.GetData <GH_String>("Path", ref path); this.alternativeDataSourcePath = path.Value; DA.GetData <GH_Boolean>("Production", ref productionStage); DA.GetData <GH_Boolean>("Waste Processing", ref wasteProcessingStage); DA.GetData <GH_Boolean>("Recycling Potential", ref recyclingPotentialStage); DA.GetData <GH_Boolean>("Quartz", ref useQuartz); DA.GetData <GH_Boolean>("OekobauDat", ref useOekobaudat); GH_String lang = new GH_String("de"); DA.GetData <GH_String>("Lang", ref lang); if (this.Url == "") { if (useOekobaudat.Value) { this.Url = "http://www.oekobaudat.de/OEKOBAU.DAT"; } if (useQuartz.Value) { this.Url = "http://www.quartzproject.org"; } } // Set selected Stages if (productionStage.Value) { Stages.Add(new Types.LifecycleStage() { Name = "A1-A3", Column = 0 }); } if (wasteProcessingStage.Value) { Stages.Add(new Types.LifecycleStage() { Name = "C3", Column = 1 }); } if (recyclingPotentialStage.Value) { Stages.Add(new Types.LifecycleStage() { Name = "D", Column = 2 }); } // if a Path has been specified load Data from File if (this.alternativeDataSourcePath != "") { this.LoadedMaterials = Types.Material.LoadFromFile(this.alternativeDataSourcePath, this.Stages); } else { // Load from Quartz DB if (useQuartz.Value) { this.LoadedMaterials = Types.Material.LoadFromQuartz(this.Stages, this.Url); } // Load from Oekobau.dat else { this.LoadedMaterials = Types.Material.LoadFromOekoBauDat(this.Stages, this.Url, lang.Value.ToLower()); } } DA.SetData("Material", this.material); }