Hi, guys!

Sorry for that probably silly question, but I am somewhat new to the whole XNA stuff. Is it possible to create a tool, i.e. level/map editor with XNA My question is in fact two-fold:

1. Is it possible to load some game content (meshes, textures etc.) through the content pipeline on the fly - from your hard disk and add it to your level All examples i have found so far use only static content added directly to the GSE game project.

2. Is it possible to target XNA rendering output to a windows forms control From what I have seen/tested XNA creates its own window. I have read some threads in this forum from guys who have limited success running XNA inside windows forms, but nothing 100% working, just hacks. Actually I managed to embed the XNA window inside my form by using Win32 API functions like SetParent and MoveWindow, but this is UGLY, I admit. Maybe there is a better/proper way to do it, i dont know.

If you are curious, I plan to write a simple 3D game as a hobby project, that uses 3D tiles for its levels, and I need to create a map editor for it. This map editor should be used outside visual studio express (from users with little or no programming skills at all), to create custom levels for my game. They should be able to add and configure their own tilesets and character models directly from the tool, without the need to mess with Visual Studio and the game project itself.

I'd appreciate any ideas/suggestions on this topic.

Best regards,

Vankata! :-)

Re: XNA Framework xna level/map editor


I'm pretty green in this area too, but here goes...

1. Don't know. I'm not using the content pipeline.

2. Yes. Just render normally and use the overloaded Present(rect, rect, handle) method to display your control. You may need to ensure that the device window is large enough to accomodate your largest control (as all controls render to the same backbuffer), but other than that it appears to be all gravy

Hope this helps.

Re: XNA Framework xna level/map editor


Do you mean it is possible to load textures/models/effects outside the content framework Sorry, I didn't knew. Ok I'll check that...

Re: XNA Framework xna level/map editor

George Clingerman

It is possible to continue to use the Content Pipeline and load addition resources dynamically. You can read this thread for more details. It basically involves using MSBuild to package the resources up for your project.

Mike36 gives the most details on how to accomplish this.

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.

2. In LoadGraphicsContent, change

myModel = content.Load<Model>("Content\\Models\\p1_wedge");


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="">


<Content Include="Content\Models\p1_wedge.fbx">
<Content Include="Content\Textures\wedge_p1_diff_v1.tga">
<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" />

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!

And you can read this thread for getting XNA to work with Forms. It's a fairly straightforward process with no API calls.

Hope that helps answers your questions. Good luck with your level editor!

Re: XNA Framework xna level/map editor


Thanks for the fast replies!

This is really helpful!

Best regards,


Re: XNA Framework xna level/map editor


Another puzzle piece - blog on how to do this for level editors, that I just happened to see today right before reading this post: