Original Post
I'm kind of new to C# and .Net and I was wondering how (if possible) to cast a structure, like this: into a single dimensional array of floats (float[]). In memory, it should already be stored like a linear array, so I'd think it'd be possible, but I don't know how to do the cast. Currently I'm converting them in a loop something like this: but this really seems unnecessary to me. Can anyone help?
[ StructLayout( LayoutKind.Sequential, Pack = 1)]
public struct Vertex
{
public float x, y, z;
}
for (int i = 0; i < numVerts; i++)
{
vert[3 * i + 0] = vertex.x;
vert[3 * i + 1] = vertex.y;
vert[3 * i + 2] = vertex.z;
}