TriMesh.LoadVerticesFromBytes

TriMesh.LoadVerticesFromBytes method

Load vertices from bytes, the length of bytes must be an integer multiple of vertex size.

public void LoadVerticesFromBytes(byte[] verticesInBytes)
ParameterTypeDescription
verticesInBytesByte[]

Exceptions

exceptioncondition
ArgumentNullException
ArgumentException

Examples

The following code shows how to create an empty TriMesh and manually load vertices from raw bytes.

var indices = new int[] { 0,  1,  2 };
var vertices = new byte[]{
    0, 0, 0, 191,
    0, 0, 0, 0,
    0, 0, 0, 191,
    0, 0, 0, 191,
    0, 0, 0, 0,
    0, 0, 0, 63,
    0, 0, 0, 63,
    0, 0, 0, 0,
    0, 0, 0, 63
};
VertexDeclaration vd = new VertexDeclaration();
vd.AddField(VertexFieldDataType.FVector3, VertexFieldSemantic.Position);
//create an empty TriMesh with specified vertex declaration
var triMesh = new TriMesh("", vd);
//load vertices directly from bytes
triMesh.LoadVerticesFromBytes(vertices);
triMesh.AddTriangle(0, 1, 2);
int[] indices = new int[] { 0,  1,  2 };
byte[] vertices = new byte[]{
    0, 0, 0, 191,
    0, 0, 0, 0,
    0, 0, 0, 191,
    0, 0, 0, 191,
    0, 0, 0, 0,
    0, 0, 0, 63,
    0, 0, 0, 63,
    0, 0, 0, 0,
    0, 0, 0, 63
};
VertexDeclaration vd = new VertexDeclaration();
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.POSITION);
//create an empty TriMesh with specified vertex declaration
var triMesh = new TriMesh("", vd);
//load vertices directly from bytes
triMesh.loadVerticesFromBytes(vertices);
triMesh.addTriangle(0, 1, 2);

See Also