static public unsafe void swzzlGrnyVertsToD3DVerts(byte[] grnyVerts, VertexDeclaration grnyVD, int vertMemSize, int numVerts, ref byte[] d3dVerts, VertexDeclaration d3dVD) { //loop through all the verts and swizzle them to be FVF friendly for d3d VertexElement[] grnVE = grnyVD.GetDeclaration(); VertexElement[] d3dVE = d3dVD.GetDeclaration(); for (int j = 0; j < grnVE.Length; j++) { VertexElement ve = grnVE[j]; for (int k = 0; k < d3dVE.Length; k++) { VertexElement dstVE = d3dVE[k]; if (dstVE.DeclarationUsage == ve.DeclarationUsage) { int count = sizeof(float) * 3; if (ve.DeclarationType == DeclarationType.Float3) { count = sizeof(float) * 3; } if (ve.DeclarationType == DeclarationType.Float2) { count = sizeof(float) * 2; } if (ve.DeclarationType == DeclarationType.Float1) { count = sizeof(float) * 1; } if (ve.DeclarationType == DeclarationType.Color) { count = sizeof(int); } if (ve.DeclarationType == DeclarationType.Ubyte4N) { count = sizeof(int); } for (int i = 0; i < numVerts; i++) { int srcInd = (i * vertMemSize) + ve.Offset; int dstInd = (i * vertMemSize) + dstVE.Offset; for (int q = 0; q < count; q++) { d3dVerts[dstInd + q] = grnyVerts[srcInd + q]; } } k = d3dVE.Length + 1;; } } } }