Level: Beginners and up
Table of contents
This is going to be a series of 3D Studio Max tutorials for Beginners and Intermediate Users. It's aim is to give artists the ability to use their modeling package to successfully aid their programmers in creating appealing and working game or research environments. Since I'm trying very hard to explain every step I take in detail, programmers as well as artists may find this tutorial useful as a step-by-step guide to creating content. Intermediate users may find the first issues of the series a bit tedious, because I explain everything. Bear with me. I only expect users of this Tutorial to be able to navigate in Max. I hope you will learn all the other small things as we go along. Here's a quick rundown of the major navigation hotkeys:
- pan: middle mouse button
- rotate: alt + mmb
- zoom: mouse wheel
- enlarge selected viewport: alt + w
While I am using Max version 7 for these Tutorials, I don't think you should run into any major problems with other Max Versions. Some of the tricks might even be applicable to Maya and other applications.
The first Tutorial will deal with one of the most basic and yet tricky uses of a modelling application: Generating Terrain. It's also the first step on the ladder of creating a basic environment for Ogre.
First of all, let's look at the advantages of creating your terrain in a 3D environment, compared to painting everything by hand. The major issues of painting a greyscale heightmap by hand are obvious: you don't immediately know what the outcome will look like. You don't get instant feedback on what you're doing. You have to let your imagination do the math. The next thing is that if you have your map available in 3D you can use it to go on generating a texture map, a shadow map and any additional maps your heart (or client) may desire.
With that out of the way, let's start modeling!
We'll start out by creating a simple plane from the creation panel. Just drag it out to a random size in the top viewport.
Since we'll use this plane to generate maps for a Terrain, we'll want it to be rectangular. After you created the plane make sure your settings about match mine:
If you accidentally right-clicked before changing the settings, you can easily access the "Parameters" rollout from the "modify" tab, right next to the "create" tab.
The segments can be any number, really. The more you use, the finer and more detailed the map will turn out to be, but it'll also strain your workstation. On my PC, 64 is a good trade-off between performance and quality. For this tutorial it should be enough.
Now right click on your newly created plane and convert it to an editable poly.
That will enable us to use a nice tool called "soft selection". First make sure the plane is selected, then press the "1" key on your keyboard to go into Vertex sub-object mode (the three red dots to the very left of the "selection" rollout). Now expand the "Soft Selection" rollout and check "use Soft Selection".
Press "w" on your keyboard to switch to your move tool and create a small mountain in the right corner of your Terrain by pressing and holding the left mouse button on the desired location and then moving the mouse up.
To create valleys just move the mouse down. Create a small lake to the left of your mountain.
Now, let's take a look at all the options we have with soft selection. First of all, you will obviously want to create more than just mountains and lakes. Maybe a hill in the top corner of the Plane would be nice. In the Soft Selections Rollout change Falloff to "9,0" and repeat what you did with the mountain. Notice that the area you're affecting is much smaller this time.
So what if you wanted to create a river for the lake now? For that we'll use the "paint selection" option. First click "paint" in the "Soft Selection" rollout. If for some reason it reselects your small hill, then just uncheck "lock soft selection" and try again. Select an appropriate brush size and start painting a small river that runs into our lake.
Let go of the mouse button and see that the selection stays active. If you made a mistake, you can can use "Revert" like you would use an eraser in a painting application. Now just grab the blue "Z-Axis" of the movement Gizmo and drag it down some, like you did earlier with the lake. To deselect, just uncheck the "Lock soft selection" box.
You can play a bit with the Soft selection options at a later time. For now this terrain will serve our purpose well enough.
We now need to apply a "Unwrap UVW" modifier from the modifier dropdown menu. Go to the "Modify" Tab and apply one. Make sure your plane is selected and press "1" on your keyboard to go into "select face" mode. The "Unwrap UVW" Modifier should get highlighted yellow.
## What does this terminology mean? What's UVW, what's a UVMap? Why do we need to do this? Can we get explanations here? [[User:Jekteir|Jekteir]] 18:53, 16 April 2007 (BST)
In your top viewport, drag out a large selection box and select the whole plane. Now select "X" or "Y" (doesn't really matter which one of the two, for our purpose) under "Sub Object Params" and click "planar Map".
## Why doesn't it matter whether X or Y is selected: what is our purpose? [[User:Jekteir|Jekteir]] 18:53, 16 April 2007 (BST)
Next open up our newly created UVMap by clicking "Edit". There is our plane, mapped straight from the side.
In order for this to work, you need to scale the plane to match the rectangular UVmap (you can see the borders are thicker and slightly darker than the rest of the grid). To do that grab one of the cornerpoints and drag the plane. To limit scaling to one axis, you can hold down shift. Your new map should look something like this:
## If we're building this map thingy based on the plane itself, why isn't it already on the same scale? [[User:Jekteir|Jekteir]] 18:53, 16 April 2007 (BST)
Now open up your Material editor:
and click the as-yet-unmarked button next to the grey "Diffuse" color:
From the list that pops up select "Gradient" and confirm. You are back to the material editor and you can now change the parameters of your gradient. Edit the colors so White is the topmost color, and Black is the downmost color, as seen in here:
Once you've set that up, click the small "Go to Parent" button to leave your "Gradient" options and go back to the General Material Options.
In the Basic Parameters, find the small "Self-Illumination" parameters and take it up all the way to 100. This will ensure that our plane isn't affected by any additional lighting, that might impact the heightmap we want to generate.
Drag and drop the Material from the Editor on your plane. It should turn totally white.
So what did we just do?
Good Question. I'll try to explain. I assume you all know how heightmaps work.
## Can we hear what we're doing as we do it, not later when we're not sure what you're referring to? No, I don't know how heightmaps work, that's why I'm reading the number 1 beginners' tutorial! [[User:Jekteir|Jekteir]] 18:53, 16 April 2007 (BST)
They are used to tell Ogre how high or low the Terrain is supposed to be at any given position. White means high ground, Black means low ground. If you click on "show Map in Viewport" in the Material Editor You may get an idea of where we're going with this.
## So you're saying Ogre interprets the pixel color of each segment of a plane in grayscale as a measurement of depth? And presumably this limits height to a certain level of accuracy (256 steps, or whatever)? Does this eventually become a .map object or something? [[User:Jekteir|Jekteir]] 18:53, 16 April 2007 (BST)
What we just did: We applied a Gradient material to the plane, projected on it straight from the Side. This will ensure that the topmost parts of our plane will receive a whiter material and vice versa for the lower parts.
Now all that is left to do is render our plane while the upper viewport is active. Just position the plane so you get a good view on it in the "top" viewport, then press "F9" to render. Tada!
Hit the Printscreen button for a lossless shot you can cut in your imaging-software of choice, or click the "save as" button and save the render. In both cases you'll still need to cut it up and resize it nicely. This last part should be applicable to all 3D packages that support unwrapping and Gradients.
## And what do we do with this top-down image to make it usable in an Ogre-based program? [[User:Jekteir|Jekteir]] 18:53, 16 April 2007 (BST)
Note: A Heightmaps resolution should always be a power of 2 (e.g. 256 is 2^8) plus 1, and the same length on both sides (i.e. 257 x 257). They also have to be saved in a greyscale format.
Next up: Generating a Texture for your Terrain.
## Does that tutorial exist? I know I'm a whiny beggar, but I need help with this stuff! Thanks. [[User:Jekteir|Jekteir]] 18:53, 16 April 2007 (BST)