XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

Problem building externally referenced model files from a master scene graph file

Last post 4/2/2007 11:47 AM by Shawn Hargreaves. 2 replies.
  • 3/31/2007 6:30 PM

    Problem building externally referenced model files from a master scene graph file

    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!

  • 4/1/2007 7:31 AM In reply to

    Re: Problem building externally referenced model files from a master scene graph file

    Answer
    Reply Quote

    Solved my own problem - I needed to pass "ModelProcessor" to the BuildAssets call. I had assumed that an empty string would mean automatic selection of the model processor based on file extension, but that obviously isn't the case.

    I based my assumption on the XNA documentation which specifies that the processor name is optional, and on this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1068422&SiteId=1.

     

  • 4/2/2007 11:47 AM In reply to

    Re: Problem building externally referenced model files from a master scene graph file

    Answer
    Reply Quote

    A null processor name is interpreted as "don't do any processing", not "autodetect the processor". This is different from the importer selection, which is autodetected based on the extension, for a couple of reasons:

    • It would make no sense to have a no-op importer, but sometimes you just want your data to be passed through without any custom processor.
    • There is typically only one importer per file type, so this can reliably be detected from the extension, but there are usually many processors that can apply to the same type of file, so it would usually be ambiguous which one to pick.
    XNA Framework Developer - blog - homepage
Page 1 of 1 (3 items) Previous Next