#region CPL License
/*
Nuclex Framework
Copyright (C) 2002-2009 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#endregion
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;
namespace Nuclex.Graphics {
///
/// Describes the usage and purpose of an element in a vertex structure
///
///
/// Based on ideas from Michael Popoloski's article on gamedev.net:
/// http://www.gamedev.net/reference/programming/features/xnaVertexElement/
///
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public sealed class VertexElementAttribute : Attribute {
/// Initializes a new vertex element attribute
/// What purpose the vertex element will serve
public VertexElementAttribute(VertexElementUsage usage) {
this.usage = usage;
}
/// Initializes a new vertex element attribute
/// What purpose the vertex element will serve
/// Format in in which the data for this element is provided
public VertexElementAttribute(VertexElementUsage usage, VertexElementFormat format) :
this(usage) {
this.format = format;
this.formatProvided = true;
}
/// Index of the vertex buffer that will contain this element
///
/// Data for vertices can come from multiple vertex buffers. For example, you can store
/// the positions of your vertices in one vertex buffer and then store the texture
/// coordinates in an entirely different vertex buffer, only to combine them at rendering
/// time by using the two vertex buffers simultaneously two feed your shader.
///
public int Stream {
get { return this.stream; }
set { this.stream = value; }
}
/// What purpose the vertex element is going to be used for
public VertexElementUsage Usage {
get { return this.usage; }
}
/// Format the vertex element's data is provided in
public VertexElementFormat Format {
get { return this.format; }
}
/// Index of the element when multiple elements share the same usage
public byte UsageIndex {
get { return this.usageIndex; }
set { this.usageIndex = value; }
}
/// True if a format has been provided for the vertex element
internal bool FormatProvided {
get { return this.formatProvided; }
}
/// Index of the vertex buffer that will contain this element
private int stream;
/// What purpose the vertex element is going to be used for
private VertexElementUsage usage;
/// Format the vertex element's data is provided in
private VertexElementFormat format;
/// Index of the element when multiple elements share the same usage
private byte usageIndex;
/// Whether a format has been provided for this element
private bool formatProvided;
}
} // namespace Nuclex.Graphics