Original Post
Hi! I'm writing my own Mesh class for Dx10 and got some problem using DrawIndexed. I wrote exporter from 3d max and in my mesh file I got something like: Submesh 1 NrVerts 340 NrInd 580 Vertex1 -3,0,4 Vertex2 ... Index1 0,1,3 Index2 ... Submesh 2 NrVerts 133 NrInd 220 Vertex1 -2,5,8 ... Index1 0,5,7 ... I'm creating VertexBuffer which holds ALL vertices (from all submeshes) and the same goes with IndexBuffer. And my drawing function looks: It's ok if i'm rendering only first submesh but if there are more it looks like this: http://img407.imageshack.us/my.php?image=teapot.jpg And this is how I set all paremeters which I pass to DrawIndexed: m_uiNumOfIndices = (num of faces I parse from file) m_uiStartingIndex = (num of faces of all previous submeshes) m_iBaseVertexLocation = (num of vertices of all previous submeshes) Can anybody tell me what am I doing wrong?
UINT uiStride = sizeof(cVertex);
UINT uiOffset = 0;
Graphics()->GetDevice()->IASetVertexBuffers(0, 1, &m_pVertexBuffer, &uiStride, &uiOffset);
Graphics()->GetDevice()->IASetIndexBuffer(m_pIndexBuffer, DXGI_FORMAT_R32_UINT, m_Submeshes[SubmeshNr].m_uiStartingIndex*sizeof(DWORD));
Graphics()->GetDevice()->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); Graphics()->GetDevice()->DrawIndexed(m_Submeshes[SubmeshNr].m_uiNumOfIndices*3, m_Submeshes[SubmeshNr].m_uiStartingIndex, m_Submeshes[SubmeshNr].m_iBaseVertexLocation);