Skip to content

Commit

Permalink
Added normal vertex usage (#89)
Browse files Browse the repository at this point in the history
Added normal vertex usage
  • Loading branch information
Scellow authored and tlgkccampbell committed May 28, 2018
1 parent a1907b4 commit fdbf4d1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Source/Ultraviolet/Shared/Graphics/VertexPositionNormalTexture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace Ultraviolet.Graphics
{
/// <summary>
/// Represents a vertex containing 3D position, normal, and texture coordinate data.
/// </summary>
public struct VertexPositionNormalTexture : IVertexType
{
/// <summary>
/// Initializes a new instance of the <see cref="VertexPositionNormalTexture"/> structure.
/// </summary>
/// <param name="position">The vertex position.</param>
/// <param name="normal">The vertex normal.</param>
/// <param name="textureCoordinate">The texture coordinate.</param>
public VertexPositionNormalTexture(Vector3 position, Vector3 normal, Vector2 textureCoordinate)
{
this.Position = position;
this.Normal = normal;
this.TextureCoordinate = textureCoordinate;
}

/// <summary>
/// Gets the vertex declaration.
/// </summary>
VertexDeclaration IVertexType.VertexDeclaration
{
get { return VertexDeclaration; }
}

/// <summary>
/// The vertex declaration.
/// </summary>
public static readonly VertexDeclaration VertexDeclaration = new VertexDeclaration(new[] {
new VertexElement(0, VertexFormat.Vector3, VertexUsage.Position, 0),
new VertexElement(sizeof(Single) * 3, VertexFormat.Vector3, VertexUsage.Normal, 0),
new VertexElement(sizeof(Single) * 3 + sizeof(Single) * 3, VertexFormat.Vector2, VertexUsage.TextureCoordinate, 0),
});

/// <summary>
/// The vertex position.
/// </summary>
public Vector3 Position;

/// <summary>
/// The vertex normal.
/// </summary>
public Vector3 Normal;

/// <summary>
/// The texture coordinate.
/// </summary>
public Vector2 TextureCoordinate;
}
}
5 changes: 5 additions & 0 deletions Source/Ultraviolet/Shared/Graphics/VertexUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@ public enum VertexUsage
/// The element provides texture coordinate data.
/// </summary>
TextureCoordinate,

/// <summary>
/// The element provides normal data.
/// </summary>
Normal,
}
}

0 comments on commit fdbf4d1

Please sign in to comment.