Game Development Reference
In-Depth Information
::MessageBox(0, "D3DXLoadMeshFromX() - FAILED", 0, 0);
return false;
}
After we have loaded the XFile data, we must iterate through the
D3DXMATERIAL array and load any textures that the mesh references:
//
// Extract the materials, load textures.
//
if( mtrlBuffer != 0 && numMtrls != 0 )
{
D3DXMATERIAL* mtrls=(D3DXMATERIAL*)mtrlBuffer->
GetBufferPointer();
for(inti=0;i<numMtrls; i++)
{
// the MatD3D property doesn't have an ambient value
// set when it's loaded, so set it now:
mtrls[i].MatD3D.Ambient = mtrls[i].MatD3D.Diffuse;
// save the ith material
Mtrls.push_back( mtrls[i].MatD3D );
// check if the ith material has an associative
// texture
if( mtrls[i].pTextureFilename != 0 )
{
// yes, load the texture for the ith subset
IDirect3DTexture9* tex = 0;
D3DXCreateTextureFromFile(
Device,
mtrls[i].pTextureFilename,
&tex);
// save the loaded texture
Textures.push_back( tex );
}
else
{
// no texture for the ith subset
Textures.push_back( 0 );
}
}
}
d3d::Release<ID3DXBuffer*>(mtrlBuffer); // done w/ buffer
.
. // Snipped irrelevant code to this chapter (e.g., setting up lights,
. // view and projection matrices, etc.)
.
return true;
} // end Setup()
Search WWH ::




Custom Search