Rev 784 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BauzoidNET.graphics.model
{
public class VertexAttribute
{
// we only support a subset of the full SUX attribute list since OpenGL ES 2.0 can
// only have 8 attributes per vertex
public const int POSITION = 0;
public const int COLOR = 1;
public const int NORMAL = 2;
public const int TEXCOORD0 = 3;
public const int TEXCOORD1 = 4;
public const int BLENDINDICES = 5;
public const int BLENDWEIGHTS = 6;
public const int GENERIC = 7;
private int mAttribType = -1;
private int mCoordsPerElement = 0;
private int mByteOffset = 0;
/** Constructor. */
public VertexAttribute(int attribType, int coordsPerElement, int byteOffset)
{
mAttribType = attribType;
mCoordsPerElement = coordsPerElement;
mByteOffset = byteOffset;
}
/** Get the attribute type. */
public int getAttribType()
{
return mAttribType;
}
/** Get the number of coordinates per element - 2, 3 or 4. */
public int getCoordsPerElement()
{
return mCoordsPerElement;
}
/** Get the byte offset within an element - the first one (or the only one in an individual stream) is always 0. */
public int getByteOffset()
{
return mByteOffset;
}
/** Check if valid attribute type. */
public static bool isValidType(int type)
{
switch (type)
{
case 0: // Generic
case 1: // Position
case 2: // Normal
case 3: // Color
case 7: // TexCoord0
case 8: // TexCoord1;
case 15: // Blend Indices
case 16: // Blend Weights
return true;
default:
return false;
}
}
/** Convert SUX attribute type to internal. */
public static int toInternalType(int suxType)
{
switch (suxType)
{
case 0: return GENERIC;
case 1: return POSITION;
case 2: return NORMAL;
case 3: return COLOR;
case 7: return TEXCOORD0;
case 8: return TEXCOORD1;
case 15: return BLENDINDICES;
case 16: return BLENDWEIGHTS;
default: return -1;
}
}
}
}