Source SDK Game Development Essentials — Save 50%
Develop engaging and immersive mods with Source SDK with this book and ebook
This article by Brett Bernier, author of the book Source SDK Game Development Essentials, will introduce you to your new tools, and teach you how to navigate in 2D and 3D spaces.
In this article, we will cover the following topics:
- Learning some basic terminology
- Opening Hammer for the first time
- Navigating the 2D and 3D viewports
- Customizing your user interface
- Developing some basic organizational skills
Let us begin.
(For more resources related to this topic, see here.)
In this article, I will be guiding you through many examples using Hammer. There are a handful of terms that will recur many times that you will need to know. It might be a good idea to bookmark this page, so you can flip back and refresh your memory.
A brush is a piece of world geometry created with block tool. Brushes make up the basic building blocks of a map and must be convex. A convex object's faces cannot see each other, while a concave object's faces can. Imagine if you're lying on the pitched roof of a generic house. You wouldn't be able to see the other side of the roof because the profile of the house is a convex pentagon. If you moved the point of the roof down inside the house, you would be able to see the other side of the roof because the profile would then be concave.
This can be seen in the following screenshot:
Got it? Good. Don't think you're limited by this; you can always create convex shapes out of more than one brush.
Since we're talking about houses, brushes are used to create the walls, floor, ceiling, and roof. Brushes are usually geometrically very simple; upon creation, common brushes have six faces and eight vertices like a cube.
The brushes are outlined in the following screenshot:
Not all brushes have six sides; however, the more advanced brushwork techniques can create brushes that have (almost) as many sides as you want. You need to be careful while making complex brushes with the more advanced tools though. This is because it can be quite easy to make an invalid solid if you're not careful.
An invalid solid will cause errors during compilation and will make your map unplayable. A concave brush is an example of an invalid solid. World brushes are completely static or unmoving. If you want your brushes to have a special function, they need to be turned into entities.
An entity is anything in the game that has a special function. Entities come in two flavors: brush-based and point-based. A brush-based entity, as you can probably guess, is created from a brush. A sliding door or a platform lift are examples of brush-based entities. Point-based entities, on the other hand, are created in a point in space with the entity tool. Lights, models, sounds, and script events are all point-based entities. In the following figure, the models or props are highlighted:
The world is everything inside of a map that you create. Brushes, lights, triggers, sounds, models, and so on are all part of the world. They must all be contained within a sealed map made out of world brushes.
The void is nothing or everything that isn't the world. The world must be sealed off from the void in order to function correctly when compiled and played in game. Imagine the void as outer space or a vacuum. World brushes seal off the world from the void. If there are any gaps in world brushes (or if there are any entities floating in the void), this will create a leak, and the engine will not be able to discern what the world is and what the void is. If a leak exists in your map, the engine will not know what is supposed to be seen during the compile! The map will compile, but performance-reducing side effects such as bland lighting and excess rendered polygons will plague your map.
If at any point in your mapping experience, Hammer doesn't seem to be operating the way you want it to be, go to Tools | Options, and see if there's any preferences you would like to change. You can customize general settings or options related to the 2D and 3D views. If you're coming from another editor, perhaps there's a setting that will make your Hammer experience similar to what you're used to.
Loading Hammer for the first time
You'll be opening Steam\steamapps\common\Half-Life 2\bin often, so you may want to create a desktop shortcut for easier access. Run Hammer.bat from the bin folder to launch Valve Hammer Editor, Valve's map (level) creator, so you can start creating a map. Hammer will prompt you to choose a game configuration, so choose which game you want to map for.
I will be using Half-Life 2: Episode Two in the following examples:
When you first open up Hammer, you will see a blank gray screen surrounded by a handful of menus, as shown in the following screenshot:
Like every other Microsoft Windows application, there is a main menu in the top-left corner of the screen that lets you open, save, or create a document. As far as Hammer is concerned, our documents are maps, and they are saved with the .vmf file extension. So let's open the File menu and load an example map so we can poke around a bit. Load the map titled Chapter2_Example.vmf.
The Hammer overview
In this section, we will be learning to recognize the different areas of Hammer and what they do. Being familiar with your environment is important!
There are four main windows or viewports in Hammer, as shown in the following screenshot:
By default, the top-left window is the 3D view or camera view. The top-right window is the top (x/y) view, the bottom-right window is the side (x/z) view, and the bottom-left window is the front (y/z) view. If you would like to change the layout of the windows, simply click on the top-left corner of any window to change what is displayed.
In this article, I will be keeping the default layout but that does not mean you have to! Set up Hammer any way you'd like. For instance, if you would prefer your 3D view to be larger, grab the cross at the middle of the four screens and drag to extend the areas.
The 3D window has a few special 3D display types such as Ray-Traced Preview and Lightmap Grid. We will be learning more about these later, but for now, just know that 3D Ray-traced Preview simulates the way light is cast. It does not mimic what you would actually see in-game, but it can be a good first step before compile to see what your lighting may look like.
The 3D Lighting Preview will open in a new window and will update every time a camera is moved or a light entity is changed. You cannot navigate directly in the lighting preview window, so you will need to use the 2D cameras to change the viewing perspective.
The Map toolbar
Located to the left of the screen, the Map toolbar holds all the mapping tools. You will probably use this toolbar the most. The tools will each be covered in depth later on, but here's a basic overview, as shown in the following screenshot, starting from the first tool:
The Selection Tool
The Selection Tool is pretty self-explanatory; use this tool to select objects. The hot key for this is Shift + S. This is the tool that you will probably use the most. This tool selects objects in the 3D and 2D views and also lets you drag selection boxes in the 2D views.
The Magnify Tool
The Magnify Tool will zoom in and out in any view. You could also just use the mouse wheel if you have one or the + and – keys on the numerical keypad for the 2D views. The hot key for the magnify tool is Shift + G.
The Camera Tool
The Camera Tool enables 3D view navigation and lets you place multiple different cameras into the 2D views. Its hot key is Shift + C.
The Entity Tool
The Entity Tool places entities into the map. If clicked on the 3D view, an entity is placed on the closest brush to the mouse cursor. If used in the 2D view, a crosshair will appear noting the origin of the entity, and the Enter key will add it to the map at the origin. The entity placed in the map is specified by the object bar. The hot key is Shift + E.
The Block Tool
The Block Tool creates brushes. Drag a box in any 2D view and hit the Enter key to create a brush within the bounds of the box. The object bar specifies which type of brush will be created. The default is box and the hot key for this is Shift + B.
The Texture Tool
The Texture Tool allows complete control over how you paint your brushes. For now, just know where it is and what it does; the hot key is Shift + A.
The Apply Current Texture Tool
Clicking on the Apply Current Texture icon will apply the selected texture to the selected brush or brushes.
The Decal Tool
The Decal Tool applies decals and little detail textures to brushes and the hot key is Shift + D.
The Overlay Tool
The Overlay Tool is similar to the decal tool. However, overlays are a bit more powerful than decals. Shift + O will be the hot key.
The Clipping Tool
The Clipping Tool lets you slice brushes into two or more pieces, and the hot key is Shift + X.
The Vertex manipulation Tool
The Vertex manipulation Tool, or VM tool, allows you to move the individual vertices and edges of brushes any way you like. This is one of the most powerful tools you have in your toolkit! Using this tool improperly, however, is the easiest way to corrupt your map and ruin your day. Not to worry though, we'll learn about this in great detail later on. The hot key is Shift + V.
The selection mode bar
The selection mode bar (located at the top-right corner by default) lets you choose what you want to select. If Groups is selected, you will select an entire group of objects (if they were previously grouped) when you click on something. The Objects selection mode will only select individual objects within groups. Solids will only select solid objects.
The texture bar
Located just beneath the selection mode toolbar, the texture bar, as shown, in the following screenshot, shows a thumbnail preview of your currently selected (active) texture and has two buttons that let you select or replace a texture. What a nifty tool, eh?
The filter control bar
The filter control bar controls your VisGroups (short for visual groups). VisGroups separate your map objects into different categories, similar to layers in the image editing software.
To make your mapping life a bit easier, you can toggle visibility of object groups. If, for example, you're trying to sculpt some terrain but keep getting your view blocked by tree models, you can just uncheck the Props box, as shown in the following screenshot, to hide all the trees!
There are multiple automatically generated VisGroups such as entities, displacements, and nodraws that you can easily filter through. Don't think you're limited to this though; you can create your own VisGroup with any selection at any time.
The object bar
The object bar lets you control what type of brush you are creating with the brush tool. This is also where you turn brushes into brush-based entities and create and place prefabs, as shown in the following screenshot:
Navigating in 3D
You will be spending most of your time in the main four windows, so now let's get comfortable navigating in them, starting with the 3D viewport.
Select the camera tool on the map tools bar. It's the third one down on the list and looks like a red 35 mm camera.
Holding the left mouse button while in the 3D view will allow you to look around from a stationary point. Holding the right mouse button will allow you to pan left, right, up, and down in the 3D space. Holding both left and right mouse buttons down together will allow you to move forward and backwards as well as pan left and right. Scrolling the mouse wheel will move the camera forward and backwards.
Practice flying down the example map hallway. While looking down the hallway, hold the right mouse button to rise up through the grate and see the top of the map.
If you would prefer another method of navigating in 3D, you can use the W, S, A, and D keys to move around while the left mouse button is pressed. Just like your normal FPS game, W moves forward in the direction of the camera, S moves backwards, and A and D move left and right, respectively. You can also move the mouse to look around while moving.
Being comfortable with the 3D view is necessary in order to become proficient in creating and scripting 3D environments. As with everything, practice makes perfect, so don't be discouraged if you find yourself hitting the wrong buttons.
Having the camera tool selected is not necessary to navigate in 3D. With any tool selected, hold Space bar while the cursor is in the 3D window to activate the 3D navigation mode. While holding Space bar, the navigation functions exactly as it does as if the camera tool was selected. Releasing Space bar will restore normal functionality to the currently selected tool. This can be a huge time saver down the line when you're working on very technical object placements.
If you find yourself bouncing around between different areas of the map, or even changing angles near the same object, you can create multiple cameras and juggle between them. With the camera tool selected, hold Shift and drag a line with the left mouse button in any 2D viewport. The start of the line will be the camera origin, and the end of the line will be the camera's target.
Whenever you create a new camera, the newly created camera becomes active and displays its view in the 3D viewport. To cycle between cameras, press the Page Up and Page Down buttons, or click on a camera in any 2D view. Camera locations are stored in the map file when you save, so you don't have to worry about losing them when you exit. Pressing the Delete key with a camera selected will remove the active camera. If you delete the only camera, your view will snap to the origin (0, 0, 0) but you will still be able to look around and create other cameras. In essence, you will always have at least one camera in your map.
Selecting objects in the 3D viewport
To select an object in the 3D viewport, you must have the selection tool active, as shown in the following screenshot. A quick way to activate the selection tool is to hit the Esc key while any tool is selected, or use the Shift + S hot key.
A selected brush or a group of brushes will be highlighted in red with yellow edges as shown in the following screenshot:
To deselect anything within the 3D window, click on any other brush, or on the background (void), or simply hit the Esc key. If you want to select an object behind another object, press and hold the left mouse button on the front object. This will cycle through all the objects that are located behind the cursor. You will be able to see the selected objects changing in the 2D and 3D windows about once per second. Simply release the mouse button to complete your selection.
To select multiple brushes or objects in the 3D window, hold Ctrl and left-click on multiple brushes. Clicking on a selected object while Ctrl is held will deselect the object. If you've made a mistake choosing objects, you can undo your selections with Ctrl + Z or navigate to Edit | Undo.
|Develop engaging and immersive mods with Source SDK with this book and ebook|
eBook Price: €19.99
Book Price: €32.99
Navigating in 2D
Navigating in 2D is a bit different than 3D. Each 2D window has scroll bars like any webpage or text document, but there are some tips and tricks that can streamline the process.
You can zoom in a 2D view by scrolling up the scroll wheel. Scrolling the scroll wheel down will zoom out. If you do not have a scroll wheel on your mouse, the magnify tool will be your best friend.
The magnify tool works just how you would expect it to: left-click to zoom in and right-click to zoom out.
The minimum zoom (all the way out) is 0.01. The maximum zoom (all the way in) is 256. The current zoom amount is indicated in the bottom-right corner of the status bar, as shown in the following screenshot:
Panning the view is as easy as holding the Space bar and dragging the screen around with the left mouse button. You can also pan the view by using the up, down, left, and right arrows on the keyboard or using the scroll bars located to the right and bottom of each window.
Selecting objects in 2D
Just like the 3D view, selecting a brush in 2D is as easy as left-clicking on the center X, or one of the brush's edges. A selected object in the 2D view will be highlighted in red and have a yellow dashed line as a bounding box.
Just like the 3D view, multiple objects can be selected by holding Ctrl and left-clicking every object you want to select. Thankfully, the 2D view does not fall to the same selection pitfall as the 3D window, and clicking the void with Ctrl pressed will not deselect everything! Another way to select an object is to drag a selection box around it. Left-click and drag a selection box around the brush. Make sure the selection box surrounds the brush in at least two 2D views, and then hit Enter to select everything inside of that box. Objects that intersect with the box area will also be selected.
The grid helps keep your brushes organized, and by default, objects snap to it—meaning one or more edges will forced to be aligned to it. The grid size is based on powers of 2 (1, 2, 4, 8, 16, 32, and so on), and ranges from 1 to 512. The main gridlines are white, while the origin of the map (the 0, 0, 0 point) is highlighted in green, and every 1024 units is highlighted in red. The default grid size is 64 units, but you may change this any time. To increase the grid size, press the ] key. To decrease the grid size, press the [ button. The size of the grid is indicated in the status bar at the bottom-right corner of the screen. Working with a grid will ensure that objects touch each other. If you're making the map boundaries without a grid and two objects aren't touching, you could easily create a leak.
It's good practice to stay with a grid size of 4, 8, or 16 for most of your level development. Only small details should be created with smaller grid sizes; once you're done, return to a larger grid size.
A VisGroup is a group that contains different objects that can be toggled between hidden and visible. These are useful for keeping your map organized and reducing visual clutter.
The VisGroups toolbar is located to the right of the four viewport windows. There are two tabs available for organizing your VisGroups: User and Auto. The User tab contains all the VisGroups that you create, while the Auto tab organizes all the individual items into lists so you can activate and deactivate them whenever you'd like.
With the example map loaded, turn of all VisGroups except for World Geometry to see what the world is made of.
You should see something similar to the preceding screenshot. Note that on the left-hand side, you can see the all the entities and special brushes. However, on the right-hand side, you only see the floor, walls, and ceiling. If your map is getting cluttered, try turning off some specific VisGroups to make your life easier. VisGroups will affect the 2D view as well as the 3D view.
If you would like to create your own VisGroup, select a group of objects and go to View | Move Selection to VisGroup. Alternatively, you can hit the Move to VisGroup button on the toolbar at the top of the screen. It looks like a cube with red dotted lines (outlined in a red box in the following screenshot):
Navigating in all the viewports is simple once you get the hang of it, and it's vital to be comfortable with your mapping environment if you want to create spectacular maps. In the 3D view, you can use only the mouse, the mouse and Space bar, or the left mouse button and W, S, A, and D controls to get around. The 2D viewports can be easily navigated using a combination of mouse wheel zoom, Space bar and the left mouse button panning. Selecting objects is as simple as clicking on them in either view, and if you want to keep your map organized, VisGroups are the way to do it!
Resources for Article:
- DirectX graphics diagnostic [article]
- Introduction to Game Development Using Unity 3D [article]
- Unity Game Development: Interactions (Part 1) [article]
|Develop engaging and immersive mods with Source SDK with this book and ebook|
eBook Price: €19.99
Book Price: €32.99
About the Author :
Brett Bernier has been a creator since he could hold a LEGO brick and a gamer since he was old enough to hold a controller. After his father introduced him to First-Person Shooters, it didn't take long for him to want to create his own world. A lunch time discussion with Chris, his childhood friend and band mate, inspired him to take action and download Valve's Hammer 3.4 to create a Counter-Strike map. While looking for mapping tips online, he stumbled across a small, close-knit community of Half-Life mappers at The Whole Half-Life (TWHL). Brett, also known as Tetsu0, quickly honed his skills with the help of the community's tutorials and forums. When the Source SDK launched with Half-Life 2, he was hesitant to make the jump from GoldSource (Half-Life) to Source (Half-Life 2), but once made, he did not look back. He is currently employed as a Control System Technician at ETTER Engineering in Bristol, Connecticut, and is pursuing his Bachelor's Degree in Electronics Engineering Technology at the University of Hartford. He has been creating maps for the Half-Life game series since 2002.