[slimdx] r2190 committed - Added predefined vertex types to the toolkit.

6 views
Skip to first unread message

sli...@googlecode.com

unread,
Mar 18, 2012, 12:50:43 PM3/18/12
to slimdx...@googlegroups.com
Revision: 2190
Author: mike.popoloski
Date: Sun Mar 18 09:50:15 2012
Log: Added predefined vertex types to the toolkit.
http://code.google.com/p/slimdx/source/detail?r=2190

Added:
/branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionColor.cs
/branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionColorTexture.cs
/branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionNormal.cs
/branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionNormalColor.cs

/branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionNormalColorTexture.cs
/branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionNormalTexture.cs
/branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionTexture.cs
Modified:
/branches/lite/SlimDX.Toolkit/SlimDX.Toolkit.csproj
/branches/lite/SlimDX.Toolkit/VertexTypes/InputElementFactory.cs
/branches/lite/SlimDX.Toolkit/VertexTypes/VertexElementAttribute.cs

=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionColor.cs Sun
Mar 18 09:50:15 2012
@@ -0,0 +1,119 @@
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using SlimMath;
+
+namespace SlimDX.Toolkit.VertexTypes
+{
+ /// <summary>
+ /// Represents a vertex that has a position and color.
+ /// </summary>
+ [Serializable]
+ public struct VertexPositionColor : IEquatable<VertexPositionColor>
+ {
+ /// <summary>
+ /// The size of the structure, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(VertexPositionColor));
+
+ /// <summary>
+ /// The position of the vertex.
+ /// </summary>
+ [VertexElement("SV_Position")]
+ public Vector3 Position;
+
+ /// <summary>
+ /// The color of the vertex.
+ /// </summary>
+ [VertexElement("COLOR")]
+ public Color4 Color;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="VertexPositionColor"/> struct.
+ /// </summary>
+ /// <param name="position">The position.</param>
+ /// <param name="color">The color.</param>
+ public VertexPositionColor(Vector3 position, Color4 color)
+ {
+ Position = position;
+ Color = color;
+ }
+
+ /// <summary>
+ /// Implements operator ==.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator ==(VertexPositionColor left,
VertexPositionColor right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Implements operator !=.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator !=(VertexPositionColor left,
VertexPositionColor right)
+ {
+ return !(left == right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return
string.Format(CultureInfo.CurrentCulture, "Position={0}, Color={1}",
Position, Color);
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A 32-bit signed integer that is the hash code for this
instance.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Position.GetHashCode()
+ + Color.GetHashCode();
+ }
+
+ /// <summary>
+ /// Indicates whether this instance and a specified object are
equal.
+ /// </summary>
+ /// <param name="obj">Another object to compare to.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="obj"/> and this instance are
the same type and represent the same value; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (GetType() != obj.GetType())
+ return false;
+
+ return Equals((VertexPositionColor)obj);
+ }
+
+ /// <summary>
+ /// Indicates whether the current object is equal to another
object of the same type.
+ /// </summary>
+ /// <param name="other">An object to compare with this
object.</param>
+ /// <returns>
+ /// <c>true</c> if the current object is equal to the <paramref
name="other"/> parameter; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(VertexPositionColor other)
+ {
+ return
+ Position == other.Position &&
+ Color == other.Color;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionColorTexture.cs
Sun Mar 18 09:50:15 2012
@@ -0,0 +1,129 @@
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using SlimMath;
+
+namespace SlimDX.Toolkit.VertexTypes
+{
+ /// <summary>
+ /// Represents a vertex that has a position, color, and texture
mapping information.
+ /// </summary>
+ [Serializable]
+ public struct VertexPositionColorTexture :
IEquatable<VertexPositionColorTexture>
+ {
+ /// <summary>
+ /// The size of the structure, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(VertexPositionColorTexture));
+
+ /// <summary>
+ /// The position of the vertex.
+ /// </summary>
+ [VertexElement("SV_Position")]
+ public Vector3 Position;
+
+ /// <summary>
+ /// The color of the vertex.
+ /// </summary>
+ [VertexElement("COLOR")]
+ public Color4 Color;
+
+ /// <summary>
+ /// The texture coordinates.
+ /// </summary>
+ [VertexElement("TEXCOORD")]
+ public Vector2 TextureCoordinates;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="VertexPositionColorTexture"/> struct.
+ /// </summary>
+ /// <param name="position">The position.</param>
+ /// <param name="color">The color.</param>
+ /// <param name="textureCoordinates">The texture
coordinates.</param>
+ public VertexPositionColorTexture(Vector3 position, Color4 color,
Vector2 textureCoordinates)
+ {
+ Position = position;
+ Color = color;
+ TextureCoordinates = textureCoordinates;
+ }
+
+ /// <summary>
+ /// Implements operator ==.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator ==(VertexPositionColorTexture left,
VertexPositionColorTexture right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Implements operator !=.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator !=(VertexPositionColorTexture left,
VertexPositionColorTexture right)
+ {
+ return !(left == right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return
string.Format(CultureInfo.CurrentCulture, "Position={0}, Color={1},
TexCoords={2}", Position, Color, TextureCoordinates);
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A 32-bit signed integer that is the hash code for this
instance.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Position.GetHashCode()
+ + Color.GetHashCode()
+ + TextureCoordinates.GetHashCode();
+ }
+
+ /// <summary>
+ /// Indicates whether this instance and a specified object are
equal.
+ /// </summary>
+ /// <param name="obj">Another object to compare to.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="obj"/> and this instance are
the same type and represent the same value; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (GetType() != obj.GetType())
+ return false;
+
+ return Equals((VertexPositionColorTexture)obj);
+ }
+
+ /// <summary>
+ /// Indicates whether the current object is equal to another
object of the same type.
+ /// </summary>
+ /// <param name="other">An object to compare with this
object.</param>
+ /// <returns>
+ /// <c>true</c> if the current object is equal to the <paramref
name="other"/> parameter; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(VertexPositionColorTexture other)
+ {
+ return
+ Position == other.Position &&
+ Color == other.Color &&
+ TextureCoordinates == other.TextureCoordinates;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionNormal.cs Sun
Mar 18 09:50:15 2012
@@ -0,0 +1,119 @@
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using SlimMath;
+
+namespace SlimDX.Toolkit.VertexTypes
+{
+ /// <summary>
+ /// Represents a vertex that has a position and normal vector.
+ /// </summary>
+ [Serializable]
+ public struct VertexPositionNormal : IEquatable<VertexPositionNormal>
+ {
+ /// <summary>
+ /// The size of the structure, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(VertexPositionNormal));
+
+ /// <summary>
+ /// The position of the vertex.
+ /// </summary>
+ [VertexElement("SV_Position")]
+ public Vector3 Position;
+
+ /// <summary>
+ /// The vertex normal.
+ /// </summary>
+ [VertexElement("NORMAL")]
+ public Vector3 Normal;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="VertexPositionNormal"/> struct.
+ /// </summary>
+ /// <param name="position">The position.</param>
+ /// <param name="normal">The normal.</param>
+ public VertexPositionNormal(Vector3 position, Vector3 normal)
+ {
+ Position = position;
+ Normal = normal;
+ }
+
+ /// <summary>
+ /// Implements operator ==.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator ==(VertexPositionNormal left,
VertexPositionNormal right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Implements operator !=.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator !=(VertexPositionNormal left,
VertexPositionNormal right)
+ {
+ return !(left == right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return
string.Format(CultureInfo.CurrentCulture, "Position={0}, Normal={1}",
Position, Normal);
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A 32-bit signed integer that is the hash code for this
instance.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Position.GetHashCode()
+ + Normal.GetHashCode();
+ }
+
+ /// <summary>
+ /// Indicates whether this instance and a specified object are
equal.
+ /// </summary>
+ /// <param name="obj">Another object to compare to.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="obj"/> and this instance are
the same type and represent the same value; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (GetType() != obj.GetType())
+ return false;
+
+ return Equals((VertexPositionNormal)obj);
+ }
+
+ /// <summary>
+ /// Indicates whether the current object is equal to another
object of the same type.
+ /// </summary>
+ /// <param name="other">An object to compare with this
object.</param>
+ /// <returns>
+ /// <c>true</c> if the current object is equal to the <paramref
name="other"/> parameter; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(VertexPositionNormal other)
+ {
+ return
+ Position == other.Position &&
+ Normal == other.Normal;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionNormalColor.cs
Sun Mar 18 09:50:15 2012
@@ -0,0 +1,129 @@
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using SlimMath;
+
+namespace SlimDX.Toolkit.VertexTypes
+{
+ /// <summary>
+ /// Represents a vertex that has a position, normal vector, and color.
+ /// </summary>
+ [Serializable]
+ public struct VertexPositionNormalColor :
IEquatable<VertexPositionNormalColor>
+ {
+ /// <summary>
+ /// The size of the structure, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(VertexPositionNormalColor));
+
+ /// <summary>
+ /// The position of the vertex.
+ /// </summary>
+ [VertexElement("SV_Position")]
+ public Vector3 Position;
+
+ /// <summary>
+ /// The vertex normal.
+ /// </summary>
+ [VertexElement("NORMAL")]
+ public Vector3 Normal;
+
+ /// <summary>
+ /// The color of the vertex.
+ /// </summary>
+ [VertexElement("COLOR")]
+ public Color4 Color;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="VertexPositionNormalColor"/> struct.
+ /// </summary>
+ /// <param name="position">The position.</param>
+ /// <param name="normal">The normal.</param>
+ /// <param name="color">The color.</param>
+ public VertexPositionNormalColor(Vector3 position, Vector3 normal,
Color4 color)
+ {
+ Position = position;
+ Normal = normal;
+ Color = color;
+ }
+
+ /// <summary>
+ /// Implements operator ==.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator ==(VertexPositionNormalColor left,
VertexPositionNormalColor right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Implements operator !=.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator !=(VertexPositionNormalColor left,
VertexPositionNormalColor right)
+ {
+ return !(left == right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return
string.Format(CultureInfo.CurrentCulture, "Position={0}, Normal={1},
Color={2}", Position, Normal, Color);
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A 32-bit signed integer that is the hash code for this
instance.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Position.GetHashCode()
+ + Normal.GetHashCode()
+ + Color.GetHashCode();
+ }
+
+ /// <summary>
+ /// Indicates whether this instance and a specified object are
equal.
+ /// </summary>
+ /// <param name="obj">Another object to compare to.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="obj"/> and this instance are
the same type and represent the same value; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (GetType() != obj.GetType())
+ return false;
+
+ return Equals((VertexPositionNormalColor)obj);
+ }
+
+ /// <summary>
+ /// Indicates whether the current object is equal to another
object of the same type.
+ /// </summary>
+ /// <param name="other">An object to compare with this
object.</param>
+ /// <returns>
+ /// <c>true</c> if the current object is equal to the <paramref
name="other"/> parameter; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(VertexPositionNormalColor other)
+ {
+ return
+ Position == other.Position &&
+ Normal == other.Normal &&
+ Color == other.Color;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionNormalColorTexture.cs
Sun Mar 18 09:50:15 2012
@@ -0,0 +1,139 @@
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using SlimMath;
+
+namespace SlimDX.Toolkit.VertexTypes
+{
+ /// <summary>
+ /// Represents a vertex that has a position, normal vector, color, and
texture mapping information.
+ /// </summary>
+ [Serializable]
+ public struct VertexPositionNormalColorTexture :
IEquatable<VertexPositionNormalColorTexture>
+ {
+ /// <summary>
+ /// The size of the structure, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(VertexPositionNormalColorTexture));
+
+ /// <summary>
+ /// The position of the vertex.
+ /// </summary>
+ [VertexElement("SV_Position")]
+ public Vector3 Position;
+
+ /// <summary>
+ /// The vertex normal.
+ /// </summary>
+ [VertexElement("NORMAL")]
+ public Vector3 Normal;
+
+ /// <summary>
+ /// The color of the vertex.
+ /// </summary>
+ [VertexElement("COLOR")]
+ public Color4 Color;
+
+ /// <summary>
+ /// The texture coordinates.
+ /// </summary>
+ [VertexElement("TEXCOORD")]
+ public Vector2 TextureCoordinates;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="VertexPositionNormalColorTexture"/> struct.
+ /// </summary>
+ /// <param name="position">The position.</param>
+ /// <param name="normal">The normal.</param>
+ /// <param name="color">The color.</param>
+ /// <param name="textureCoordinates">The texture
coordinates.</param>
+ public VertexPositionNormalColorTexture(Vector3 position, Vector3
normal, Color4 color, Vector2 textureCoordinates)
+ {
+ Position = position;
+ Normal = normal;
+ Color = color;
+ TextureCoordinates = textureCoordinates;
+ }
+
+ /// <summary>
+ /// Implements operator ==.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator ==(VertexPositionNormalColorTexture
left, VertexPositionNormalColorTexture right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Implements operator !=.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator !=(VertexPositionNormalColorTexture
left, VertexPositionNormalColorTexture right)
+ {
+ return !(left == right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return
string.Format(CultureInfo.CurrentCulture, "Position={0}, Normal={1},
Color={2}, TexCoords={3}", Position, Normal, Color, TextureCoordinates);
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A 32-bit signed integer that is the hash code for this
instance.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Position.GetHashCode()
+ + Normal.GetHashCode()
+ + Color.GetHashCode()
+ + TextureCoordinates.GetHashCode();
+ }
+
+ /// <summary>
+ /// Indicates whether this instance and a specified object are
equal.
+ /// </summary>
+ /// <param name="obj">Another object to compare to.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="obj"/> and this instance are
the same type and represent the same value; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (GetType() != obj.GetType())
+ return false;
+
+ return Equals((VertexPositionNormalColorTexture)obj);
+ }
+
+ /// <summary>
+ /// Indicates whether the current object is equal to another
object of the same type.
+ /// </summary>
+ /// <param name="other">An object to compare with this
object.</param>
+ /// <returns>
+ /// <c>true</c> if the current object is equal to the <paramref
name="other"/> parameter; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(VertexPositionNormalColorTexture other)
+ {
+ return
+ Position == other.Position &&
+ Normal == other.Normal &&
+ Color == other.Color &&
+ TextureCoordinates == other.TextureCoordinates;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionNormalTexture.cs
Sun Mar 18 09:50:15 2012
@@ -0,0 +1,129 @@
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using SlimMath;
+
+namespace SlimDX.Toolkit.VertexTypes
+{
+ /// <summary>
+ /// Represents a vertex that has a position, normal vector, and
texture mapping information.
+ /// </summary>
+ [Serializable]
+ public struct VertexPositionNormalTexture :
IEquatable<VertexPositionNormalTexture>
+ {
+ /// <summary>
+ /// The size of the structure, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(VertexPositionNormalTexture));
+
+ /// <summary>
+ /// The position of the vertex.
+ /// </summary>
+ [VertexElement("SV_Position")]
+ public Vector3 Position;
+
+ /// <summary>
+ /// The vertex normal.
+ /// </summary>
+ [VertexElement("NORMAL")]
+ public Vector3 Normal;
+
+ /// <summary>
+ /// The texture coordinates.
+ /// </summary>
+ [VertexElement("TEXCOORD")]
+ public Vector2 TextureCoordinates;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="VertexPositionNormalTexture"/> struct.
+ /// </summary>
+ /// <param name="position">The position.</param>
+ /// <param name="normal">The normal.</param>
+ /// <param name="textureCoordinates">The texture
coordinates.</param>
+ public VertexPositionNormalTexture(Vector3 position, Vector3
normal, Vector2 textureCoordinates)
+ {
+ Position = position;
+ Normal = normal;
+ TextureCoordinates = textureCoordinates;
+ }
+
+ /// <summary>
+ /// Implements operator ==.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator ==(VertexPositionNormalTexture left,
VertexPositionNormalTexture right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Implements operator !=.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator !=(VertexPositionNormalTexture left,
VertexPositionNormalTexture right)
+ {
+ return !(left == right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return
string.Format(CultureInfo.CurrentCulture, "Position={0}, Normal={1},
TexCoords={2}", Position, Normal, TextureCoordinates);
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A 32-bit signed integer that is the hash code for this
instance.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Position.GetHashCode()
+ + Normal.GetHashCode()
+ + TextureCoordinates.GetHashCode();
+ }
+
+ /// <summary>
+ /// Indicates whether this instance and a specified object are
equal.
+ /// </summary>
+ /// <param name="obj">Another object to compare to.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="obj"/> and this instance are
the same type and represent the same value; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (GetType() != obj.GetType())
+ return false;
+
+ return Equals((VertexPositionNormalTexture)obj);
+ }
+
+ /// <summary>
+ /// Indicates whether the current object is equal to another
object of the same type.
+ /// </summary>
+ /// <param name="other">An object to compare with this
object.</param>
+ /// <returns>
+ /// <c>true</c> if the current object is equal to the <paramref
name="other"/> parameter; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(VertexPositionNormalTexture other)
+ {
+ return
+ Position == other.Position &&
+ Normal == other.Normal &&
+ TextureCoordinates == other.TextureCoordinates;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/VertexTypes/VertexPositionTexture.cs Sun
Mar 18 09:50:15 2012
@@ -0,0 +1,119 @@
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using SlimMath;
+
+namespace SlimDX.Toolkit.VertexTypes
+{
+ /// <summary>
+ /// Represents a vertex that has a position and texture mapping
information.
+ /// </summary>
+ [Serializable]
+ public struct VertexPositionTexture : IEquatable<VertexPositionTexture>
+ {
+ /// <summary>
+ /// The size of the structure, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(VertexPositionTexture));
+
+ /// <summary>
+ /// The position of the vertex.
+ /// </summary>
+ [VertexElement("SV_Position")]
+ public Vector3 Position;
+
+ /// <summary>
+ /// The texture coordinates.
+ /// </summary>
+ [VertexElement("TEXCOORD")]
+ public Vector2 TextureCoordinates;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="VertexPositionTexture"/> struct.
+ /// </summary>
+ /// <param name="position">The position.</param>
+ /// <param name="textureCoordinates">The texture
coordinates.</param>
+ public VertexPositionTexture(Vector3 position, Vector2
textureCoordinates)
+ {
+ Position = position;
+ TextureCoordinates = textureCoordinates;
+ }
+
+ /// <summary>
+ /// Implements operator ==.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator ==(VertexPositionTexture left,
VertexPositionTexture right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Implements operator !=.
+ /// </summary>
+ /// <param name="left">The left side of the operator.</param>
+ /// <param name="right">The right side of the operator.</param>
+ /// <returns>The result of the operator.</returns>
+ public static bool operator !=(VertexPositionTexture left,
VertexPositionTexture right)
+ {
+ return !(left == right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return
string.Format(CultureInfo.CurrentCulture, "Position={0}, TexCoords={1}",
Position, TextureCoordinates);
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A 32-bit signed integer that is the hash code for this
instance.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Position.GetHashCode()
+ + TextureCoordinates.GetHashCode();
+ }
+
+ /// <summary>
+ /// Indicates whether this instance and a specified object are
equal.
+ /// </summary>
+ /// <param name="obj">Another object to compare to.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="obj"/> and this instance are
the same type and represent the same value; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (GetType() != obj.GetType())
+ return false;
+
+ return Equals((VertexPositionTexture)obj);
+ }
+
+ /// <summary>
+ /// Indicates whether the current object is equal to another
object of the same type.
+ /// </summary>
+ /// <param name="other">An object to compare with this
object.</param>
+ /// <returns>
+ /// <c>true</c> if the current object is equal to the <paramref
name="other"/> parameter; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(VertexPositionTexture other)
+ {
+ return
+ Position == other.Position &&
+ TextureCoordinates == other.TextureCoordinates;
+ }
+ }
+}
=======================================
--- /branches/lite/SlimDX.Toolkit/SlimDX.Toolkit.csproj Sat Mar 17 22:22:28
2012
+++ /branches/lite/SlimDX.Toolkit/SlimDX.Toolkit.csproj Sun Mar 18 09:50:15
2012
@@ -49,6 +49,13 @@
<Compile Include="Sprites\SpriteBatch.cs" />
<Compile Include="VertexTypes\InputElementFactory.cs" />
<Compile Include="VertexTypes\VertexElementAttribute.cs" />
+ <Compile Include="VertexTypes\VertexPositionColor.cs" />
+ <Compile Include="VertexTypes\VertexPositionColorTexture.cs" />
+ <Compile Include="VertexTypes\VertexPositionNormal.cs" />
+ <Compile Include="VertexTypes\VertexPositionNormalColor.cs" />
+ <Compile Include="VertexTypes\VertexPositionNormalColorTexture.cs" />
+ <Compile Include="VertexTypes\VertexPositionNormalTexture.cs" />
+ <Compile Include="VertexTypes\VertexPositionTexture.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\build\SlimDX.vcxproj">
=======================================
--- /branches/lite/SlimDX.Toolkit/VertexTypes/InputElementFactory.cs Sat
Mar 17 22:22:28 2012
+++ /branches/lite/SlimDX.Toolkit/VertexTypes/InputElementFactory.cs Sun
Mar 18 09:50:15 2012
@@ -7,7 +7,7 @@
using SlimDX.DXGI;
using SlimMath;

-namespace SlimDX.Toolkit
+namespace SlimDX.Toolkit.VertexTypes
{
/// <summary>
/// Defines a factory for creating input layout descriptions for
various vertex types.
=======================================
--- /branches/lite/SlimDX.Toolkit/VertexTypes/VertexElementAttribute.cs Sat
Mar 17 22:22:28 2012
+++ /branches/lite/SlimDX.Toolkit/VertexTypes/VertexElementAttribute.cs Sun
Mar 18 09:50:15 2012
@@ -5,7 +5,7 @@
using SlimDX.DXGI;
using SlimDX.Direct3D11;

-namespace SlimDX.Toolkit
+namespace SlimDX.Toolkit.VertexTypes
{
/// <summary>
/// Describes the usage and format of an element in a vertex structure.
Reply all
Reply to author
Forward
0 new messages