Ogre::BillboardChain* BillboardLine::createChain() { std::stringstream ss; static int count = 0; ss << "BillboardLine chain" << count++; Ogre::BillboardChain* chain = scene_manager_->createBillboardChain(ss.str()); chain->setMaterialName( material_->getName() ); scene_node_->attachObject( chain ); chains_.push_back(chain); return chain; }
void ResourceGroupReloader::UpdateMaterialRenderableVisitor::visit( Ogre::Renderable *rend, Ogre::ushort lodIndex, bool isDebug, Ogre::Any *pAny) { const Ogre::MaterialPtr mat = rend->getMaterial(); if(!mat.isNull()) { std::string newMatName = mat->getName(); Ogre::MaterialPtr newMat = Ogre::MaterialManager::getSingleton().getByName(newMatName); if(newMat.isNull()) { // this can happen if there was error during the reloading of the material. // in that case, we keep the ancient one. // Ice::Log::Instance().LogMessage(newMatName+" : new material is null!"); return; } // unfortunately, the renderable gives access only to a const MaterialPtr. // and there is no 'setMaterial' or 'setMaterialName' method on renderables. // so I have to try to down cast with known classes... { Ogre::SubEntity* lRend = dynamic_cast<Ogre::SubEntity*>(rend); if(lRend){lRend->setMaterialName(newMatName);return;} } { Ogre::SimpleRenderable* lRend = dynamic_cast<Ogre::SimpleRenderable*>(rend); if(lRend){lRend->setMaterial(newMatName);return;} } { Ogre::ShadowRenderable* lRend = dynamic_cast<Ogre::ShadowRenderable*>(rend); if(lRend){lRend->setMaterial(newMat);return;} } { Ogre::BillboardChain* lRend = dynamic_cast<Ogre::BillboardChain*>(rend); if(lRend){lRend->setMaterialName(newMatName);return;} } { Ogre::BillboardSet* lRend = dynamic_cast<Ogre::BillboardSet*>(rend); if(lRend){lRend->setMaterialName(newMatName);return;} } { Ogre::OverlayElement* lRend = dynamic_cast<Ogre::OverlayElement*>(rend); if(lRend){lRend->setMaterialName(newMatName);return;} } }else{ // was there for debug... // Ice::Log::Instance().LogMessage("material of renderable is null!"); } }