OSDN Git Service

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