• Advertisement

Archived

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

2 meshes

This topic is 5244 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

ok, this is the code for loading a mesh and its materials in C++ .net: LPD3DXBUFFER pD3DXMtrlBuffer; // Load the mesh from the specified file if( FAILED( D3DXLoadMeshFromX( "Tiger.x", D3DXMESH_SYSTEMMEM, g_pd3dDevice, NULL, &pD3DXMtrlBuffer, NULL, &g_dwNumMaterials, &g_pMesh ) ) ) { // If model is not in current folder, try parent folder if( FAILED( D3DXLoadMeshFromX( "..\\Tiger.x", D3DXMESH_SYSTEMMEM, g_pd3dDevice, NULL, &pD3DXMtrlBuffer, NULL, &g_dwNumMaterials, &g_pMesh ) ) ) { MessageBox(NULL, "Could not find tiger.x", "Meshes.exe", MB_OK); return E_FAIL; } } // We need to extract the material properties and texture names from the // pD3DXMtrlBuffer D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer(); g_pMeshMaterials = new D3DMATERIAL9[g_dwNumMaterials]; g_pMeshTextures = new LPDIRECT3DTEXTURE9[g_dwNumMaterials]; for( DWORD i=0; i = d3dxMaterials[i].MatD3D; // Set the ambient color for the material (D3DX does not do this) g_pMeshMaterials[i].Ambient = g_pMeshMaterials[i].Diffuse; g_pMeshTextures[i] = NULL; if( d3dxMaterials[i].pTextureFilename != NULL && lstrlen(d3dxMaterials[i].pTextureFilename) > 0 ) { // Create the texture if( FAILED( D3DXCreateTextureFromFile( g_pd3dDevice, d3dxMaterials[i].pTextureFilename, &g_pMeshTextures[i] ) ) ) { // If texture is not in current folder, try parent folder const TCHAR* strPrefix = TEXT("..\\"); const int lenPrefix = lstrlen( strPrefix ); TCHAR strTexture[MAX_PATH]; lstrcpyn( strTexture, strPrefix, MAX_PATH ); lstrcpyn( strTexture + lenPrefix, d3dxMaterials[i].pTextureFilename, MAX_PATH - lenPrefix ); // If texture is not in current folder, try parent folder if( FAILED( D3DXCreateTextureFromFile( g_pd3dDevice, strTexture, &g_pMeshTextures[i] ) ) ) { MessageBox(NULL, "Could not find texture map", "Meshes.exe", MB_OK); } } } } // Done with the material buffer pD3DXMtrlBuffer->Release(); return S_OK; now my question is, if i just copy and paste a second one of these will it load 2 meshes into the window or will some error happen?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
someone help me please if at all possibal

Share this post


Link to post
Share on other sites

  • Advertisement