Matt MacLaurin - MSFT

I have a mesh with a multi/sub material on it.

There are three different sub-materials, each with a different texture.

I export via FBX.

It comes in as a mesh with 3 parts (naturally.)

I want to dynamically replace the texture on ONE of those parts.

I need to be able to find the original name of either the material or the texture from the Max file in order to identify which texture to replace at runtime.

I found a name parameter on the texture, but it is empty (despite being populated in Max.)

Am in in content processor territory here



Re: XNA Game Studio Express access texture NAME for a an FBX-loaded effect

thedo

I think you will need to write a custom processor - something like this (shamelessly robbed from Shawn Hargreaves blog - which any sane XNA developer should check daily ;))

[ContentProcessor]
public class CustomEffectModelProcessor : ModelProcessor
{
protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
{
EffectMaterialContent myMaterial = new EffectMaterialContent();

string effectPath = Path.GetFullPath("MyEffect.fx");

myMaterial.Effect = new ExternalReference<EffectContent>(effectPath);

return base.ConvertMaterial(myMaterial, context);
}
}


Heres the link to the blog entry in question - http://blogs.msdn.com/shawnhar/archive/2006/12/07/rendering-a-model-with-a-custom-effect.aspx

I expect you'll want to modify that quite a bit, but i think all youd need to do would be to change the external reference to your new texture and be away. Of course this will only affect the build stage - so it wont be dynamic. I suppose you could force it to load all the textures and then switch at runtime based on some data in a tag somewhere, but its difficult to say without knowing what resukt youre after

N