This topic is now archived and is closed to further replies.


LockAttributeBuffer() :( What a headache

Recommended Posts

Does anyone know how when using the LPD3DXMESH interface you can set the attribute buffer up so that you specify the vertices subsets, I have almost completed a mesh class, which holds the various textures and states in a list of structs, these contain start and size variables for the mesh, but whenever I try to access the attribute buffer it does not seem to want to change the drawsubset() table. Can anyone help me with this. My code snippet is : LPD3DXMESH pMesh = NULL; ... Mesh Creation ... Adjacency Buffer Creation ... Index/Vertex Buffer Creation LPD3DXATTRIBUTERANGE pAtt = new D3DXATTRIBUTERANGE[2]; pAtt[0]-> ... populate Subset Id 0 /and info ....[1]-> ... populate Subset Id 1 LPD3DXATTRIBUTERANGE pAttribs = NULL; m_pMesh->LockAttributeBuffer(D3DLOCK_NOSYSLOCK,(DWORD**)&pAttribs); memcpy(pAttribs,pAtt,sizeof(D3DXATTRIBUTERANGE)*2); m_pMesh->UnlockAttributeBuffer(); I thought this would be enough but oviously not, can anyone PLEASE help. I tried using a 'new' also for the pointer passed back from the lock attribute buffer class, I just cant seem to understand how to store my attributes in the table. Regards Matthew Eva Edited by - MatthewEva on October 15, 2001 9:09:50 AM

Share this post

Link to post
Share on other sites
When you lock the buffer you get array of DWORDS!!! One DWORD for each triangle.

I think D3DX uses ATTRIBUTERANGE inside when mesh is optimized.

DWORD *pAttrTable = NULL;

HRESULT hr = pMesh->LockAttributeBuffer(0,&pAttrTable);

if( !FAILED(hr) )

pAttrTable[0] = 0; // 1st face belongs to group 0

pAttrTable[1] = 3; // 2nd face belongs to group 3

// ...


This is what I remember how I did it. But what you did is definitely illegal.

Edited by - stefu on October 15, 2001 10:03:18 AM

Share this post

Link to post
Share on other sites
Many thanks, I will try that.

I guess the ATTRIBUTE structure is only used for reading the information then, and dor assigning the values you only use one DWORD for each triangle, makes things very simple.

Thanks Alot

Share this post

Link to post
Share on other sites