+++ /dev/null
-/*\r
-* Copyright (c) 2007-2009 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-using System;\r
-using System.Globalization;\r
-using System.Runtime.InteropServices;\r
-using SharpDX;\r
-using SharpDX.Direct3D9;\r
-\r
-namespace SampleFramework\r
-{\r
- /// <summary>\r
- /// Represents a single transformed and colored vertex.\r
- /// </summary>\r
- [StructLayout(LayoutKind.Sequential)]\r
- public struct TransformedColoredVertex : IEquatable<TransformedColoredVertex>\r
- {\r
- /// <summary>\r
- /// Gets or sets the transformed position of the vertex.\r
- /// </summary>\r
- /// <value>The transformed position of the vertex.</value>\r
- [VertexElement(DeclarationType.Float4, DeclarationUsage.PositionTransformed)]\r
- public Vector4 Position\r
- {\r
- get;\r
- set;\r
- }\r
-\r
- /// <summary>\r
- /// Gets or sets the color of the vertex.\r
- /// </summary>\r
- /// <value>The color of the vertex.</value>\r
- [VertexElement(DeclarationType.Color, DeclarationUsage.Color)]\r
- public int Color\r
- {\r
- get;\r
- set;\r
- }\r
-\r
- /// <summary>\r
- /// Gets the size in bytes.\r
- /// </summary>\r
- /// <value>The size in bytes.</value>\r
- public static int SizeInBytes\r
- {\r
- get { return Marshal.SizeOf(typeof(TransformedColoredVertex)); }\r
- }\r
-\r
- /// <summary>\r
- /// Gets the format.\r
- /// </summary>\r
- /// <value>The format.</value>\r
- public static VertexFormat Format\r
- {\r
- get { return VertexFormat.PositionRhw | VertexFormat.Diffuse; }\r
- }\r
-\r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="TransformedColoredVertex"/> struct.\r
- /// </summary>\r
- /// <param name="position">The position.</param>\r
- /// <param name="color">The color.</param>\r
- public TransformedColoredVertex(Vector4 position, int color)\r
- : this()\r
- {\r
- Position = position;\r
- Color = color;\r
- }\r
-\r
- /// <summary>\r
- /// Implements the operator ==.\r
- /// </summary>\r
- /// <param name="left">The left side of the operator.</param>\r
- /// <param name="right">The right side of the operator.</param>\r
- /// <returns>The result of the operator.</returns>\r
- public static bool operator ==(TransformedColoredVertex left, TransformedColoredVertex right)\r
- {\r
- return left.Equals(right);\r
- }\r
-\r
- /// <summary>\r
- /// Implements the operator !=.\r
- /// </summary>\r
- /// <param name="left">The left side of the operator.</param>\r
- /// <param name="right">The right side of the operator.</param>\r
- /// <returns>The result of the operator.</returns>\r
- public static bool operator !=(TransformedColoredVertex left, TransformedColoredVertex right)\r
- {\r
- return !(left == right);\r
- }\r
-\r
- /// <summary>\r
- /// Returns the hash code for this instance.\r
- /// </summary>\r
- /// <returns>\r
- /// A 32-bit signed integer that is the hash code for this instance.\r
- /// </returns>\r
- public override int GetHashCode()\r
- {\r
- return Position.GetHashCode() + Color.GetHashCode();\r
- }\r
-\r
- /// <summary>\r
- /// Indicates whether this instance and a specified object are equal.\r
- /// </summary>\r
- /// <param name="obj">Another object to compare to.</param>\r
- /// <returns>\r
- /// true if <paramref name="obj"/> and this instance are the same type and represent the same value; otherwise, false.\r
- /// </returns>\r
- public override bool Equals(object obj)\r
- {\r
- if (obj == null)\r
- return false;\r
-\r
- if (GetType() != obj.GetType())\r
- return false;\r
-\r
- return Equals((TransformedColoredVertex)obj);\r
- }\r
-\r
- /// <summary>\r
- /// Indicates whether the current object is equal to another object of the same type.\r
- /// </summary>\r
- /// <param name="other">An object to compare with this object.</param>\r
- /// <returns>\r
- /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.\r
- /// </returns>\r
- public bool Equals(TransformedColoredVertex other)\r
- {\r
- return (Position == other.Position && Color == other.Color);\r
- }\r
-\r
- /// <summary>\r
- /// Returns a string representation of the current object.\r
- /// </summary>\r
- /// <returns>\r
- /// A <see cref="T:System.String"/> representing the vertex.\r
- /// </returns>\r
- public override string ToString()\r
- {\r
- return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", Position.ToString(), System.Drawing.Color.FromArgb(Color).ToString());\r
- }\r
- }\r
-}\r