X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=FDK%2F%E3%82%B3%E3%83%BC%E3%83%89%2F01.%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%83%AF%E3%83%BC%E3%82%AF%2FUtilities%2FTransformedColoredVertex.cs;fp=FDK%2F%E3%82%B3%E3%83%BC%E3%83%89%2F01.%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%83%AF%E3%83%BC%E3%82%AF%2FUtilities%2FTransformedColoredVertex.cs;h=4658aefcc0b41d3ffd8b920bce9558b94acef7d3;hb=7bf3e650c7c6f5afac463ea6e288fcd3fad4387b;hp=0000000000000000000000000000000000000000;hpb=296446998eeba408353da55a275458b590e4ebf5;p=dtxmania%2Fdtxmania.git diff --git a/FDK/コード/01.フレームワーク/Utilities/TransformedColoredVertex.cs b/FDK/コード/01.フレームワーク/Utilities/TransformedColoredVertex.cs new file mode 100644 index 00000000..4658aefc --- /dev/null +++ b/FDK/コード/01.フレームワーク/Utilities/TransformedColoredVertex.cs @@ -0,0 +1,162 @@ +/* +* Copyright (c) 2007-2009 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; +using SharpDX.Direct3D9; + +namespace SampleFramework +{ + /// + /// Represents a single transformed and colored vertex. + /// + [StructLayout(LayoutKind.Sequential)] + public struct TransformedColoredVertex : IEquatable + { + /// + /// Gets or sets the transformed position of the vertex. + /// + /// The transformed position of the vertex. + [VertexElement(DeclarationType.Float4, DeclarationUsage.PositionTransformed)] + public Vector4 Position + { + get; + set; + } + + /// + /// Gets or sets the color of the vertex. + /// + /// The color of the vertex. + [VertexElement(DeclarationType.Color, DeclarationUsage.Color)] + public int Color + { + get; + set; + } + + /// + /// Gets the size in bytes. + /// + /// The size in bytes. + public static int SizeInBytes + { + get { return Marshal.SizeOf(typeof(TransformedColoredVertex)); } + } + + /// + /// Gets the format. + /// + /// The format. + public static VertexFormat Format + { + get { return VertexFormat.PositionRhw | VertexFormat.Diffuse; } + } + + /// + /// Initializes a new instance of the struct. + /// + /// The position. + /// The color. + public TransformedColoredVertex(Vector4 position, int color) + : this() + { + Position = position; + Color = color; + } + + /// + /// Implements the operator ==. + /// + /// The left side of the operator. + /// The right side of the operator. + /// The result of the operator. + public static bool operator ==(TransformedColoredVertex left, TransformedColoredVertex right) + { + return left.Equals(right); + } + + /// + /// Implements the operator !=. + /// + /// The left side of the operator. + /// The right side of the operator. + /// The result of the operator. + public static bool operator !=(TransformedColoredVertex left, TransformedColoredVertex 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() + Color.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((TransformedColoredVertex)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(TransformedColoredVertex other) + { + return (Position == other.Position && Color == other.Color); + } + + /// + /// Returns a string representation of the current object. + /// + /// + /// A representing the vertex. + /// + public override string ToString() + { + return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", Position.ToString(), System.Drawing.Color.FromArgb(Color).ToString()); + } + } +}