Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 10th, 2010  |  syntax: C++  |  size: 1.01 KB  |  views: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data