/* * Copyright (c) 2007-2010 SlimDX Group * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ using System; using System.Globalization; using System.Runtime.InteropServices; using SharpDX; namespace FDK { /// /// Represents a vertex with a position and a texture coordinate. /// [StructLayout(LayoutKind.Sequential)] public struct TexturedVertex : IEquatable { /// /// Gets or sets the position of the vertex. /// public Vector3 Position { get; set; } /// /// Gets or sets the texture coordinate for the vertex. /// public Vector2 TextureCoordinate { get; set; } /// /// Initializes a new instance of the struct. /// /// The position. /// The color. public TexturedVertex(Vector3 position, Vector2 textureCoordinate) : this() { Position = position; TextureCoordinate = textureCoordinate; } /// /// Implements operator ==. /// /// The left. /// The right. /// The result of the operator. public static bool operator ==(TexturedVertex left, TexturedVertex right) { return left.Equals(right); } /// /// Implements operator !=. /// /// The left side of the operator. /// The right side of the operator. /// The result of the operator. public static bool operator !=(TexturedVertex left, TexturedVertex right) { return !(left == right); } /// /// Returns the hash code for this instance. /// /// /// A 32-bit signed integer that is the hash code for this instance. /// public override int GetHashCode() { return Position.GetHashCode() + TextureCoordinate.GetHashCode(); } /// /// Indicates whether this instance and a specified object are equal. /// /// Another object to compare to. /// /// true if and this instance are the same type and represent the same value; otherwise, false. /// public override bool Equals(object obj) { if (obj == null) return false; if (GetType() != obj.GetType()) return false; return Equals((TexturedVertex)obj); } /// /// Indicates whether the current object is equal to another object of the same type. /// /// An object to compare with this object. /// /// true if the current object is equal to the parameter; otherwise, false. /// public bool Equals(TexturedVertex other) { return (Position == other.Position && TextureCoordinate == other.TextureCoordinate); } } }