Jump to content
  • Advertisement
Sign in to follow this  

Need help with atribute buffer DX9 C++

This topic is 2793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am confused with DrawIndexedPrimitive() DX9. I am myself create Attribute Buffer, create Vert Buffer and Index Buffer. But 3D model don`t render properly. What is the matter? What I draw my model of room without attribute buffer- it draw properly. But if I use my attribute buffer its draw not correct.

Indices Array arranged by material. That is for example:
Mat #1 - > face 1, face 2, face 3
Mat #2 -> face 4, face 5, face 6 etc.
And indices array contain:
1, 2, 3, 4, 5, 6 etc.

My code:

pTR2RoomMesh.pAttr = new D3DXATTRIBUTERANGE[pTR2RoomMesh.nNumMat];
for(UINT k=0; k<pTR2RoomMesh.nNumMat; k++)
set <int> myset;
for(UINT j=0; j< v[k].size(); j++)
//calculate count of vertex in attribute buffer k
UINT v1, v2, v3;
UINT face = v[k][j].face;
v1 = pTR2RoomMesh.pIndicesArrayNew[face*3];
v2 = pTR2RoomMesh.pIndicesArrayNew[face*3 + 1];
v3 = pTR2RoomMesh.pIndicesArrayNew[face*3 + 2];
pTR2RoomMesh.pAttr[k].AttribId = k;
pTR2RoomMesh.pAttr[k].VertexStart = pTR2RoomMesh.pIndicesArrayNew[vn[k][0].face*3];
pTR2RoomMesh.pAttr[k].VertexCount = vn[k].size() * 3 ;// (DWORD) myset.size();
pTR2RoomMesh.pAttr[k].FaceStart = vn[k][0].face;
pTR2RoomMesh.pAttr[k].FaceCount = (DWORD) vn[k].size();
//draw room
for (int i = 0; i < Level->NumRooms; i++)
for(int k = 0; k < pTR2RoomMesh.nNumMat; k++)
m_pD3DDevice->SetStreamSource( 0, pTR2RoomMesh.pVB, 0, sizeof(LEVEL_VERTEX) );
m_pD3DDevice->SetIndices( pTR2RoomMesh.pIB );
m_pD3DDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,
pTR2RoomMesh.pAttr[k].VertexStart, //MinIndex
pTR2RoomMesh.pAttr[k].VertexCount, //NumVertices
pTR2RoomMesh.pAttr[k].FaceStart*3, //StartIndex
pTR2RoomMesh.pAttr[k].FaceCount ); //NumPrimitives

Thanks in advance!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!