Problem setting the attribute table of a mesh
I have a problem setting the attribute table of a mesh. The original mesh has only one attribute range. I like to change it and to add another one like this:
D3DXATTRIBUTERANGE ar[2];
ar[0].AttribId = 0;
ar[0].FaceCount = 2;
ar[0].FaceStart = 0;
ar[0].VertexCount = 6;
ar[0].VertexStart = 0;
ar[1].AttribId = 1;
ar[1].FaceCount = 10;
ar[1].FaceStart = 2;
ar[1].VertexCount = 30;
ar[1].VertexStart = 6;
V(m_pMesh->SetAttributeTable( ar, 2 ));
But like this SetAttributeTable returns an error. It works fine when I just set the first table. Can somebody help?
Thanks.
Nico
[654 byte] By [
NicoRi] at [2008-2-16]
NicoRi wrote: |
| I have a problem setting the attribute table of a mesh. |
|
You probably don't want to set the attribute table of a mesh. It's a bit confusing, but the attribute table is essentially an internal data structure created automatically from the attribute buffer when you call the
Optimize() method. The attribute buffer is a simpler, more general, data structure: an array of
DWORDs, one per face in your mesh. It doesn't require that attributes be sorted.
What you'ld probably want to do is something like:
| | DWORD *ab; m_pmesh->LockAttributeBuffer(0, &ab); ab[0] = 0; ab[1] = 0; for (int i = 2; i < 12; i++) { ab[ i ] = 1; } m_pmesh->UnlockAttributeBuffer(); m_pmesh->OptimizeInPlace(D3DXMESHOPT_ATTRSORT, ...); |
The
SetAttributeTable() method is ment for when you make changes to an already optimized mesh that require the attribute table to be updated, and you don't want to take the performance hit of optimizing the mesh again.
Ross Ridge