Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Loading the material buffer
- D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)materialBuffer->GetBufferPointer();
- // Holding material and texture pointers
- D3DMATERIAL9 *meshMaterials = new D3DMATERIAL9[numMaterials];
- LPDIRECT3DTEXTURE9 *meshTextures = new LPDIRECT3DTEXTURE9[numMaterials];
- // Filling material and texture arrays
- for (DWORD i=0; i<numMaterials; i++)
- {
- // Copy the material
- meshMaterials[i] = d3dxMaterials[i].MatD3D;
- // Set the ambient color for the material (D3DX does not do this)
- meshMaterials[i].Ambient = meshMaterials[i].Diffuse;
- // Create the texture if it exists - it may not
- meshTextures[i] = NULL;
- if (d3dxMaterials[i].pTextureFilename)
- D3DXCreateTextureFromFile(d3dDevice, d3dxMaterials[i].pTextureFilename, &meshTextures[i]);
- }
- ...........
- ...........
- ...........
- for (DWORD i=0; i<numMaterials; i++)
- {
- // Set the material and texture for this subset
- d3dDevice->SetMaterial(&meshMaterials[i]);
- d3dDevice->SetTexture(0,meshTextures[i]);
- // Draw the mesh subset
- mesh->DrawSubset( i );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement