I've done some
preliminary tests with using MSBuild.exe (mine is located on
C:\Windows\Microsoft.NET\Framework\v2.0.50727) and I'm able to do
dynamic model loading at runtime. Here are some steps to try:
1. Do the steps outlined in Tutorial 1: Displaying a 3D Model On The Screen.
myModel = content.Load<Model>("Content\\Models\\MyModel");
Note that you can replace "Content\\Models\\MyModel" with a string variable to simulate a name you got from somewhere.
3. Make a copy of the Content folder
you created in the project in Step 1. Place this copy in a new project
directory, Test, that you create.
4. Use the following sample project file and place it into the Test project directory:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<XnaFrameworkVersion>v1.0</XnaFrameworkVersion>
<XnaPlatform>Windows</XnaPlatform>
<XNAGlobalContentPipelineAssemblies>Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll;Microsoft.Xna.Framework.Content.Pipel
ine.FBXImporter.dll;Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll;Microsoft.Xna.Framework.Content.Pipeline.XImporter.d
ll</XNAGlobalContentPipelineAssemblies>
<XNAProjectContentPipelineAssemblies>
</XNAProjectContentPipelineAssemblies>
</PropertyGroup>
<ItemGroup>
<Content Include="Content\Models\p1_wedge.fbx">
<XNAUseContentPipeline>true</XNAUseContentPipeline>
<Importer>FbxImporter</Importer>
<Processor>ModelProcessor</Processor>
<Name>MyModel</Name>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="Content\Textures\wedge_p1_diff_v1.tga">
<XNAUseContentPipeline>true</XNAUseContentPipeline>
<Importer>TextureImporter</Importer>
<Processor>SpriteTextureProcessor</Processor>
<Name>MyTexture</Name>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA\Game Studio
Express\v1.0\Microsoft.Xna.ContentPipeline.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA\Game Studio Express\v1.0\Microsoft.Xna.Common.targets" />
</Project>
5. Open a Command window and navigate
to your directory with MSBuild.exe (mine is located on
C:\Windows\Microsoft.NET\Framework\v2.0.50727).
6. Type "MSBuild <project
directory>Test.csproj" without the quotes, where <project
directory> is the place you put your files. Example: MSBuild
C:\Projects\Test\Test.csproj. You'll get a build error, but your
content will be compiled.
7. Copy the files from your Test
directory's Bin\Debug\Content\Models and Bin\Debug\Content\Textures
directories to the corresponding project directories you created in
Step 1.
8. Run your project in Step 1 to see the model!
Since MSBuild.exe is built-into the
.NET Framework, an editor can generate a project file similar to the
one in step 4 above, compile the models specified by the user, and then
copy the results to a game's content directory. A game written to
dynamically load content files would then have models and textures in
the proper format. Not a bad way to go!