Original Post
I'm trying join individual smaller meshes into one large mesh. My first step was to just create a single copy of a mesh manually. (I realize that for a single mesh you'd normally just clone it, but this code is to join some meshes together.) It runs without error, but when I render I get nothing.
This also doesn't render:
// In Class Declaration CD3DMesh *m_pWall; // Wall Object CD3DMesh *m_pWallComb; // Copied Wall Object //In Create m_pWall = new CD3DMesh; // Wall m_pWallComb = new CD3DMesh; // Wall Combined
// In InitDeviceObjects()
// Load a wall
if( FAILED( m_pWall->Create( m_pd3dDevice, _T("wall2.x") ) ) )
return D3DAPPERR_MEDIANOTFOUND;
// Copy Wall
LPDIRECT3DVERTEXBUFFER8 pVB;
LPDIRECT3DVERTEXBUFFER8 pVB2;
DWORD meshFVF;
UINT uiFVFSize;
DWORD dwNumVertices = m_pWall->GetSysMemMesh()->GetNumVertices();
DWORD dwNumFaces = m_pWall->GetSysMemMesh()->GetNumFaces();
meshFVF = m_pWall->GetSysMemMesh()->GetFVF();
uiFVFSize = D3DXGetFVFVertexSize(meshFVF );
D3DXCreateMeshFVF(dwNumFaces, dwNumVertices, D3DXMESH_SYSTEMMEM, meshFVF,m_pd3dDevice, &m_pWallComb->m_pSysMemMesh);
if(SUCCEEDED(m_pWall->GetSysMemMesh()->GetVertexBuffer(&pVB)))
{
if(SUCCEEDED(m_pWallComb->GetSysMemMesh()->GetVertexBuffer(&pVB2)))
{
// uiFVFSize = 32 for this mesh 8*FLOAT=32
struct VERTEX { FLOAT x,y,z,tu,tv,a,b,c; };
VERTEX* pVertices;
VERTEX* pVertices2;
pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 );
pVB2->Lock( 0, 0, (BYTE**)&pVertices2, 0 );
memcpy(pVertices2,pVertices,uiFVFSize*dwNumVertices);
pVB2->Unlock();
pVB2->Release();
pVB->Unlock();
}
pVB->Release();
}
m_pWallComb->m_dwNumMaterials = m_pWall->m_dwNumMaterials;
m_pWallComb->m_pMaterials = new D3DMATERIAL8[m_pWallComb->m_dwNumMaterials];
m_pWallComb->m_pTextures = new LPDIRECT3DTEXTURE8[m_pWallComb->m_dwNumMaterials];
memcpy(m_pWallComb->m_pMaterials,m_pWall->m_pMaterials,sizeof(D3DMATERIAL8)*m_pWallComb->m_dwNumMaterials);
TCHAR strTexture[MAX_PATH];
TCHAR strTextureTemp[MAX_PATH];
DXUtil_ConvertAnsiStringToGeneric( strTextureTemp, _T("wall.bmp") );
DXUtil_FindMediaFile( strTexture, strTextureTemp );
if( FAILED( D3DXCreateTextureFromFile( m_pd3dDevice, strTexture,
&m_pWallComb->m_pTextures[0] ) ) )
m_pWallComb->m_pTextures[0] = NULL;
m_pWallComb->m_dwNumMaterials = m_pWall->m_dwNumMaterials; m_pWallComb->m_pMaterials = m_pWall->m_pMaterials; m_pWallComb->m_pTextures = m_pWall->m_pTextures;I'm sure it's either something stupid or something I don't know that I'm supposed to do. I have traced it and DrawSubset is being called, and D3DXCreateMeshFVF is not failing. Any help would be appreciated. Shad [edited by - ShadowCoder on October 5, 2002 10:06:55 PM]