PDA

View Full Version : node->setMaterialTexture can not set 2 Material in same layer and improve it



feelthat
05-31-2013, 08:28 AM
IAnimatedMesh* mesh0 = pScene->getMesh( (GetBaseAppPath() + "game/dwarf.x").c_str());
IAnimatedMeshSceneNode* node0 = pScene->addAnimatedMeshSceneNode( mesh0 );

node0->setMaterialTexture(0, IrrlichtManager::GetIrrlichtManager()->GetDriver()->getTexture( (GetBaseAppPath() + "game/axe.rttex").c_str() ));

node0->setMaterialTexture(0, IrrlichtManager::GetIrrlichtManager()->GetDriver()->getTexture( (GetBaseAppPath() + "game/dwarf.rttex").c_str() ));

above code will fail on 2 Material in layer 0

////////////fixed as follow/////////////

node0->setGroupMaterialTexture(0, 0, IrrlichtManager::GetIrrlichtManager()->GetDriver()->getTexture( (GetBaseAppPath() + "game/axe.rttex").c_str() ));

node0->setGroupMaterialTexture(1, 0, IrrlichtManager::GetIrrlichtManager()->GetDriver()->getTexture( (GetBaseAppPath() + "game/dwarf.rttex").c_str() ));

///////////////add code in IsceneNode.h////////////

void setGroupMaterialTexture(u32 groupid, u32 textureLayer, video::ITexture* texture)
{
if (textureLayer >= video::MATERIAL_MAX_TEXTURES)
return;

if( groupid< getMaterialCount() )
getMaterial(groupid).setTexture(textureLayer, texture);
}
//

ref. http://www.cnblogs.com/flysnow/archive/2006/07/28/462093.html in chinese