-
Notifications
You must be signed in to change notification settings - Fork 0
/
VertexPositionNormalColor.cs
85 lines (74 loc) · 2.62 KB
/
VertexPositionNormalColor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// This definition doesn't exist in SharpDX for some reason so I've added it
using System;
using System.Runtime.InteropServices;
using SharpDX;
using SharpDX.Toolkit;
using SharpDX.Toolkit.Graphics;
namespace Project1
{
/// <summary>
/// Describes a custom vertex format structure that contains position and color information.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct VertexPositionNormalColor : IEquatable<VertexPositionNormalColor>
{
/// <summary>
/// Initializes a new <see cref="VertexPositionNormalColor"/> instance.
/// </summary>
/// <param name="position">The position of this vertex.</param>
/// <param name="normal">The vertex normal.</param>
/// <param name="color">The color of this vertex.</param>
public VertexPositionNormalColor(Vector3 position, Vector3 normal, Color color) : this()
{
Position = position;
Normal = normal;
Color = color;
}
/// <summary>
/// XYZ position.
/// </summary>
[VertexElement("SV_POSITION")]
public Vector3 Position;
/// <summary>
/// The vertex normal.
/// </summary>
[VertexElement("NORMAL")]
public Vector3 Normal;
/// <summary>
/// Color.
/// </summary>
[VertexElement("COLOR")]
public Color Color;
public bool Equals(VertexPositionNormalColor other)
{
return Position.Equals(other.Position) && Normal.Equals(other.Normal) && Color.Equals(other.Color);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is VertexPositionNormalColor&& Equals((VertexPositionNormalColor) obj);
}
public override int GetHashCode()
{
unchecked
{
int hashCode = Position.GetHashCode();
hashCode = (hashCode * 397) ^ Normal.GetHashCode();
hashCode = (hashCode * 397) ^ Color.GetHashCode();
return hashCode;
}
}
public static bool operator ==(VertexPositionNormalColor left, VertexPositionNormalColor right)
{
return left.Equals(right);
}
public static bool operator !=(VertexPositionNormalColor left, VertexPositionNormalColor right)
{
return !left.Equals(right);
}
public override string ToString()
{
return string.Format("Position: {0}, Normal: {1}, Color: {2}", Position, Normal, Color);
}
}
}