Creating terrains using 3D Studio Max
In this tutorial we will learn how to create terrain models for our XNA demos. Terrains are usually created using code while loading, or dynamically while the game is runing. BattleField Bad Company uses an advanced terrain system in which the terrain is modified
during the game because of the explosions that take place. You don't always need such an advanced terrain generation system, and so you can create it first and then load it directly onto the Content of your project. This is precisely what we will see in
First thing that we are going to need is a texture for our terrain. You can either create it yourself or get it on the internet, for this example we are going to use this one:
The next thing we will need is a height map. This map uses black to represent minimum height and white for maximum height. We are going to create this height map using Photoshop.
We start Photoshop and open a new file, 512x512 since our terrrain is going to be square:
Next we paint the background black so that it will all be initially at sea level:
Now we use the paint brush to draw the parts of our terrain that we want to be higher. We should choose an airbrush to that our terrain will be smooth.
I recomend that you make a black margin, so that when you put the camera in the center you will never see the end of the terrain since the mountains will be in our view.
Now that we have the textures that we needes, we can use 3D Studio Max to finish. Lets create a plane in the center of the world. For this we need to go to Create in the menu to the right, and select Geometric, where we will see a button that says Plane.
We click on this button, and while pressing Ctrl we can create a plane.
To make sure that it is in the center, we can right click over the Move button on the upper toolbar, and set all the values to 0.
Now let's go to the Modify tab. Below are the plane's properties, which we are going to modify in order to create more vertex. We modify the length segs and the width segs – here I use 40 for each, but you can change this depending on the terrain's
size and on how smooth you want the terrain to be.
Next we go to the Modifiers list, where we add one to out Displace plane:
Next we apply the heightMap that we created using Photoshop to the Map (Properties).
We adjust the Strength to the height that we want for the white pixels:
Now that we have created out terrain, we just need to give it a texture. We need to open the material editor (the easiest way to do that is by pressing the 'M' key). Any default material, we select Maps and add a texture to the diffuse channel.
To add the texture to the plane we need to follow these steps (first select the plane):
Now we are done! The only thing left to do is to export the model as fbx or whatever format you want to use.
Traslated by Juliet R. Moreiro Bockhop
Created by Javier Cantón Ferrero.
MVP XNA-DirectX 2007/2009