// // ModelMaterial.cs - describes information about a material for a 3D model // // Author: // Michael Becker // // Copyright (c) 2013-2020 Mike Becker's Software // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System; using System.Collections.ObjectModel; using MBS.Framework.Drawing; namespace UniversalEditor.ObjectModels.Multimedia3D.Model { /// /// Describes information about a material for a 3D model. /// public class ModelMaterial : ICloneable { public class ModelMaterialCollection : Collection { } private uint? mvarMapID = null; /// /// Gets or sets the name of the material. /// /// The name of the material. public string Name { get; set; } = string.Empty; /// /// Gets or sets the diffuse color of the material. /// /// The diffuse color of the material. public Color DiffuseColor { get; set; } = Colors.Black; /// /// Gets or sets the specular color of the material. /// /// The specular color of the material. public Color SpecularColor { get; set; } = Colors.Black; /// /// Gets or sets the emissive color of the material. /// /// The emissive color of the material. public Color EmissiveColor { get; set; } = Colors.Black; /// /// Gets or sets the ambient color of the material. /// /// The ambient color of the material. public Color AmbientColor { get; set; } = Colors.Black; /// /// Gets or sets the index of the toon texture to use for this . /// /// The index of the toon texture to use for this . public sbyte ToonNumber { get; set; } = 0; /// /// Gets or sets the shininess of the material. /// /// The shininess of the material. public float Shininess { get; set; } = 0f; /// /// Gets or sets a value indicating whether this participates in edge detection for toon rendering. /// /// true if this participates in edge detection for toon rendering; otherwise, false. public bool EdgeFlag { get; set; } = false; /// /// Gets or sets the number of vertices affected by this . /// /// The number of vertices affected by this . public uint IndexCount { get; set; } = 0u; /// /// Gets or sets a user-defined comment for this . /// /// A user-defined comment for this . public string Comment { get; set; } = string.Empty; /// /// Gets or sets the color of the toon edge line when is set to true. /// /// The color of the toon edge line when is set to true. public Color EdgeColor { get; set; } = Color.Empty; /// /// Gets or sets the size of the toon edge line when is set to true. /// /// The size of the toon edge line when is set to true. public float EdgeSize { get; set; } = 0f; public object Clone() { ModelMaterial clone = new ModelMaterial(); clone.AmbientColor = AmbientColor; clone.DiffuseColor = DiffuseColor; clone.EdgeColor = EdgeColor; clone.EdgeFlag = EdgeFlag; clone.EdgeSize = EdgeSize; clone.IndexCount = IndexCount; clone.Name = Name; clone.Shininess = Shininess; clone.SpecularColor = SpecularColor; foreach (ModelTexture texture in Textures) { clone.Textures.Add(texture.Clone() as ModelTexture); } return clone; } /// /// Gets a collection of instances representing the texture animation frames contained in this . /// /// The texture animation frames contained in this . public ModelTexture.ModelTextureCollection Textures { get; } = new ModelTexture.ModelTextureCollection(); /// /// Gets or sets the index of the default texture frame for this . /// /// The index of the default texture frame for this . public int TextureIndex { get; set; } = 0; public override string ToString() { return Name + " (" + ((Textures.Count > 0) ? (!String.IsNullOrEmpty(Textures[0].TextureFileName) ? Textures[0].TextureFileName : Textures[0].MapFileName) : AmbientColor.ToString()) + ")"; } /// /// Gets or sets a value indicating whether the lights-out glow effect is always lit for this on supported renderers. /// /// true if the lights-out glow effect is always lit for this ; otherwise, false. public bool AlwaysLight { get; set; } = false; /// /// Gets a collection of instances representing the faces affected by this . /// /// The triangles. public ModelTriangle.ModelTriangleCollection Triangles { get; } = new ModelTriangle.ModelTriangleCollection(); /// /// Gets or sets a value indicating whether the lights-out glow effect should be enabled for this on supported renderers. /// /// true if the lights-out glow effect should be enabled for this ; otherwise, false. public bool EnableGlow { get; set; } = false; /// /// Gets or sets a value indicating whether the multiple-texture animation feature should be enabled for this on supported /// renderers. /// /// true if the multiple-texture animation feature should be enabled for this ; otherwise, false. public bool EnableAnimation { get; set; } = false; } }