Dupe material names

Evak

13-06-2006 00:30:02

Hi. I have the need to load multiple OSM files that sometimes share the same materials. With ofusion this causes a conflict between duplicate materials and crashes ogre.

If I export 2 OSM's say I have seperate levels in a game with different materials, if they use the same default material names these will conflict so ogre is unable to start.

Is there anything that can be done to overcome this problem?

One way might be to have ofusion to save your OSM and have the OSM's name automaticly added to the beginning of the materials exported with it

If you export hall.OSM and it has a "16 - Default" as a material name it would be renamed hall_default

Lioric

13-06-2006 01:50:48

In the test version with advanced features you have, you can use the "Resource Locations" support (in the Export dialog) to create a scene with a specific sub folder structure, for example if you export your scene to the "Media\hall" folder, you can configure the resource locations to produce this results:


\Media\hall\scene.osm
\Media\hall\meshes\object1.mesh, object2.mesh, ..., objectN.mesh
\Media\hall\materials\scene.materials, object1.material, ... fileN.material
\Media\hall\images\texture1.jpg, hallTexture.png, ..., imageN.jpg
\Media\hall\shaders\shader1.source, shader1.program, ..., shaderN


(you need to activate the "Auto Copy" option for textures if you want the textures to be in the selected sub folder)

With this you can even use the same name for all your scene files, and use the parent directory as the name of the level (useful on moddable engines), i.e


String sceneName = "hall"; // User selected or hard coded in the game
sceneName += "\\scene.osm";

sceneLoader.load(sceneName);


The scene loader will detect the sub folder locations and will auto register them (and load the media files)
When you want to load a different scene, you can unload the scene (this will auto unload the registered locations) and then load the new scene, so its own location will be auto registered

In this case you just need to register the "\Media" folder with your game (i.e. in the resources.cfg file) and the levels can have the same names

If you want to load several scenes at the same time, then your suggestion is good, i will review this and add its support if proves to be useful (i.e. its better than just use a material renamer tool)

ChrisC

13-06-2006 02:23:48

you dont even need to load *any* OSM files for this problem to prevent Ogre from even starting, you can have more than 1 material with the same name

This means if I want to provide 2 or three demos.exe that use between them use 2 or more OSM files, I have to be extremely careful to not allow oFusion to name any oth the materials for me.

This stops Ogre dead in its tracks, while parsing the material files, its a right pain!

Vectrex

13-06-2006 08:17:47

yeah it bugs me too to be honest. Isn't this what the resourcegroups is for though?
In the above example it's not ideal, for instance a user made level would use all the same textures/materials and meshes so I'd probably have a core resourcegroup that all levels have access too, then have the seperate folders so user levels don't conflict.. would work you think?

ChrisC

13-06-2006 08:38:07

I'd rather that by default oFusion wouldnt stop ogre dead in its tracks!! ;)

but resource groups are an interesting idea...

Evak

13-06-2006 20:22:51

some things in my current projects where multiple OSM files in the same scene are useful are.

Aerial Antics VR. we reuse the locales across multiple levels, but use a collection of instanced OSM gameplay items. Reason for OSM is that these items are instanced around the level many times and use helper nodes in order to function properly in the game.

Lokblox, uses patented sort of lego type bricks, they need to be saved as OSM files in order to keep the helper nodes with their local rotations intact, so that in the editor object snaps and block alignment is possible.

Another thing we do is build levels in two stages, visuals and gameplay.

So we have one OSM that contains level visuals, and ambient anim etc, and a second that contains all the collisions, and all the gameplay related objects that are exported from max. Different lighting and sky backdrops etc that we swap and share between levels.