Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
VertexPositionColorTexture.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Runtime.InteropServices;
5 using SiliconStudio.Core.Mathematics;
6 
7 namespace SiliconStudio.Paradox.Graphics
8 {
9  /// <summary>
10  /// Describes a custom vertex format structure that contains position and color information.
11  /// </summary>
12  [StructLayout(LayoutKind.Sequential)]
13  public struct VertexPositionColorTexture : IEquatable<VertexPositionColorTexture>
14  {
15  /// <summary>
16  /// Initializes a new <see cref="VertexPositionColorTexture"/> instance.
17  /// </summary>
18  /// <param name="position">The position of this vertex.</param>
19  /// <param name="color">The color of this vertex.</param>
20  /// <param name="textureCoordinate">UV texture coordinates.</param>
21  public VertexPositionColorTexture(Vector3 position, Color color, Vector2 textureCoordinate)
22  : this()
23  {
24  Position = position;
25  Color = color;
26  TextureCoordinate = textureCoordinate;
27  }
28 
29  /// <summary>
30  /// XYZ position.
31  /// </summary>
32  public Vector3 Position;
33 
34  /// <summary>
35  /// The vertex color.
36  /// </summary>
37  public Color Color;
38 
39  /// <summary>
40  /// UV texture coordinates.
41  /// </summary>
43 
44  /// <summary>
45  /// Defines structure byte size.
46  /// </summary>
47  public static readonly int Size = 24;
48 
49  /// <summary>
50  /// The vertex layout of this struct.
51  /// </summary>
52  public static readonly VertexDeclaration Layout = new VertexDeclaration(
56  );
57 
58 
60  {
61  return Position.Equals(other.Position) && Color.Equals(other.Color) && TextureCoordinate.Equals(other.TextureCoordinate);
62  }
63 
64  public override bool Equals(object obj)
65  {
66  if (ReferenceEquals(null, obj)) return false;
67  return obj is VertexPositionColorTexture && Equals((VertexPositionColorTexture)obj);
68  }
69 
70  public override int GetHashCode()
71  {
72  unchecked
73  {
74  int hashCode = Position.GetHashCode();
75  hashCode = (hashCode * 397) ^ Color.GetHashCode();
76  hashCode = (hashCode * 397) ^ TextureCoordinate.GetHashCode();
77  return hashCode;
78  }
79  }
80 
81  public static bool operator ==(VertexPositionColorTexture left, VertexPositionColorTexture right)
82  {
83  return left.Equals(right);
84  }
85 
86  public static bool operator !=(VertexPositionColorTexture left, VertexPositionColorTexture right)
87  {
88  return !left.Equals(right);
89  }
90 
91  public override string ToString()
92  {
93  return string.Format("Position: {0}, Color: {1}, Texcoord: {2}", Position, Color, TextureCoordinate);
94  }
95  }
96 }
static VertexElement Color(PixelFormat format, int offsetInBytes=AppendAligned)
Declares a VertexElement with the semantic "COLOR".
bool Equals(Color other)
Determines whether the specified Color is equal to this instance.
Definition: Color.cs:1130
The layout of a vertex buffer with a set of VertexElement.
Represents a two dimensional mathematical vector.
Definition: Vector2.cs:42
static VertexElement TextureCoordinate(PixelFormat format, int offsetInBytes=AppendAligned)
Declares a VertexElement with the semantic "TEXCOORD".
Represents a three dimensional mathematical vector.
Definition: Vector3.cs:42
TextureCoordinate
The texture coordinate.
VertexPositionColorTexture(Vector3 position, Color color, Vector2 textureCoordinate)
Initializes a new VertexPositionColorTexture instance.
override int GetHashCode()
Returns a hash code for this instance.
Definition: Color.cs:1118
SiliconStudio.Core.Mathematics.Color Color
Definition: ColorPicker.cs:14
Represents a 32-bit color (4 bytes) in the form of RGBA (in byte order: R, G, B, A).
Definition: Color.cs:16
static VertexElement Position(PixelFormat format, int offsetInBytes=AppendAligned)
Declares a VertexElement with the semantic "POSITION".
Describes a custom vertex format structure that contains position and color information.
A description of a single element for the input-assembler stage. This structure is related to Direct3...