TrenchBroom Help - Shaping Brushes

## Shaping Brushes

The shape of a brush can be changed using several different tools. With the brush resizing tool, you can quickly move faces, thereby changing the brushes size. The clip tool allows you to cut brushes into arbitrary shapes. TrenchBroom also comes with very powerful tools to edit the vertices, edges and the faces of a brush.

### Resizing Brushes

Brush resizing in action.

Brush resizing is actually a translation of a face along its normal. This means that you cannot move faces around freely, but are restricted to the face's normal as its single axis of movement. To resize a brush, click and drag one of the brush's faces with the left mouse button while holding the
key. Note that if you have multiple brushes selected and you drag a face, every face of any selected brush that lies in the same plane as the dragged face will be moved, too. This allows you to quickly change the sizes of multiple brushes at once.

You can also move faces which are facing away from the camera by clicking outside of the brush. In the screencast above, observe how the second resize operation translates such a face. Note that you can only drag faces which have at least one edge visible. If you want to drag faces which are completely on the back of the brush, you need to reposition the camera.

TrenchBroom uses two methods to determine how to snap the distance by which you drag the face:

- The distance is snapped to the current grid size, i.e., if you drag a face by 17.5 units along its normal, it will be moved by 16.0 units if the current grid size is 16. This is useful if you are resizing brushes which are part of a curve because their faces will line up after the drag.
- The vertices of the dragged faces are snapped to the grid planes, i.e., whenever at least one vertex component (X,Y, or Z) is a multiple of the current grid size, the face is snapped to that vertex. This makes it easy to align a face to other adjacent faces.

Note that both snap modes are used simultaneously. There may be situations when you have to move the camera closer to a face in order to have sufficient precision when dragging the face.

### Using the clip Tool

The clip tool an important tool to change the shapes of brushes because it can add and remove faces from a brush. It is not activated with a modifier key such as the shift key. To toggle the clip tool, you need to choose
while brushes are selected. Afterwards, you will notice a white dot under your mouse cursor if you move the mouse over a selected brushes (see also the first of the following screenshots).

The general principle of the clip tool is that it cuts one or several brushes by adding a face to them. Remember that brushes are made of faces, and each face defines a plane which is actually the boundary of a half space. The brushes volume is then the intersection of all the half spaces defined by its faces. If you add a new face to a brush, there are three possible outcomes:

- The halfspace defined by the new plane does not intersect the brushes volume at all, and as a result the brush becomes invalid and is deleted.
- The brushes volume is entirely contained in the halfspace defined by the new face, so nothing actually changes.
- The intersection of the brushes volume and the half space defined by the new face is smaller than the brushes volume. The result is that the new face is added to the brush and all other faces which intersect with the new face are cut off. Additionally, some faces may be removed from the brush. This is what the clip tool is designed to do.

The clip tool allows you to define a plane (called the clip plane) by placing at least one point in space. This plane is then added to the selected brushes as a new face, and some brushes are deleted, some are changed and some retain their shape as described above. Depending on the orientation of the clip plane, different parts of the selected brushes are retained and deleted. The following screenshots show the three clip modes of the clip tool:

The modes of the clip tool.

The first screenshot shows the clip plane in its default orientation. Here, only one part of the brush is kept and the other is deleted. The second screenshot shows the same clip plane, but with the opposite orientation, so the part of the brush that would be deleted in the first screenshot is retained and vice versa. And finally the third screenshot shows the third mode of the clip tool. Here, both parts of the brush are retained, so the brush is split in two along the clip plane.

Now how does the clip tool work in practice? After it is activated, you can place up to three points in space. These points define the clip plane. The following screenshots should give you an idea how this works:

Defining a clip plane.

The white dots represent the clip points. The clip tool needs at least one clip point to create a clip plane. You can place clip points by clicking with the left mouse button, but you can only place clip points on the faces of the currently selected brushes. However, you can drag clip points off the faces (see below). You can delete the most recently placed clip point by hitting the
key. Once you have placed a point, the clip tool will try to guess a clip plane for you. If you need more control over the clip plane, you need to add more clip points as shown in the screenshots. Now the clip plane will be represented by a white line or triangle that has the clip points as vertices (see second and third screenshot).

The clip tool always gives you an instant preview of how the clipped brushes will look. Once you are satisfied with the clip plane, you can hit
to perform the clip. You can toggle between the three modes of the clip tool using the
command. If you use the split mode (where both sides of the clip plane are kept) on a brush entity, the resulting brushes will be added to the entity. TrenchBroom will also remember the last clip mode you used and the resulting brush(es) selected, which can help make further clip operations quicker. If you would like to cancel the clip operation, simply deactivate the clip tool with
or click in the void to deselect your current selection.

You should practice a bit with the clip tool. Often, you can change a brush into a desired shape much quicker using the clip tool than if you use one of the other options described in this section.

## Brush Editing

Unlike other editors, modifying the three geometric aspects of a brush, it's vertices, edges or faces, is all available via the vertex editing mode. To activate the vertex editing mode, press
. To deactivate the vertex editing mode, press
again. When vertex editing is enabled, handles appear at various points on the selected brushes to allow manipulation.

Selecting handles is treated just like selecting regular objects. Moving the mouse over the handle and
selects the handle.
can be used to select multiple handles at once.

Selection highlighting for vertices, edges and faces
Selected handles turn red

Once you are happy with the selection, you can move the handles just like you move other objects.
the mouse moves the handle(s) along the horizontal plane, and
moves the handle(s) vertically.

### Editing Vertices

The vertex editing mode allows you to move the vertices of a brush and to split edges and faces by adding new vertices to them. On selecting the first vertex, you will notice the handles for edges and faces disappear. This is to avoid cluttering up the view and also because you can only edit one type of handle at once. Also note that these handles will only be visible if you are within a certain distance to the brush. Like other objects, vertices can be moved horizontally by
them with the mouse and vertically by holding the
while dragging

Vertex Editing

You can move vertices freely as long as the brush does not become invalid. Trenchbroom tries it's best to stop that from happening and it will split and merge faces as needed to prevent it by splitting or merging faces and turning edges. If there is no way for Trenchbroom to validate the movement you are trying to do, it will simply not allow you to complete the move. In the second screenshot above, you can see that the front face of the cuboid has been split into two triangles as a result of one of its vertices being moved.

Edge splitting

You can also add new vertices to a brush by either splitting an edge or splitting a face. To split an edge, double click on the edge's handle. You can now drag it in a direction to create a new vertex at that point. In the above screenshot, you can see how the right edge of the front face has been split in two, resulting in a new vertex.

Face splitting

To split a face, double click on the face's handle drag it away from the brush. Look at the screenshot above for an example. Here, the front face of the brush has been split into four triangles which share the newly created vertex.

You can also merge vertices by moving one vertex onto another vertex, but only if the two vertices belong to the same edge. Otherwise, the brush would become invalid.

Face and edge splitting are very useful operations for creating terrain and natural rock formations. Play around with these features and you will quickly get an idea how they work.

### Editing Edges

Editing edges is similar to editing vertices. To select an edge, select the handle that lies at the edge's midpoint. As you hover over the edge's handle, the edge itself will become highlighted in white and
it will turn the edge red to indicate it has been selected. Again, these handles are only shown if you are close to a selected brush. Like vertices, edges can be moved horizontally by
them with the mouse and vertically by holding the
while dragging.

Edge Editing

In the screenshot above on the right, you can see that the upper edge of the left face has been moved horizontally inside the brush. Moving an edge is basically just a shortcut for moving the two vertices of the edge. TrenchBroom also splits and merges faces automatically just like in vertex editing mode.

Edge Editing 2

To illustrate these concepts, the screenshots above show the effect of moving the edge sideways. You can see that the front right face of the brush has been split into triangles.

### Face Editing

Finally, you can edit faces in vertex editing mode. This is done by selecting the handle in the center of the face you wish to edit. In this way, you can move all vertices which belong to one face by
the handle. To move the face vertically, hold the
key while dragging.

Face Editing 2

As you can see in the screenshots above, moving a face is basically like shearing brush. Of couse, you can also change the size of the brush by dragging the face towards or away from the brush's center. Note that, depending on the shape of the brush, face editing can have a different effect than brush resizing. Consider the following screenshots for an example.

Face Dragging vs. Brush Resizing

In the first screenshot, you see a brush shaped like a frustrum (a frustrum is a pyramid with its tip cut off). The top face is a square with a side length of four grid units. The second screenshot shows the effect of moving the top face upward using face editing mode. As you can see, the side length of the square has not changed - this is because face moving is tantamount to moving the vertices of the face in parallel. In the third screenshot however, you see the effect of resizing the face upwards. In this case, the side length of the top square has changed. Both operations have their advantages and disadvantages and it depends on the context which one you should use.

This concludes the section about shaping brushes. You have learned how to drag faces, clip brushes, delete individual faces and how to use the vertex, edge and face editing modes. Together, these tools allow you to create complex brush shapes quickly and precisely.

### Snapping to Grid

Like other objects, performing translations on handles operates by offsetting the selection by the current grid size. That is to say, if your current grid size is set to 64 and your handle is on '8 8 8', trying to move it in the X direction would result in the new position of '72 8 8'. Normally this is fine but sometimes it might be desireable to bring the selection back onto the grid. This is done by pressing
while dragging the selection and it will immediately snap to the nearest grid point.

In the case where you have multiple handles selected, it is the handle that was clicked on for the drag that will be used for snapping to grid.

### Snapping to Other Vertices

Sometimes it is difficult to snap a vertex onto another vertex in the 3D view. For such cases, there is an easy shortcut: Double click on a vertex handle and drag it onto another vertex handle. The clicked handle will be snapped to the exact position of the target handle. Note that this can be done only once and only with a single vertex. If you inadvertedly snapped the vertex onto the wrong target handle, you must undo the operation and try again.

## Working With Multiple Brushes

Vertex editing mode is not limited to working with single brushes. Selecting more than one brush and then pressing
to enable vertex mode will cause vertex handles to appear for all brushes in the selection. This is more useful when working on organic brushwork such as terrain. You can build a large group of brushes and modify them all at once without having to change the selection

### Vertex Clumping

Trenchbroom will recognize when vertices of multiple brushes share the same position. In this case, when trying to move a vertex, Trenchbroom will move all those vertices together making editing terrain much quicker and easier.

Vertex editing with multiple brushes

In the above screenshot, the vertices under the cursor were moved with a single drag operation because they share the same position. This behaviour also applies to edge and face editing if the handles of those components share the same position in space.