I try to make mesh by creating vertex buffer and index buffer as next code:
void CD3DSimulationView::CreateMeshes()
{
unsigned short nNumFaces = 12;
unsigned short nNumVertices = 8;
D3DXCreateMeshFVF(nNumFaces, nNumVertices, D3DXMESH_VB_MANAGED, D3DFVF_XYZ, m_pd3dDevice, &m_pMesh);
//m_pMesh - is object declared in CD3DSimulationView
CUSTOMVERTEX* pVertices;
m_pMesh->LockVertexBuffer(D3DLOCK_DISCARD, (void**)&pVertices);
float front = -1.0;
float back = 1.0;
float left = -1.0;
float right = 1.0;
float top = 1.0;
float bottom = -1.0;
pVertices[0].m_pVertices = D3DXVECTOR3(left, bottom, front);
pVertices[1].m_pVertices = D3DXVECTOR3(right, bottom, front);
pVertices[2].m_pVertices = D3DXVECTOR3(left, top, front);
pVertices[3].m_pVertices = D3DXVECTOR3(right, top, front);
pVertices[4].m_pVertices = D3DXVECTOR3(left, bottom, back);
pVertices[5].m_pVertices = D3DXVECTOR3(right, bottom, back);
pVertices[6].m_pVertices = D3DXVECTOR3(left, top, back);
pVertices[7].m_pVertices = D3DXVECTOR3(right, top, back);
m_pMesh->UnlockVertexBuffer();
UINT *pIB = NULL;
m_pMesh->LockIndexBuffer( 0, (void**)&pIB);
short leftbottomfront = 0;
short rightbottomfront = 1;
short lefttopfront = 2;
short righttopfront = 3;
short leftbottomback = 4;
short rightbottomback = 5;
short lefttopback = 6;
short righttopback = 7;
pIB[0] = lefttopfront;
pIB[1] = lefttopback;
pIB[2] = leftbottomback;
pIB[3] = leftbottomback;
pIB[4] = leftbottomfront;
pIB[5] = lefttopfront;
pIB[6] = lefttopfront;
pIB[7] = leftbottomfront;
pIB[8] = rightbottomfront;
pIB[9] = rightbottomfront;
pIB[10] = righttopfront;
pIB[11] = lefttopfront;
pIB[12] = righttopback;
pIB[13] = righttopfront;
pIB[14] = rightbottomfront;
pIB[15] = rightbottomfront;
pIB[16] = rightbottomback;
pIB[17] = righttopback;
pIB[18] = leftbottomback;
pIB[19] = lefttopback;
pIB[20] = righttopback;
pIB[21] = righttopback;
pIB[22] = rightbottomback;
pIB[23] = leftbottomback;
pIB[24] = righttopfront;
pIB[25] = righttopback;
pIB[26] = lefttopback;
pIB[27] = lefttopback;
pIB[28] = lefttopfront;
pIB[29] = righttopfront;
pIB[30] = leftbottomfront;
pIB[31] = leftbottomback;
pIB[32] = rightbottomback;
pIB[33] = rightbottomback;
pIB[34] = rightbottomfront;
pIB[35] = leftbottomfront;
m_pMesh->UnlockIndexBuffer();
Render();
}
But when I run render process of the created mesh, no object on the screan appear as I expect.
I need to create parallelipiped. What is that I miss in my function.
Is it possible to send me some examples or links that I shall be able to find more information.
Sincerely Yours
Kamen












