This tutorial is a basic introduction to using the GtkRadiant level editor. We will cover basic editor functions, basic level construction, and compiling and executing maps.
To get started, go to http://www.qeradiant.com and click the "Download Selector" link. Select "Stable" and "Quake2" from the options given. The site should then give you a download link for GtkRadiant 1.4.0 Classic, which is the most stable version of Radiant that is compatible with Quake2. (Note: QERadiant is a different, older tool that's hosted on the same site. It's not what you want.) The download link should give you an installer executable.
Its okay to click next > next > next through this installer, but if you didn't install Quake2 to the default directory (C:\Quake2\), now is your only chance to change Radiant's Quake2 path to your personal install directory (for example, C:\Program Files\Quake2\). If Radiant is pointing to the wrong place, you will be unable to load any textures or test your map in any way. You will be able to open the editor, but all of its functionality as a mapping tool will be removed. You also might want to uncheck the Heretic2 and Half-Life boxes in the custom install tab. If you are mapping for Quake2 you have no need of the media associated with those games, and leaving support in the editor could lead to confusion down the road.
The first time you launch Radiant, it will ask you what game you want to map for. Select Quake2 from the drop-down menu. (If you didn’t install Halflife and Heretic support, it should be your only option.) It will now make a new empty map and display the toolbars on the screen. Unlike other programs, Radiant can never "close" maps. Only one map can be open in an instance of the program, and each instance of the program always has a map open. This isn't nearly as limiting as it sounds, because you can spawn multiple instances of the editor merely by executing it again.
To see if everything is configured properly, click the "Textures" menu. There should be a list of entries ranging from e1u1 to e3u3. These each represent different texture sets that come with Quake2. If your install path is correct, choosing one of these options from the menu will load a number of images in the bottom right hand panel of the editor. If your install is not configured correctly, you will only see "radiant" at the bottom of the Textures menu. If this is the case, I recommend reinstalling the editor and double-checking your paths. As obnoxious as this process sounds, it is the only way to successfully load the textures.
The reason behind the need for reinstalling is the method that Quake2 uses to store texture information. When you execute Quake2, it opens up the various compressed .pak files in its Quake2/baseq2/ directory and loads all information relating to the game out of those files. The textures that cover the walls in the game are all stored in virtual directories inside the .pak files. Radiant and the compiling tools cannot read .pak files. In order to texture the walls in the editor, the image files have to be stored in the Quake2/baseq2/textures/ directory in an uncompressed format. The installer process deposits all the images in an uncompressed format, something that editing a path at a later date would not do. Therefore, if you pick the wrong path to Quake2, your only option is to start over.
This directory is also where you would put any sort of custom textures you would want to use. Merely depositing texture files into a subdirectory of Quake2/baseq2/textures/ will make them load in Radiant.
Assuming that we've had success loading the default textures, we can start using Radiant to map.
To get started, I'll first go over the basic layout of the editor. The left half of the screen is dominated by a large grid that represents an XY (top-down) view of the map. The very far left has a narrow vertical bar that represents the Z-axis. The upper right side is a 3D camera view, and the lower right side contains the textures that are loaded for use. Right now, the camera will be a blank grey screen, the grid will be empty, and there will be random textures from planet Strogg, depending on which texture set you clicked in the menu.
If this basic layout offends you (say, for example, you are a WorldCraft fiend), choosing "Preferences" under the "Edit" menu will allow you to change the layout. However, I strongly recommend using the default interface unless you already have experience using other view modes. It is by far the most efficient use of screen space, and the rest of this tutorial will be written assuming that you are using it.
To begin creating your map, just click and start dragging in the XY view. Every time that you drag your mouse across this area, you will create a new brush if you have nothing selected (the deselect key is escape.) As you have nothing in your map yet that could possibly be selected, this first click will create a brush.
Now that you have created a brush, a red dotted line will appear in the XY view that represents the active selection. You can change its x and y size by clicking and dragging outside of the red line (this will stretch the brush) or change its x and y position by clicking and dragging inside the dotted line. You should see a red checkered surface appear in the bottom of the camera view as you play around.
If you want to change the height of the brush, you can perform the same operations in the Z bar (the narrow vertical bar on the very left of the screen.) For the purposes of testing, I would recommend making this brush about 256 units wide in both the x and y directions, 192 units tall, and centered on the origin. The location of the origin doesn’t actually affect your map, but all positional values for brushes are stored relative to that point, so the closer the center of your map is to the origin, the less data is being stored.
Note that your camera is probably inside your brush at this point, which means that it won't be seeing anything at all. The camera only draws the FRONT surfaces of a brush. All brushes are a convex collection of surfaces, so if you ever maneuver a camera inside a brush, it will appear invisible. If you want to observe your handiwork, right click in the camera view and use the arrow keys to move the camera around. While in camera mode, the camera will have full mouselook enabled, and the left and right arrow keys will "strafe" (sidestep left and right). If you right click again to leave camera mode, you gain control of your cursor again, but lose camera control. You can still move the camera forward and backwards using up and down, but left and right now rotate and you have no way to change your z position. Using whatever method you desire, move the camera outside the box, and take a look at it.
The box will most likely be colored in a red and black checkerboard that says "No Texture." To change this, make sure you have your brush selected, and then click on one of the textures in the panel in the bottom right hand corner of the screen. This will retexture your box with whatever you clicked on. Because your brush is selected, it will be tinted red, so if you want to see its natural colors, hit escape and deselect.
This box we have created isn't really what we want, though, and can't even be seen in the actual game of Quake2 yet. All Quake2 maps have a couple of generic properties, and two of these properties are that all maps must have a spawn point (a place for the player to start), and all entities must be sealed within the map (spawn points are a type of entity). Right now, wherever you put your spawn point, players will either be stuck inside a brush, or lost to the void of space. What we have to do is turn our box into a sealed container.
Reselect our one brush by shift left clicking on it in either the XY view or the camera view, and then use the hot bar at the top of the screen to "hollow" it. (The "Hollow" button is near the middle of the bar.) Now the box is split into six surfaces, each of which is one of the six sides of the box. If you move the camera back inside the box, you will now see that you can see the box's insides. This is because you are no longer inside any individual brush. The hollowing process turned our old brush into six new brushes, each of which is one side of the box. If you carefully maneuver yourself into one of the walls, you will find that it will still go invisible.
Now that this box is a sealed environment, it's safe to put a spawn point inside. Deselect everything, right click in the XY view at some point inside the walls of the box, and use the context menu that appears to add an info -> info_player_start. This is a spawn point for players. Make sure that it is positioned inside the box in both the XY and the Z views (isn't it handy how Radiant marks the floor and the ceiling in the Z view?) and then press escape to deselect the spawn point. We now have our basic map.
Suppose for a moment that you hadn't put a roof on this room. When you attempt a compile, it will fail, and in the editor you will see a red line come from the spawn point, out the hole that is our roof, and then stop. This is called a map leak. When you compile your map, if all of the entities in the map aren't sealed with it, it won't compile. As I noted above, Quake 2 MUST have a sealed level.
To view this map in game, we first need to save it. In the save dialogue, make sure that you save it to the Quake2/baseq2/maps/ directory. Otherwise, Quake2 won't know where to find it after you have compiled.
Now go to the "BSP" menu and select "NoVis." We haven't added any lights or details to the game at this point, so if we tell the compiler to care about lights (by not selecting one of the compiling options that runs the lighting process), we will end up with a perfectly black level. If we instead tell it to completely forget about lighting, we will end up with a full-bright level, in which every surface looks exactly the same as any other surface with that texture. It's incredibly flat and boring, but effective for testing a map.
Note: If you want Quake2 to automatically run your map after compile, you can tell it to do so in the preferences menu (Edit -> Preferences, and then Other -> BSP Monitoring -> Run engine after compile.) Otherwise, load up Quake2 and type "map mapname" in the console (where "mapname" is whatever you named your map). You don't need to include the file extension (".bsp") because Quake2 can only understand one format: .bsp.
You should now spawn in a perfectly bright box with whatever wall color you selected. Not much to look at, but it's definitely a start. Now let’s add some décor.
Quit out of Quake and go back to Radiant. We're now going to add some panache to our little cube. You can add whatever you want, but I’m going to start by adding a crate (what else would you add to a Quake level?).
In the XY and Z views, make a new brush in the level that is about the dimensions you might imagine a crate to be. You can use the info_player_start as something to compare your new brush to (it is the height of a player, but a little bit narrower).
Now that you've made another brush, we want to texture it. There are some nice crate textures under e1u2. Click on a crate texture while you have the brush selected to turn all of the faces of your brush into crate. You will notice that the texture probably does not come close to aligning itself with the face of your brush - the image is probably larger than the brush you created, and almost certainly not lined up.
You can fix this in a number of ways. All of the base Quake2 textures are perfectly designed to fit with the grid in radiant. So by using the XY and Z views to change the width and height of your crate, you could align the brush with the texture, instead of the texture with the brush.
Another option is to deselect your brush (assuming it is the correct shape), and then fix things surface by surface. You can select a single surface of a brush by control + shift clicking on it. Once you have a surface selected, hit the "s" key to pop up the Surface Inspector. Here, you can use the "H Shift" and "V Shift" values to micro-adjust the position of your crate surfaces. Assuming your cube is the right size, this will result in a perfect-looking crate.
However, this won’t work for any sort of custom texture that doesn’t perfectly match the grid, and it won’t work if your crate isn’t the correct size. If you can’t play around with a surface and get it to align properly, you have one last resort. In the surface inspector, in the middle of the panel, is a button that says "Fit." Clicking "Fit" will scale the texture so that it perfectly covers whatever surface it is applied to, no matter what its shape and size. Generally, using "Fit" is frowned upon for the same reason that you don’t include massive images in a webpage and then use HTML to scale them to being 60 pixels wide. Generally, image editing tools can resize images with far cleaner results than GtkRadiant (or a web browser).
Because the different sides of the cube won’t naturally align themselves (unless you used the first method of just dragging the sides of the cube around, in which case they might), you will have to repeat whatever process you used on the other five sides. If you want to select multiple surfaces at once (to "H Shift" or "V Shift"), you can do so by shift + ctrl + alt clicking on them.
If you recompile and reload the map at this point, you should now have a crate in your map.
No Id Software map has just one crate in it though, so we will want to add some more. Instead of making another one by hand, we can just duplicate our old crate. Select the crate (shift click it) and then hit the spacebar. We now have a second crate (which should be selected). You will notice that it overlaps most of the first crate. Duplicated brushes will have the same Z positions, and an offset of 1 grid unit in both the X and Y. Drag the second crate away so that it no longer overlaps, and then back up and admire your handiwork. If you put the crates flush up against each other, it will probably just look like one super extended crate. To avoid this effect, leave a gap of a grid unit or so in between like-textured objects.
At this point, I've gone over all of the basic brush capabilities: creating, resizing and texturing. However, up to this point, you can only create incredibly limited shapes -- everything is a rectangular prism and everything is lined up perfectly with the XY grid. Although one property of brushes is that they must be convex, Quake2 supports far more than a bunch of cubes, so I'll go over some of the advanced editor features at this point.
As an aside, if you don’t like a brush, the key to delete it is Backspace, not Delete. Delete and Insert actually zoom the XY view, as does the mouse wheel.
If you select any brush in your map and hit the "E" key, you will go into edge mode. Edge mode lets you reform your brushes so that they are no longer cubic. In edge mode, each edge of the brush gets a blue dot at its center, which you can drag around in either the XY or camera view. If you try to drag an edge into another edge, the editor will stop you, because you run the risk of forming a non-convex shape. In order to form pseudo-concave shapes, you have to take two convex brushes and place them flush against each other. There is no "right" way to emulate a given shape, but, generally speaking, the fewer brushes you use, the better.
You can also rotate brushes so they aren't stuck to the XY grid. Hit the "R" key to enter rotation mode, in which you can spin the object you have selected around its Z-axis. If you want to do 90-degree rotations (or flips), the hot bar at the top of the screen has buttons to automate the process.
If you feel as though the brushes you are creating are too large, you can change the size of the snap-to grid by hitting the number keys. In terms of game units (the scale on the XY and Z views) the keys correspond to 2n-1, where n is the number key that you hit. So hitting the 1 key will give you a grid size of 1, 2 gives 2, 3 gives 4, and 4 gives 8. The default grid size is 8 (the 4 key). If you want to entirely remove the grid, you can hit 0, but, generally speaking, this is a bad idea. Decimals in a brush's XY coordinates slow down the game’s engine at runtime, so it’s considered bad practice.
Another note on brushes: You never want two planar surfaces to overlap. You might think this is somewhat obvious, but it’s not. Imagine an empty room with a single cube in it. If you duplicate that cube, another cube appears offset slightly, but overlapping the first cube. Because the Z-axis values for the cubes are identical, their top surfaces will overlap with each other. Radiant doesn't know which one to draw on top, so they will flicker back and forth. It turns out that Quake2 doesn’t know either: both are supposed to be in the same spot, so the engine will try to draw both at the same time, leaving you with a flickering effect. This is called Z-fighting (even if it occurs in the X or Y dimensions). If this ever occurs, either move the second brush, or delete the part of it that is overlapping with the first brush. If this involves chopping the second brush into multiple pieces so that they remain convex, that's okay.
This doesn’t mean that you can’t have two surfaces flush against each other. If I put two cubes in a room and they touch faces horizontally, then we have no problems because the engine isn't trying to draw both surfaces in exactly the same spot. (Remember, brush surfaces are directional and only face outwards. So if you put the camera inside one cube and look at another cube that is touching it, you will only see the outside wall of the second cube.) You will only have Z-fighting if one brush is (at least partially) contained in another brush.
You now know enough about mapping to start building levels. However, if you jump right in at this point, you will still miss a few important points. One of these is the difference between "Structural" and "Detail" brushes.
When you create a brush, it is by default structural. This means that not only will it be drawn on the screen and give players a bloody nose if they run into it, but it will also stop the Quake2 engine itself from rendering objects behind it. Quake2 stores a lot of information in active memory that it isn’t actually drawing at the time. To avoid loading issues, the engine keeps track of a number of things that are "just around the corner." Any brushes that are structural count as solid walls in the engine’s mind when it is deciding where the corner is. Detail brushes, on the other hand, will be drawn on the screen, and will cause the player to clip against them (bloody nose and all that), but will not stop the engine from thinking about what is behind them.
In theory, you might want every brush to be structural. The logic behind this is that the less the engine is thinking about, the faster it must be running. However, this theory doesn’t pan out. Its logic holds true only if players are holding perfectly still. Once he moves, the more pieces the level is broken up into (by the excess number of structural walls), the more pieces have to be loaded in real time. And because each of those pieces has to be calculated when you compile your map, in-game loading times, in-game re-renderings, and map compilation times all shoot through the roof. It takes well over ten thousand times longer to complete the VIS process in compiling if you have a small map that is entirely structural. As your map size increases, your compile times grow exponentially.
The other extreme isn’t any good either, though. If you were to make every brush detail (except for the outer walls - more on this in a minute), you would have an abysmal frame rate, because Quake 2 would have to render everything at once, no matter how little of it you were actually seeing.
The solution to this problem is to make every brush that serves as a wall into a structural brush, and every brush that represents something less solid (say, a table, a book case, or our crate) into a detail brush. This will mean that everything in a given room will be rendered by the engine at all times, but, since everything in that room is loaded already, running around that room won't require any reloading. The hotkey for "make this brush detail" is ctrl + m, and the hotkey for "make this brush structural" is ctrl + shift + s. To see how much of a room is detail, hit ctrl + d to toggle off vision of all detail brushes (don't worry, you haven't deleted them). If your room looks perfectly bare without detail brushes, then you’re all set. If there is clutter left, ctrl + m your way to an empty room.
To clarify above, the other problem with making outside walls of a map into detail is that detail brushes don't count when the engine is making sure the map is airtight. You WILL get map leaks if you make your outer walls detail. If you are following the red line to your leak, and you see that it goes right through a wall, make sure the wall didn't accidentally get turned into a detail brush.
You might have noticed that the info_player_start that we added earlier doesn't have any of the properties that a regular brush has. That's because it's not the same type of object as a brush. The brushes that make up the walls of the level are just that - the bones of the level. They don't actually have any properties other than the fact that they are walls.
Entities, on the other hand, do have properties. If you select your info_player_start and hit "N", a properties window will pop up in which you can change things such as the direction players are facing when they spawn there. We don't need to change anything in our spawn point because it is already functional, but "N" is the key to use should you need to do so.
Now that you can successfully build and texture levels, it’s time to start with lighting.
You can light your map using one of two methods. Either you can add point entities that emit ideal light (that even fades according to the 1/r2 model), or you can add light-emitting properties to the surfaces of brushes.
Point lights are pretty simple. Deselect and right-click in the XY view, and select "light" from the drop-down menu. It will ask you for a value. For a room the size of the one we made for the soda machine, you will want a value of around 150-200 to produce a well-lit room that still has enough shadow to make the different surfaces appear defined.
When populating a room with point lights, it's usually fairly obvious to a player where you put these lights. Unless the room has a natural central light source, this is a bad thing. To get around this, try moving your light entities further from walls, or duplicating them and turning down the intensity (remember, "N" to edit entity properties). Don't waste hours trying to get the lighting perfect in a room. It’s not possible to duplicate real-world light effects in the game engine. It’s enough to tinker around with values enough so that it’s not just one super bright point flooding a room with a flat white light.
If you want to add color, hit K when you have a light entity selected and use the color picker to select what you want. If you later decide that you preferred white, you can use the entity properties and the "delete key/pair" option to remove it.
Duplicating lights is the same as duplicating anything else: spacebar.
Surface lighting isn't much more complicated. Start by creating a new brush that will be your light, and then use the surface inspector to apply a light texture to the side that you want to be light-emitting. In the surface inspector palette near the bottom, there is an option for light. The default is zero (no light emitted). Raise this value to around 10,000. Surface lights require MUCH higher numbers than point lights. A point light of even 1,000 would wash out the entire area surrounding it, whereas a surface light of 1,000 would barely provide enough light to see. A good way to imagine how to select values is that a surface with value 10,000 will emit the same amount of light as a surface that is reflecting light from a 10,000-point light. Although this isn’t an accurate portrayal of what is happening, it’s an easy way to think about what sort of values you want.
You can't change the color of a surface light the way you can change the color of a point light though, because surfaces always emit light the same color as the texture on that surface. If you tell a blue surface to emit light, you will get a blue lighting effect.