What is the best method for getting a list of material names

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
snipexv
Halfling
Posts: 66
Joined: Thu Jan 27, 2005 3:20 pm

What is the best method for getting a list of material names

Post by snipexv »

Hi!
What is the best , or is there a, method for getting a list of all of the materials loaded into ogre. I tried using :
Ogre::MaterialManager::getSingleton().getResourceIterator().getNext()->getName();. But this returns "DefualtSettings." Any help would be appreciated.
Thanks,
snipexv
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

No, that's the best way to do it. There happens to be a material called 'DefaultSettings' which is what all materials get initialised with. Keep iterating and you'll find all the other materials right there.
nfz
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 1263
Joined: Wed Sep 24, 2003 4:00 pm
Location: Halifax, Nova Scotia, Canada

Post by nfz »

here is an example:

Code: Select all

  Ogre::ResourceManager::ResourceMapIterator materialIterator =
    Ogre::MaterialManager::getSingleton().getResourceIterator();

  while (materialIterator.hasMoreElements())
  {
      cbobox->addItem(nfz::createListItem( static_cast<Ogre::MaterialPtr>
        (materialIterator.peekNextValue())->getName(), 0));

      materialIterator.moveNext();
  }
Last edited by nfz on Sun Jul 10, 2005 11:15 pm, edited 1 time in total.
User avatar
snipexv
Halfling
Posts: 66
Joined: Thu Jan 27, 2005 3:20 pm

Post by snipexv »

Thanks!
Post Reply