OSDN Git Service

SlimDX から SharpDX へ機械的に移行。
[dtxmania/dtxmania.git] / FDK17プロジェクト / コード / 04.グラフィック / 頂点フォーマット(Vertex) / TransformedColoredVertex.cs
1 /*\r
2 * Copyright (c) 2007-2010 SlimDX Group\r
3\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy\r
5 * of this software and associated documentation files (the "Software"), to deal\r
6 * in the Software without restriction, including without limitation the rights\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
8 * copies of the Software, and to permit persons to whom the Software is\r
9 * furnished to do so, subject to the following conditions:\r
10\r
11 * The above copyright notice and this permission notice shall be included in\r
12 * all copies or substantial portions of the Software.\r
13\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
20 * THE SOFTWARE.\r
21 */\r
22 \r
23 using System;\r
24 using System.Globalization;\r
25 using System.Runtime.InteropServices;\r
26 \r
27 using SharpDX;\r
28 \r
29 namespace FDK {\r
30     /// <summary>\r
31     /// Represents a vertex with a pre-transformed position and a color.\r
32     /// </summary>\r
33     [StructLayout(LayoutKind.Sequential)]\r
34     public struct TransformedColoredVertex : IEquatable<TransformedColoredVertex> {\r
35         /// <summary>\r
36         /// Gets or sets the pre-transformed position of the vertex.\r
37         /// </summary>\r
38         public Vector4 Position {\r
39             get;\r
40             set;\r
41         }\r
42 \r
43         /// <summary>\r
44         /// Gets or sets the color of the vertex.\r
45         /// </summary>\r
46         public int Color {\r
47             get;\r
48             set;\r
49         }\r
50 \r
51         /// <summary>\r
52         /// Initializes a new instance of the <see cref="TransformedColoredVertex"/> struct.\r
53         /// </summary>\r
54         /// <param name="position">The position.</param>\r
55         /// <param name="color">The color.</param>\r
56         public TransformedColoredVertex(Vector4 position, int color)\r
57             : this() {\r
58             Position = position;\r
59             Color = color;\r
60         }\r
61 \r
62         /// <summary>\r
63         /// Implements operator ==.\r
64         /// </summary>\r
65         /// <param name="left">The left.</param>\r
66         /// <param name="right">The right.</param>\r
67         /// <returns>The result of the operator.</returns>\r
68         public static bool operator ==(TransformedColoredVertex left, TransformedColoredVertex right) {\r
69             return left.Equals(right);\r
70         }\r
71 \r
72         /// <summary>\r
73         /// Implements operator !=.\r
74         /// </summary>\r
75         /// <param name="left">The left side of the operator.</param>\r
76         /// <param name="right">The right side of the operator.</param>\r
77         /// <returns>The result of the operator.</returns>\r
78         public static bool operator !=(TransformedColoredVertex left, TransformedColoredVertex right) {\r
79             return !(left == right);\r
80         }\r
81 \r
82         /// <summary>\r
83         /// Returns the hash code for this instance.\r
84         /// </summary>\r
85         /// <returns>\r
86         /// A 32-bit signed integer that is the hash code for this instance.\r
87         /// </returns>\r
88         public override int GetHashCode() {\r
89             return Position.GetHashCode() + Color.GetHashCode();\r
90         }\r
91 \r
92         /// <summary>\r
93         /// Indicates whether this instance and a specified object are equal.\r
94         /// </summary>\r
95         /// <param name="obj">Another object to compare to.</param>\r
96         /// <returns>\r
97         /// true if <paramref name="obj"/> and this instance are the same type and represent the same value; otherwise, false.\r
98         /// </returns>\r
99         public override bool Equals(object obj) {\r
100             if (obj == null)\r
101                 return false;\r
102 \r
103             if (GetType() != obj.GetType())\r
104                 return false;\r
105 \r
106             return Equals((TransformedColoredVertex)obj);\r
107         }\r
108 \r
109         /// <summary>\r
110         /// Indicates whether the current object is equal to another object of the same type.\r
111         /// </summary>\r
112         /// <param name="other">An object to compare with this object.</param>\r
113         /// <returns>\r
114         /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.\r
115         /// </returns>\r
116         public bool Equals(TransformedColoredVertex other) {\r
117             return (Position == other.Position && Color == other.Color);\r
118         }\r
119     }\r
120 }\r