I'm working on a custom content pipeline for a scene graph file which contains references to external model files (.x format), and have run into a problem for which I've found no help in documentation or in forums.
When a node referencing a model file is imported, I create an external reference to the model file thus:
ExternalReference<NodeContent> modelReference = new ExternalReference<NodeContent>(modelFile);
Then in the ContentProcessor class for my scene graph, I process all the model references like this:
ExternalReference<ModelContent> builtModel = context.BuildAsset<NodeContent, ModelContent>(modelReference, "");
I would then go on to write out those external references in my scene graph's ContentTypeWriter class.
When I run this through the pipeline, my scene graph file builds OK, but I get the following error message when it tries building a referenced model:
error : Unsupported type. Cannot find a ContentTypeWriter implementation for Microsoft.Xna.Framework.Content.Pipeline.Graphics.NodeContent
I've followed the structure of other working custom content pipelines, and also took careful note that the .X importer returns NodeContent, and the ModelProcessor takes NodeContent input and should produce ModelContent as output. However it seems that what's coming out of the model processor is NodeContent, not ModelContent - or the model processor isn't being run.
I also tried using BuildAndLoadAsset to try embedding the models, but got an exception about trying to cast NodeContent to ModelContent. If I change use of ModelContent to NodeContent in this case, I don't get an exception (and the node hierarchy looks OK, holding NodeContent and MeshContent objects) - however if I then try writing the embedded models via WriteObject<NodeContent> I get the same "unsupported type" error as above.
The test model I've used is a simple untextured, unshaded cube exported from Blender; this shows up fine in the DirectX model viewer, and also builds fine if added directly to my testbed XNA project.
Any advice would be greatly appreciated, and gratefully received!