KentDub: wrote a custom importer which allows me to keep my original Maya files in the project solution (huge plus -- I get source control now, automatic triangulation, plus I don't have to worry about exporting files anymore).
That is just awesomely cool!
KentDub:From how it seems, and I can be completely wrong here, is that the real role of a Content Importer is to extract all information from the source asset and put it into ContentNodes (and various subclasses). Then it would seem that the Content Processor (which it should be obvious I haven't written one yet) picks and chooses that information it is given from the Content Importer and serializes it into the run-time format.
Exactly right. The role of the importer is to pull data from the source tool into a standard, normalized format, so it removes any quirks that are specific to the source tool. Then the processor turns this normalized data model into whatever more specialized format the runtime game engine requires.
One way to think of this:
- Importer = specific to source modelling tool or file format
- Processor = specific to game engine
The benefit of separating the two is that as long as everyone uses the same content object model (NodeContent etc) in between them, this can make the same importer able to be used with many different game engines (for instance our Custom Model Class sample is able to use the same FbxImporter as our built-in Model class), and also the same game engine can be used with many different importers (for instance many of our samples use a mixture of both .X and FBX format models, but their processors don't need to care which format the input data came from).
Of course, this is just a principle, and you don't have to follow it. If you wanted, you could do all the work in the importer, have it output a game-ready object, and not need a processor at all. Or your importer could be a no-op that just returned the filename string it was given, and then you could have a processor that did all the work of reading the contents of that file. Either of those designs loses the benefit of being able to mix and match different importers and processors, but that's ok if you don't care about mixing and matching.
KentDub:If I am correct on that assessment, I have a lot of refactoring to do. How accurate is a Content Importer supposed to represent the data? Should I try to create a 1-1 mapping between a Maya Node and a ContentNode, if appropriate? As it is right now - I am "Flattening" the tree so all of my models are direct children of the root ContentNode. Should I be leaving all of the extra nodes in there and let the Content Processor decide how it wants to structure it?
Our FBX and X importers preserve the node tree from the input model, but this is really up to you. Preserving the hierarchy is useful if you want to do hierarchical things with the data, especially animation where you may have jointed objects parented off of other jointed objects.
KentDub:As far as structuring the tree of ContentNodes - I have yet another question. I found on another post that BoneContent should be a direct child of the MeshContent using it. What happens if you have multiple MeshContents using the same skeleton - do I duplicate the skeleton and animation data - one for each MeshContent?
You should typically have something like:
- NodeContent (scene root)
|-- MeshContent (first model)
|-- MeshContent (second model)
|-- MeshContent (third model)
|-- BoneContent (skeleton root)
|-- BoneContent (head bone)
|-- BoneContent (left arm)
|-- BoneContent (left wrist)
etc.
XNA Framework Developer -
blog -
homepage