Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
VertexPositionNormalTangentMultiTexture.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 
6 using SiliconStudio.Core.Mathematics;
7 
8 namespace SiliconStudio.Paradox.Graphics
9 {
10  /// <summary>
11  /// Describes a custom vertex format structure that contains position, color and 10 texture coordinates information.
12  /// </summary>
13  [StructLayout(LayoutKind.Sequential)]
14  public struct VertexPositionNormalTangentMultiTexture : IEquatable<VertexPositionNormalTangentMultiTexture>, IVertex
15  {
16  /// <summary>
17  /// Initializes a new <see cref="VertexPositionNormalTangentMultiTexture"/> instance.
18  /// </summary>
19  /// <param name="position">The position of this vertex.</param>
20  /// <param name="normal">The vertex normal.</param>
21  /// <param name="tangent">The vertex tangent.</param>
22  /// <param name="textureCoordinate">UV texture coordinates.</param>
23  public VertexPositionNormalTangentMultiTexture(Vector3 position, Vector3 normal, Vector4 tangent, Vector2 textureCoordinate)
24  : this()
25  {
26  Position = position;
27  Normal = normal;
28  Tangent = tangent;
29  TextureCoordinate0 = textureCoordinate;
30  TextureCoordinate1 = textureCoordinate;
31  TextureCoordinate2 = textureCoordinate;
32  TextureCoordinate3 = textureCoordinate;
33  TextureCoordinate4 = textureCoordinate;
34  TextureCoordinate5 = textureCoordinate;
35  TextureCoordinate6 = textureCoordinate;
36  TextureCoordinate7 = textureCoordinate;
37  TextureCoordinate8 = textureCoordinate;
38  TextureCoordinate9 = textureCoordinate;
39  }
40 
41  /// <summary>
42  /// XYZ position.
43  /// </summary>
44  public Vector3 Position;
45 
46  /// <summary>
47  /// The vertex normal.
48  /// </summary>
49  public Vector3 Normal;
50 
51  /// <summary>
52  /// The vertex tangent.
53  /// </summary>
54  public Vector4 Tangent;
55 
56  /// <summary>
57  /// UV texture coordinates.
58  /// </summary>
69 
70  /// <summary>
71  /// Defines structure byte size.
72  /// </summary>
73  public static readonly int Size = 120;
74 
75 
76  /// <summary>
77  /// The vertex layout of this struct.
78  /// </summary>
79  public static readonly VertexDeclaration Layout = new VertexDeclaration(
93  );
94 
95 
97  {
98  return Position.Equals(other.Position) && Normal.Equals(other.Normal) && Tangent.Equals(other.Tangent)
99  && TextureCoordinate0.Equals(other.TextureCoordinate0)
100  && TextureCoordinate1.Equals(other.TextureCoordinate1)
101  && TextureCoordinate2.Equals(other.TextureCoordinate2)
102  && TextureCoordinate3.Equals(other.TextureCoordinate3)
103  && TextureCoordinate4.Equals(other.TextureCoordinate4)
104  && TextureCoordinate5.Equals(other.TextureCoordinate5)
105  && TextureCoordinate6.Equals(other.TextureCoordinate6)
106  && TextureCoordinate7.Equals(other.TextureCoordinate7)
107  && TextureCoordinate8.Equals(other.TextureCoordinate8)
108  && TextureCoordinate9.Equals(other.TextureCoordinate9);
109  }
110 
111  public override bool Equals(object obj)
112  {
113  if (ReferenceEquals(null, obj)) return false;
115  }
116 
117  public override int GetHashCode()
118  {
119  unchecked
120  {
121  int hashCode = Position.GetHashCode();
122  hashCode = (hashCode * 397) ^ Normal.GetHashCode();
123  hashCode = (hashCode * 397) ^ Tangent.GetHashCode();
124  hashCode = (hashCode * 397) ^ TextureCoordinate0.GetHashCode();
125  hashCode = (hashCode * 397) ^ TextureCoordinate1.GetHashCode();
126  hashCode = (hashCode * 397) ^ TextureCoordinate2.GetHashCode();
127  hashCode = (hashCode * 397) ^ TextureCoordinate3.GetHashCode();
128  hashCode = (hashCode * 397) ^ TextureCoordinate4.GetHashCode();
129  hashCode = (hashCode * 397) ^ TextureCoordinate5.GetHashCode();
130  hashCode = (hashCode * 397) ^ TextureCoordinate6.GetHashCode();
131  hashCode = (hashCode * 397) ^ TextureCoordinate7.GetHashCode();
132  hashCode = (hashCode * 397) ^ TextureCoordinate8.GetHashCode();
133  hashCode = (hashCode * 397) ^ TextureCoordinate9.GetHashCode();
134  return hashCode;
135  }
136  }
137 
139  {
140  return Layout;
141  }
142 
143  public void FlipWinding()
144  {
145  TextureCoordinate0.X = (1.0f - TextureCoordinate0.X);
146  TextureCoordinate1.X = (1.0f - TextureCoordinate1.X);
147  TextureCoordinate2.X = (1.0f - TextureCoordinate2.X);
148  TextureCoordinate3.X = (1.0f - TextureCoordinate3.X);
149  TextureCoordinate4.X = (1.0f - TextureCoordinate4.X);
150  TextureCoordinate5.X = (1.0f - TextureCoordinate5.X);
151  TextureCoordinate6.X = (1.0f - TextureCoordinate6.X);
152  TextureCoordinate7.X = (1.0f - TextureCoordinate7.X);
153  TextureCoordinate8.X = (1.0f - TextureCoordinate8.X);
154  TextureCoordinate9.X = (1.0f - TextureCoordinate9.X);
155  Tangent = -Tangent;
156  }
157 
159  {
160  return left.Equals(right);
161  }
162 
164  {
165  return !left.Equals(right);
166  }
167 
168  public override string ToString()
169  {
170  return string.Format("Position: {0}, Normal: {1}, Tangent: {2}, Texcoord0: {3}", Position, Normal, Tangent, TextureCoordinate0);
171  }
172  }
173 }
The layout of a vertex buffer with a set of VertexElement.
Represents a two dimensional mathematical vector.
Definition: Vector2.cs:42
static VertexElement Tangent(PixelFormat format, int offsetInBytes=AppendAligned)
Declares a VertexElement with the semantic "TANGENT".
static VertexElement TextureCoordinate(PixelFormat format, int offsetInBytes=AppendAligned)
Declares a VertexElement with the semantic "TEXCOORD".
VertexPositionNormalTangentMultiTexture(Vector3 position, Vector3 normal, Vector4 tangent, Vector2 textureCoordinate)
Initializes a new VertexPositionNormalTangentMultiTexture instance.
Describes a custom vertex format structure that contains position, color and 10 texture coordinates i...
Represents a three dimensional mathematical vector.
Definition: Vector3.cs:42
static VertexElement Normal(PixelFormat format, int offsetInBytes=AppendAligned)
Declares a VertexElement with the semantic "NORMAL".
Represents a four dimensional mathematical vector.
Definition: Vector4.cs:42
static VertexElement Position(PixelFormat format, int offsetInBytes=AppendAligned)
Declares a VertexElement with the semantic "POSITION".
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...