I knew it couldn't be that easy or someone would have done it !

So I understand the core of the problem now: a vertex can have multiple skin points, even on a single UVmap. Ofcourse..

I wonder, though.. If you where to edit the mesh, breaking vertices everywhere, wouldn't that affect the shading? When a vertex (in 3D space, not on the UV) is duplicated its normal cannot be interpolated and you will get 'flat shading'. Maybe this just isn't a problem when all the lighting is in the skin anyway?

I looked in the sampledll and it uses d3dx9.h not d3d9.h. This file is included in the directX SDK, which you can download from microsoft. The code I have so far (quick and dirty without much error handling):
Code:

DLLFUNC var assignUV(ENTITY* ent)
{
if (!ent) return 0;

LPD3DXMESH entMesh = (LPD3DXMESH)ent_mesh(ent, 0);
int numVertices = _INT(ent_vertices(ent));

VERTEX* pVerts = NULL;
entMesh->LockVertexBuffer(0, reinterpret_cast<void**> (&pVerts));

for(int i = 0; i < numVertices; i++)
{
//pVerts[i].tu2 = pVerts[i].tu1; // Copy v1 to v2
//pVerts[i].tv2 = pVerts[i].tv1;
//pVerts[i].tu1 = 0.0f;
//pVerts[i].tv1 = 0.0f;

pVerts[i].tu2 = 0.0f; // alternative: empty v2 (seems to contain v1 usually)
pVerts[i].tv2 = 0.0f;

}

entMesh->UnlockVertexBuffer();
return _VAR(1);

}



pVerts is just a pointer, so using [] translates to pointer arithmetic. It's the same as &(pVerts + i), it moves the pointer ahead i * sizeof(VERTEX) each time (sorry if you knew this, I have no idea of your C++ skill but I thought this was pretty smart ).