This project is read-only.

Part 2 Including your Content

1. You have completed part 1 and have some map content
2. You have downloaded all the extra files including: (the shader file, map reader, and game Heightmap Game Component)
3. You understand a little about Xna and can create your own camera class.
4. The camera can be very basic and should be accessible to other classes. (make it static or use public properties in your game class which provide access)

1. Start a new project named whatever you want it named as.
  • Create a new Xna Game v3.1

2. Now lets add some References.
  • Under both the Windows game project and Content Projects you should see a references icon.
  • For both projects, doing one at a time, right click on the icon and select add reference and hit the browse tab.
  • Navigate to the folder you extracted earlier named xnaSimpleMapEditor and then follow: (MultiHeightMapProcessor3\MultiHeightMapProcessor\bin\x86\debug\)
  • Select MultiHeightMapProcessor.dll. (Remember do this for both references.)

3. Now we need one more reference this time just for the game project.
  • right click references and add this time stay under the .Net tab
  • Scroll Down to the item: (Microsoft.Xna.Framework.Content.Pipeline) v3.1
  • Make sure the version is correct.

4. Now we are going to add the classes you downloaded earlier.
  • Find the icon of your main project, (default: windowsgame1), and right click select add then select existing item...
  • Find the 2 classes you downloaded earlier: (Map_Reader.cs , and MultiHeightMapObject.cs)
  • Add them both

5. Now this is tough part. (You should have errors in the MultiHeightMapObject class by now.)
  • Go to the class MultiHeightMapObject
  • Scroll down to the last method public override void Draw(GameTime gameTime).
  • Follow the instructions there to fix the problems
  • All you are doing is replacing my camera code with yours
  • The important thing is that the FMO.DrawTerrain() method is fixed, so if your camera is static you wont even need the top line.

6. Now adding the Content.
  • Right click on the Content project icon and select add Existing item.
  • Find the shader that you should have downloaded and add it. (Series4Effects.fx)
  • Now right click on the content project again and select create new folder.
  • Name the folder EXACTLY, (case sensitive), the same as your map contents folder. (aka. the name of the map you made in the last tutorial.)
  • Now save your project if you haven't already.
  • Using windows explorer navigate to your project's directory and find the folder you just made.
  • Now cut/copy everything, (folders and files) from your saved map content into the new folder in your project.
  • You should now have the folder in your project filled with the map data.
  • Close out explorer and return to your c# project
  • Right click on the folder you created in your c# project under the content project and select add existing item.
  • Navigate to the same folder you just added all your map content to and make sure the bottom filter is set to ALL FILES.
  • Select and Open the script file (The file with the map's name and .mhf extension).

7. Now adding some code.
  • Find and open your game class
  • In the constructor method probably named: public Game1() , add this code after the already existing code.
    • MultiHeightMapObject MultiMap = new MultiHeightMapObject(this.game1, "levelnamehere", "Series4Effects");
    • game1.Components.Add(MultiMap);
    • levelnamehere is the name of your map file (.mhf) which is the same as the folder its in and the script used to create it.
  • Now if you have not done so already add the code you need to make your camera move.
For example in the method: protected override void Update(GameTime gameTime)
I would put something like this:

if (Keyboard.GetState().IsKeyDown(Keys.Up))
camera.movementVector.Z = - 1;
and so on for each direction. (It really depends how you set your camera up.)

8. You should finally be done and you can now run your project to see your map.
  • The FinalMapObject class has many more features functions and variables than are used here in this demo app.

  • Things for developers to expand upon would be:
  • Use of the lighting variables to effect other objects as well.
  • Make a checkpoint manager that handles how checkpoints are passed and processed (My team made a good one, but it was very racing game specific.)
  • Use quad tree rendering of terrain or some other efficiency algorithm to improve performance at render time. (I simply did not have the time.)
  • Improve how I process my map data. Perhaps move away from triangle lists to something more efficient.
  • Add more parameters to the map maker and processor. (You will have to edit both the map maker and content processor as well.) (the source for both is included.)

Dev Tips
  1. Remember the code for how the map is rendered is in the content processor, so you have to change it there and rebuild. (This makes debugging errors ridiculous).
  2. Don't forget the texture names have to be declared in the content processor and given friction values (You can get rid of this if you want).
  3. Feel free to use/edit my texture builder. It can be modified to build other things like models and many other content, but seems to only work on Windows XP.

Last edited Aug 23, 2010 at 8:57 PM by T3866, version 10


No comments yet.