# Extending ModelProcessor

How can one extend a model processor inside Windows Forms. In a normal XNA game you would simply create a new class like so(I think...):

[ContentProcessor]
public class ExtendedModelProcessor : ModelProcessor
{
protected override ModelContent Process(NodeContent input,
ContentProcessorContext context)
{
ModelContent m = base.Process(input,context)
//my own code
}
}


How can I duplicate this inside Windows Forms project, I am working on a project from microsoft site, "WinFormsContentLoading sample". I tried creating a class like above, but didnt work, then I tried to change the processor on contentBuilder.Add(...,"ExtendedModelProcessor"). And I also tried creating a new .dll ContentExtensionLibrary and then adding it inside ContentBuilder class, under:

static string[] pipelineAssemblies =
{
"Microsoft.Xna.Framework.Content.Pipeline.FBXImporter" + xnaVersion,
"Microsoft.Xna.Framework.Content.Pipeline.XImporter" + xnaVersion,
"Microsoft.Xna.Framework.Content.Pipeline.TextureImporter" + xnaVersion,
"Microsoft.Xna.Framework.Content.Pipeline.EffectImporter" + xnaVersion,
Application.StartupPath + "\\myDll.dll"
};


And adding the .dll to the same folder as the program. But nothing worked. How can I create an extension for ModelProcessor inside Windows Forms?

Thanks

• Anyone........? – user1806687 Feb 21 '13 at 17:24

Everything you have done so far seems correct. You just need the last step, which is to change the content builder configuration so that it actually uses your processor to build the model.

So open up MainForm.cs (right click it and select "View Code") and scroll down to line 100 (in the original sample). Then change this:

contentBuilder.Add(fileName, "Model", null, "ModelProcessor");


To match the name of your content processor, like this:

contentBuilder.Add(fileName, "Model", null, "ExtendedModelProcessor");


If you get an error message that says:

Cannot find content processor "ExtendedModelProcessor".

Then you need to fix up the path you specify in pipelineAssemblies (in ContentBuilder.cs) that points to your DLL. Any other error probably means that there's something wrong with your processor itself.

I notice you were trying to do this without creating a DLL at first. You can certainly do that, if you like. You can use your EXE in place of a DLL (they are both assemblies). But you still need to specify its path in the pipelineAssemblies array.