jack_nexx

Hello

I¡¯m getting stucked in designing a ResourcenManager for XNA GS.

Some basic thoughts :

-         For bigger scenes it is not wise to load just models and manage them, because they hold   Effects and Textures. It would be a better idea to manage Effects and Textures separately, so that you can share them between ModelMeshes. In some cases it would be even better to share ModelMeshes too.

-         To export a model, for example from a model tool to a x-file, you have to handle the material convertion problem (since the time of shaders). Maybe your model tool supports fx shader, but these are mostly not compatible with those in GameEngine and some Materials are just new, some are simpel holder for Materials in a MaterialGameLib.

 

The Problem :

The artist builds a model and wishes to put an already knowing material e.g. ¡°Wood_02¡± on it. This is also present in a MaterialGameLib dir as fx file. So how to get that link

The simplest way : via the name. The material name is exported inside the x-file as : ¡°Material Wood_02 { ...¡±, but where is it inside the XNA GS Framework

Even with the ContentPorcessors (and the fine sample on Shawn Hargreaves side : http://blogs.msdn.com/shawnhar/default.aspx ) I couldn't solve this.

¡®MaterialContent material.Name¡¯ is empty and ¡®EffectContent input.Name¡¯ too. I think this was just forgotten to fill with import.

But even when names are there it would be nice to have them inside the Game Framework too e.g.   ¡®Effect effect.Name¡¯ and of course a ¡®effect.Tag¡¯ would be nice too.

 

Surely, a solution would be to write an own XImporter. That is a huge task just for getting the material names. Maybe if I had the code of the basic XImporter.

 

Some clues,   suggestions

 




Re: XNA Game Studio Express Missing effect.Name and effect.Tag

Shawn Hargreaves - MSFT

You shouldn't need to write your own importer for this - that would indeed be a huge overkill!

In a content processor, if your artist made a file that points at a .FX file, the MaterialContent for that geometry will actually be an instance of the derived EffectMaterialContent class. That has an Effect property which will give you the filename of the effect.

I just got halfway through writing up a proper explanation of how to handle this, but decided it ought to be a blog post instead, so I'll get this cleaned up and posted later today.

You actually do get sharing of textures and effects by default in the system. If multiple meshes reference the same texture or effect, that only gets built once and they all share a single copy of the data. This is what the ExternalReference type is for in the content pipeline: it holds a filename pointing to an object that will only get built once no matter how many other assets reference it.





Re: XNA Game Studio Express Missing effect.Name and effect.Tag

jack_nexx

>You actually do get sharing of textures and effects by default in the system.

Oh, I just don¡¯t knew that. Thank you for that info .

I read you blog post and answer to it there.