Added material example (aiMaterial to D3DMATERIAL9)

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@31 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2008-05-23 11:45:56 +00:00
parent 16621e07cd
commit b958535efa
1 changed files with 43 additions and 1 deletions

View File

@ -353,6 +353,48 @@ a set of properties accessible by their names. Have a look at aiMaterial.h to se
properties are defined. In this file there are also various functions defined to test for the
presence of certain properties in a material and retrieve their values.
Example to convert from an Assimp material to a Direct3D 9 material for use with the fixed
function pipeline. Textures are not handled, only colors and the specular power:
@code
void ConvertColor ( const aiColor4D& clrIn, D3DCOLORVALUE& clrOut )
{
clrOut.r = clrIn.r;
clrOut.g = clrIn.g;
clrOut.b = clrIn.b;
clrOut.a = clrIn.a;
}
void ConvertMaterial( aiMaterial* matIn, D3DMATERIAL9* matOut )
{
// ***** DIFFUSE MATERIAL COLOR
aiColor4D clr(0.0f,0.0f,0.0f,1.0f);
// if the material property is not existing, the passed color pointer
// won't be modified, therefore the diffuse color would be BLACK in this case
aiGetMaterialColor(matIn,AI_MATKEY_COLOR_DIFFUSE,&clr);
ConvertColor ( clr, matOut.Diffuse );
// ***** SPECULAR MATERIAL COLOR
clr = aiColor4D(1.0f,1.0f,1.0f,1.0f);
aiGetMaterialColor(matIn,AI_MATKEY_COLOR_SPECULAR,&clr);
ConvertColor ( clr, matOut.Specular );
// ***** AMBIENT MATERIAL COLOR
clr = aiColor4D(0.0f,0.0f,0.0f,1.0f);
aiGetMaterialColor(matIn,AI_MATKEY_COLOR_AMBIENT,&clr);
ConvertColor ( clr, matOut.Ambient );
// ***** EMISIVE MATERIAL COLOR (Self illumination)
clr = aiColor4D(0.0f,0.0f,0.0f,1.0f);
aiGetMaterialColor(matIn,AI_MATKEY_COLOR_EMISSIVE,&clr);
ConvertColor ( clr, matOut.Emissive );
// ***** SHININESS (Phong power)
matOut.Power = 0.0f;
aiGetMaterialFloat(matIn,AI_MATKEY_COLOR_EMISSIVE,&matOut.Power);
}
@endcode
@section bones Bones
A mesh may have a set of bones. Bones are a means to deform a mesh according to the movement of