Advertisement
Guest User

Untitled

a guest
Aug 10th, 2010
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. // Loading the material buffer
  2. D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)materialBuffer->GetBufferPointer();
  3. // Holding material and texture pointers
  4. D3DMATERIAL9 *meshMaterials = new D3DMATERIAL9[numMaterials];
  5. LPDIRECT3DTEXTURE9 *meshTextures  = new LPDIRECT3DTEXTURE9[numMaterials];
  6. // Filling material and texture arrays
  7. for (DWORD i=0; i<numMaterials; i++)
  8. {
  9.     // Copy the material
  10.     meshMaterials[i] = d3dxMaterials[i].MatD3D;
  11.     // Set the ambient color for the material (D3DX does not do this)
  12.     meshMaterials[i].Ambient = meshMaterials[i].Diffuse;
  13.     // Create the texture if it exists - it may not
  14.     meshTextures[i] = NULL;
  15.     if (d3dxMaterials[i].pTextureFilename)
  16.         D3DXCreateTextureFromFile(d3dDevice, d3dxMaterials[i].pTextureFilename, &meshTextures[i]);
  17. }
  18.    
  19. ...........
  20. ...........
  21. ...........
  22.    
  23. for (DWORD i=0; i<numMaterials; i++)
  24. {
  25.     // Set the material and texture for this subset
  26.     d3dDevice->SetMaterial(&meshMaterials[i]);
  27.     d3dDevice->SetTexture(0,meshTextures[i]);
  28.     // Draw the mesh subset
  29.     mesh->DrawSubset( i );
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement