Monday, October 01, 2007

Generic XNA - Content Pipeline Mod

I have a few examples using custom pipeline code on here, now an issue I get a lot, mainly because I have next to no modeling skills, is when I try to use a new model that has been UV'd I get compile errors because the UV texture that is embedded in the model file is not present or in the right place. So I have to find the texture file reference in the model file and remove it, but some times the models are not plain text so I have to find the physical texture file (or create a dummy) put it in the right place then compile again.

Now I find this a real pain in the back side, I also then have textures in my projects I may not want to use if I cant pull them out of the model file. So I have found a nice simple solution to my problem, override the ConvertMaterial method in the ModelProcessor and just ignore any texture exceptions.

Here is the code to do it

       protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
               return base.ConvertMaterial(material, context);
               return null;

I have not put a code sample up for this as it is pretty simple to do, if you like try it out on one of the pipeline processors here.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.