// // ModelVertex.cs - represents a vertex in 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.Collections.ObjectModel; namespace UniversalEditor.ObjectModels.Multimedia3D.Model { /// /// Represents a vertex in a 3D model. /// public class ModelVertex { public class ModelVertexCollection : Collection { } public ModelVertex() { } public ModelVertex(float vx, float vy, float vz) { Position = new PositionVector3(vx, vy, vz); OriginalPosition = new PositionVector3(vx, vy, vz); } public ModelVertex(double vx, double vy, double vz) { Position = new PositionVector3(vx, vy, vz); OriginalPosition = new PositionVector3(vx, vy, vz); } public ModelVertex(float vx, float vy, float vz, float tu, float tv) { Position = new PositionVector3(vx, vy, vz); OriginalPosition = new PositionVector3(vx, vy, vz); Texture = new TextureVector2(tu, tv); } public ModelVertex(double vx, double vy, double vz, double tu, double tv) { Position = new PositionVector3(vx, vy, vz); OriginalPosition = new PositionVector3(vx, vy, vz); Texture = new TextureVector2(tu, tv); } public ModelVertex(float vx, float vy, float vz, float nx, float ny, float nz) { Position = new PositionVector3(vx, vy, vz); OriginalPosition = new PositionVector3(vx, vy, vz); Normal = new PositionVector3(nx, ny, nz); OriginalNormal = new PositionVector3(nx, ny, nz); } public ModelVertex(double vx, double vy, double vz, double nx, double ny, double nz) { Position = new PositionVector3(vx, vy, vz); OriginalPosition = new PositionVector3(vx, vy, vz); Normal = new PositionVector3(nx, ny, nz); OriginalNormal = new PositionVector3(nx, ny, nz); } public ModelVertex(float vx, float vy, float vz, float tu, float tv, float nx, float ny, float nz) { Position = new PositionVector3(vx, vy, vz); OriginalPosition = new PositionVector3(vx, vy, vz); Texture = new TextureVector2(tu, tv); Normal = new PositionVector3(nx, ny, nz); OriginalNormal = new PositionVector3(nx, ny, nz); } public ModelVertex(double vx, double vy, double vz, double tu, double tv, double nx, double ny, double nz) { Position = new PositionVector3(vx, vy, vz); OriginalPosition = new PositionVector3(vx, vy, vz); Texture = new TextureVector2(tu, tv); Normal = new PositionVector3(nx, ny, nz); OriginalNormal = new PositionVector3(nx, ny, nz); } /// /// Gets or sets the primary bone associated with this . /// /// The primary bone associated with this . public ModelBone Bone0 { get; set; } = null; /// /// Gets or sets the secondary bone associated with this . /// /// The secondary bone associated with this . public ModelBone Bone1 { get; set; } = null; public PositionVector3 Position { get; set; } = default(PositionVector3); public PositionVector3 Normal { get; set; } = default(PositionVector3); public TextureVector2 Texture { get; set; } = default(TextureVector2); /// /// Gets or sets the weight of the primary bone attached to this . /// /// The weight of the primary bone attached to this . public float Bone0Weight { get; set; } = 1.0f; /// /// Gets or sets the weight of the secondary bone attached to this . /// /// The weight of the secondary bone attached to this . public float Bone1Weight { get { return 1.0f - Bone0Weight; } set { Bone0Weight = 1.0f - value; } } /// /// 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; public object Clone() { return new ModelVertex { Bone0 = (Bone0.Clone() as ModelBone), Bone1 = (Bone1.Clone() as ModelBone), EdgeFlag = EdgeFlag, Normal = Normal, Position = Position, Texture = Texture, Bone0Weight = Bone0Weight }; } /// /// Gets or sets the original position of the vertex before any transformations have been applied. /// /// The original position of the vertex before any transformations have been applied. public PositionVector3 OriginalPosition { get; set; } /// /// Gets or sets the original normal of the vertex before any transformations have been applied. /// /// The original normal of the vertex before any transformations have been applied. public PositionVector3 OriginalNormal { get; set; } /// /// Resets the position and normal of the vertex to their original values. /// public void Reset() { Position = OriginalPosition; Normal = OriginalNormal; } } }