OgreXMLConverter has Error: Material with the name <materialName> already exists

Problems building or running the engine, queries about how to use features etc.
ryandeboer
Halfling
Posts: 87
Joined: Thu Oct 05, 2006 6:19 am
Location: Perth, Australia

OgreXMLConverter has Error: Material with the name <materialName> already exists

Post by ryandeboer »

Ogre Version: OgreXMLConverter Tsathoggua (14.4.0)
Operating System: Windows 11
Render System: n/a

Code: Select all

D:\dev\git\ogre-meshviewer\newmat>D:\dev\git\ogre_build\bin\release\OgreXMLConverter.exe ninja2.mesh.xml

-- OPTIONS --
source file      = ninja2.mesh.xml
destination file = ninja2.mesh
log file         = OgreXMLConverter.log
-- END OPTIONS --

XMLMeshSerializer reading mesh data from ninja2.mesh.xml...
Reading submeshes...
Reading geometry...
Geometry done...
Reading bone assignments...
Bone assignments done.
*-*-* OGRE Shutdown
Unregistering ResourceManager for type Compositor
Unregistering ResourceManager for type Material
Unregistering ResourceManager for type GpuProgram
Unregistering ResourceManager for type Skeleton
Unregistering ResourceManager for type Mesh
Error: Material with the name Examples/Ninja already exists.

I can't convert a mesh xml that has multiple submeshes with the same material. Even the standard ninja model can convert to xml but can't be converted back because it has submeshes with the same material. If I give submeshes a different material it works. If a mesh has submeshes with the same material how do I convert an xml back to it?

ryandeboer
Halfling
Posts: 87
Joined: Thu Oct 05, 2006 6:19 am
Location: Perth, Australia

Re: OgreXMLConverter has Error: Material with the name <materialName> already exists

Post by ryandeboer »

Found a workaround, commented out this code in OgreResourceManager.cpp:

Code: Select all

        //if (!result.second)
        //{
        //    OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM, getResourceType()+" with the name " + res->getName() +
        //        " already exists.", "ResourceManager::add");
        //}

Now I can convert the ninja xml to mesh.

I also had this problem when trying to build debug:

Code: Select all

pugixml.lib(pugixml.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj

I fixed it by recompiling pugixml dependency (https://pugixml.org/) in debug mode and replacing the file in the Dependencies\lib dir. Would be good if the dependencies supported both debug and release.

I'll leave this issue open, because workarounds aren't the best way of solving the problems.

paroj
OGRE Team Member
OGRE Team Member
Posts: 2151
Joined: Sun Mar 30, 2014 2:51 pm
x 1156

Re: OgreXMLConverter has Error: Material with the name <materialName> already exists

Post by paroj »

ryandeboer wrote: Fri Mar 28, 2025 11:32 am

Found a workaround, commented out this code in OgreResourceManager.cpp:

Code: Select all

        //if (!result.second)
        //{
        //    OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM, getResourceType()+" with the name " + res->getName() +
        //        " already exists.", "ResourceManager::add");
        //}

Now I can convert the ninja xml to mesh.

this is the proper fix:
https://github.com/OGRECave/ogre/pull/3305

that bug must have been there for 6 years without anyone bumping into it..