Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
VertexPositionNormalColor.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 
4 using System;
5 using System.Runtime.InteropServices;
6 
7 using SiliconStudio.Core.Mathematics;
8 
9 namespace SiliconStudio.Paradox.Graphics
10 {
11  /// <summary>
12  /// Describes a custom vertex format structure that contains position, normal and color information.
13  /// </summary>
14  [StructLayout(LayoutKind.Sequential)]
15  public struct VertexPositionNormalColor : IEquatable<VertexPositionNormalColor>, IVertex
16  {
17  /// <summary>
18  /// Initializes a new <see cref="VertexPositionNormalColor"/> instance.
19  /// </summary>
20  /// <param name="position">The position of this vertex.</param>
21  /// <param name="normal">The vertex normal.</param>
22  /// <param name="color">the color</param>
23  public VertexPositionNormalColor(Vector3 position, Vector3 normal, Color color)
24  : this()
25  {
26  Position = position;
27  Normal = normal;
28  Color = color;
29  }
30 
31  /// <summary>
32  /// XYZ position.
33  /// </summary>
34  public Vector3 Position;
35 
36  /// <summary>
37  /// The vertex normal.
38  /// </summary>
39  public Vector3 Normal;
40 
41  /// <summary>
42  /// The color.
43  /// </summary>
44  public Color Color;
45 
46  /// <summary>
47  /// Defines structure byte size.
48  /// </summary>
49  public static readonly int Size = 28;
50 
51 
52  /// <summary>
53  /// The vertex layout of this structure.
54  /// </summary>
55  public static readonly VertexDeclaration Layout = new VertexDeclaration(
59  );
60 
61 
62  public bool Equals(VertexPositionNormalColor other)
63  {
64  return Position.Equals(other.Position) && Normal.Equals(other.Normal) && Color.Equals(other.Color);
65  }
66 
67  public override bool Equals(object obj)
68  {
69  if (ReferenceEquals(null, obj)) return false;
70  return obj is VertexPositionNormalColor && Equals((VertexPositionNormalColor)obj);
71  }
72 
73  public override int GetHashCode()
74  {
75  unchecked
76  {
77  int hashCode = Position.GetHashCode();
78  hashCode = (hashCode * 397) ^ Normal.GetHashCode();
79  hashCode = (hashCode * 397) ^ Color.GetHashCode();
80  return hashCode;
81  }
82  }
83 
85  {
86  return Layout;
87  }
88 
89  public void FlipWinding()
90  {
91  }
92 
93  public static bool operator ==(VertexPositionNormalColor left, VertexPositionNormalColor right)
94  {
95  return left.Equals(right);
96  }
97 
98  public static bool operator !=(VertexPositionNormalColor left, VertexPositionNormalColor right)
99  {
100  return !left.Equals(right);
101  }
102 
103  public override string ToString()
104  {
105  return string.Format("Position: {0}, Normal: {1}, Color: {2}", Position, Normal, Color);
106  }
107  }
108 }
static VertexElement Color(PixelFormat format, int offsetInBytes=AppendAligned)
Declares a VertexElement with the semantic "COLOR".
The layout of a vertex buffer with a set of VertexElement.
Describes a custom vertex format structure that contains position, normal and color information...
Represents a three dimensional mathematical vector.
Definition: Vector3.cs:42
VertexPositionNormalColor(Vector3 position, Vector3 normal, Color color)
Initializes a new VertexPositionNormalColor instance.
override int GetHashCode()
Returns a hash code for this instance.
Definition: Color.cs:1118
static VertexElement Normal(PixelFormat format, int offsetInBytes=AppendAligned)
Declares a VertexElement with the semantic "NORMAL".
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".
VertexDeclaration GetLayout()
Gets the layout of the vertex.
The base interface for all the vertex data structure.
Definition: IVertex.cs:9
A description of a single element for the input-assembler stage. This structure is related to Direct3...