Sign in to follow this  
MartinLoga

custom ModelProcessor and Runtime ContentBuilder

Recommended Posts

Hi,

I made myself a console tool for converting various content to the xnb format. The whole thing bases on this [url="http://create.msdn.com/en-US/education/catalog/sample/winforms_series_2"]Content Loading Example[/url]. Now I want to add a custom model processor to the pipeline. From my understanding the content loading example generates a project on the fly and builds it. So from my point of view it looks like I have to reference to my custom model processor project (I tried it with projectRootElement.AddImport("SceneryViewerModelProcessor.csproj");) und build it all together. Best I got so far is a huge pile of error messages wich look like compiler errors.

A namespace cannot directly contain members such as fields or methods
..removed some...
A namespace cannot directly contain members such as fields or methods
Preprocessor directives must appear as the first non-whitespace character on a line
Unrecognized escape sequence
..removed some...
A namespace cannot directly contain members such as fields or methods
; expected
Invalid token ';' in class, struct, or interface member declaration
; expected
..removed some...
Unrecognized escape sequence
A namespace cannot directly contain members such as fields or methods
Unrecognized escape sequence
..removed some...
Unrecognized escape sequence
A namespace cannot directly contain members such as fields or methods
Unrecognized escape sequence
..removed some...
Unrecognized escape sequence
A namespace cannot directly contain members such as fields or methods
.... and so on .....

So first of all my question is. Is this the right way doing this? Am I heading at least the right direction?

Greetings

Maddin

Share this post


Link to post
Share on other sites
Take a look at the "ContentBuilder.cs" source file as that is where the assembly definitions are (pipelineAssemblies). Here is a comment on how to add your custom pipeline assembly to it:

// If you want to use custom importers or processors from
// a Content Pipeline Extension Library, add them here.
//
// If your extension DLL is installed in the GAC, you should refer to it by assembly
// name, eg. "MyPipelineExtension, Version=1.0.0.0, PublicKeyToken=1234567812345678".
//
// If the extension DLL is not in the GAC, you should refer to it by
// file path, eg. "c:/MyProject/bin/MyPipelineExtension.dll".

Then when you actually build/load your content you will need to specify your custom importer and processor.
contentBuilder.Add(fileName, "Asset Name", "Custom Importer", "Custom Processor");

Share this post


Link to post
Share on other sites
My bad I removed the comment for better readability :-/

Thanks for this hint. But it does not yet work.

I used the "DLL not in GAC" variant like that
[code] 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,
"MyModelProcessor.dll"
};[/code]

But when I later use it with the ContentBuilder.Add(fileName, name, null, "MyModelProcessor"); it throws an exception that he does not know the name MyModelProcessor which is the name of the class and namespace in the dll. Any Idea?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this