Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
VertexPositionColorTextureSwizzle.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, texture and swizzle information.
12  /// </summary>
13  [StructLayout(LayoutKind.Sequential)]
14  public struct VertexPositionColorTextureSwizzle : IEquatable<VertexPositionColorTextureSwizzle>
15  {
16  /// <summary>
17  /// Initializes a new <see cref="VertexPositionColorTexture"/> instance.
18  /// </summary>
19  /// <param name="position">The position of this vertex.</param>
20  /// <param name="color">The color of this vertex.</param>
21  /// <param name="textureCoordinate">UV texture coordinates.</param>
22  /// <param name="swizzle">The swizzle mode</param>
23  public VertexPositionColorTextureSwizzle(Vector4 position, Color color, Vector2 textureCoordinate, SwizzleMode swizzle)
24  : this()
25  {
26  Position = position;
27  Color = color;
28  TextureCoordinate = textureCoordinate;
29  Swizzle = (int)swizzle;
30  }
31 
32  /// <summary>
33  /// XYZ position.
34  /// </summary>
35  public Vector4 Position;
36 
37  /// <summary>
38  /// The vertex color.
39  /// </summary>
40  public Color Color;
41 
42  /// <summary>
43  /// UV texture coordinates.
44  /// </summary>
46 
47  /// <summary>
48  /// The Swizzle mode
49  /// </summary>
50  public float Swizzle;
51 
52  /// <summary>
53  /// Defines structure byte size.
54  /// </summary>
55  public static readonly int Size = 28;
56 
57  /// <summary>
58  /// The vertex layout of this struct.
59  /// </summary>
60  public static readonly VertexDeclaration Layout = new VertexDeclaration(
64  new VertexElement("BATCH_SWIZZLE", PixelFormat.R32_Float)
65  );
66 
67 
69  {
70  return Position.Equals(other.Position) && Color.Equals(other.Color) && TextureCoordinate.Equals(other.TextureCoordinate);
71  }
72 
73  public override bool Equals(object obj)
74  {
75  if (ReferenceEquals(null, obj)) return false;
77  }
78 
79  public override int GetHashCode()
80  {
81  unchecked
82  {
83  int hashCode = Position.GetHashCode();
84  hashCode = (hashCode * 397) ^ Color.GetHashCode();
85  hashCode = (hashCode * 397) ^ TextureCoordinate.GetHashCode();
86  hashCode = (hashCode * 397) ^ Swizzle.GetHashCode();
87  return hashCode;
88  }
89  }
90 
91  public static bool operator ==(VertexPositionColorTextureSwizzle left, VertexPositionColorTextureSwizzle right)
92  {
93  return left.Equals(right);
94  }
95 
96  public static bool operator !=(VertexPositionColorTextureSwizzle left, VertexPositionColorTextureSwizzle right)
97  {
98  return !left.Equals(right);
99  }
100 
101  public override string ToString()
102  {
103  return string.Format("Position: {0}, Color: {1}, Texcoord: {2}, Swizzle: {3}", Position, Color, TextureCoordinate, Swizzle);
104  }
105  }
106 }
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".
Describes a custom vertex format structure that contains position, color, texture and swizzle informa...
TextureCoordinate
The texture coordinate.
override int GetHashCode()
Returns a hash code for this instance.
Definition: Color.cs:1118
Represents a four dimensional mathematical vector.
Definition: Vector4.cs:42
SiliconStudio.Core.Mathematics.Color Color
Definition: ColorPicker.cs:14
VertexPositionColorTextureSwizzle(Vector4 position, Color color, Vector2 textureCoordinate, SwizzleMode swizzle)
Initializes a new VertexPositionColorTexture instance.
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".
SwizzleMode
Specify how to swizzle a vector.
Definition: SwizzleMode.cs:8
PixelFormat
Defines various types of pixel formats.
Definition: PixelFormat.cs:32
A description of a single element for the input-assembler stage. This structure is related to Direct3...