سؤال

XNA is the bee's knees but I still can't wrap my head completely around custom content pipelines.

Some basic samples like MSDN's normal map sample shows you how to assign normal map keys from opaque data from an .fbx file to the appropriate normal map textures to load. I don't even know how they knew what the key should be named, what opaque data actually is, if it's defined in the .fbx file or not.

The interesting thing is that there's no code in the content pipeline that says how diffuse textures are set- it seems to imply that you use a shade parameter named "Texture" and they get set automatically. But if I rename the parameter to something else, the models load with no textures.

How does it implicitly know to load diffuse textures, and how can I, for example, load diffuse textures to be read with differently named shader parameter and load a default neutral-white texture file if one doesn't exist?

For that matter, is there a "hello world" example for learning to custom load models with the content pipeline?

Note, that I am not looking to override existing texture references in the .fbx models by setting a texture in the properties window.

هل كانت مفيدة؟

المحلول

The first thing to understand is that XNA allows two separate custom content pipeline items to be created: one is an importer and the other is a processor.

When you write an importer, you parse any file how you want to and store the information you want into any class (object) that you specify. You can write the class yourself OR use certain classes within XNA. In this fashion you can simply write an importer that takes data from your file and, using the built-in ModelProcessor, makes that into an XNA Model class object.

Here is a sample of a custom model importer:

http://create.msdn.com/en-US/education/catalog/sample/custom_model_importer

If you need some other object than a Model, write a custom processor:

A processor takes the class object specified by the importer and converts this to yet another class (since you're writing it, any class and in any way you specify). This class gets used to generate a .xnb file (XNA binary), which is read at runtime by your game. All of this, therefore, is only run during compile time, in an effort to give you better control of your game's contents.

This is a good link to get started:

http://msdn.microsoft.com/en-us/library/bb447754(v=xnagamestudio.20).aspx

For your case it sounds like you are unhappy with the behavior of the default FBX importer. If this is the case, you would most likely have to write your own. You most likely do not need to write your own processor though; specify ModelProcessor as the default, just as the project in my first link has done.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top