コード例 #1
0
ファイル: Terrain.cpp プロジェクト: gitrider/wxsj2
void
Terrain::_deleteMaterials(void)
{
    Ogre::MaterialManager* materialManager = Ogre::MaterialManager::getSingletonPtr();
    // So we can delete this terrain after material manager is delete
    if (materialManager)
    {
        for (MaterialMap::const_iterator it = mMaterials.begin(); it != mMaterials.end(); ++it)
        {
            Ogre::ResourceHandle handle = it->second->getHandle();

            materialManager->remove(handle);
        }
    }
    mMaterials.clear();

    Ogre::TextureManager* textureManager = Ogre::TextureManager::getSingletonPtr();
    if (textureManager)
    {
        for (AtlasArray::const_iterator it = mAtlases.begin(); it != mAtlases.end(); ++it)
        {
            // Only remove composited textures.
            if (!it->texture.isNull() && !it->image.isNull())
            {
                textureManager->remove(it->texture->getHandle());
            }
        }

        for (TextureList::const_iterator it = mLightmapTextures.begin(); it != mLightmapTextures.end(); ++it)
        {
            textureManager->remove((*it)->getHandle());
        }
    }
    mAtlases.clear();
    mLightmapTextures.clear();

    mAtlasPixmaps.clear();

    // Mark as invalidate
    mSolidAtlasAllocInfo.blockId = mMaxAtlasBlockId;
    mTransparentAtlasAllocInfo.blockId = mMaxAtlasBlockId;
}
コード例 #2
0
//-----------------------------------------------------------------------
void MaterialTab::OnChangeName(wxCommandEvent& event)
{
	wxString newName = mTxtMaterialName->GetValue();
	wxString oldName = mMaterialListBox->GetStringSelection();
	Ogre::String newMaterialName = wx2ogre(newName);
	Ogre::String oldMaterialName = wx2ogre(oldName);
	Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(oldMaterialName);
	if (!material.isNull())
	{
		Ogre::MaterialPtr clonedMaterial = material->clone(newMaterialName);
		if (!clonedMaterial.isNull())
		{
			// Load the new resource, unload the old one, remove it from the list and set the new material as the selected
			clonedMaterial->load();
			Ogre::MaterialManager* materialManager = Ogre::MaterialManager::getSingletonPtr();
			materialManager->remove(oldMaterialName);
			mMaterialListBox->Delete(mMaterialListBox->GetSelection());
			mMaterialListBox->addMaterialName(newName);
			selectMaterial(newName);
		}
	}
}