# [TUTORIAL] Creating Complex Curves and Corner Pieces

Discussion in 'Tutorials & Resources' started by KonstantinUb, Feb 10, 2013.

1. ### KonstantinUbL1: Registered

Messages:
9
Positive Ratings:
10

Recently, I've seen several questions floating around regarding creating offset corner pieces and curved junctions. This is my attempt at a tutorial on creating complex curves using clever brush manipulation.

This is one of the two techniques I use for curves, the other being template brushes and paste special. Of course, paste special is easier to work with, but I think this technique is more versatile and allows for more complicated brushwork (like the wavy railing in the screenshot above) which is otherwise impossible to pull off seamlessly.

Without further ado, let's get started:

1. Start by creating the shape you want to wrap around the corner piece. For this demonstration, I'll just use a simple rectangular frame. You can use any shape you want — even complex, wavy ones, like the one seen above — so long as they tile nicely around the corner.

2. Move the shape into place on the corner piece and align their outer vertices. Before we start, save a copy of your template shape in a separate visgroup so that you don't have to remake it for each face. Paste special is especially handy for this (CTRL+C → CTRL+SHIFT+V).

3. The goal here is to get the shape to the same width as the underlying corner face, as well as to rotate it so that they align perfectly. To do this, we're going to have to employ a bit of math.

To find how wide the corner face is, we use the Pythagorean theorem. Grab the block tool and drag a bounding box (in the top view presumably) from one vertex of the corner edge to the other. You've now formed a right triangle, with the corner edge as the hypotenuse. On the sides, you'll be able to read how many units the edge spans on the X and Y axes (the so-called “rise” and “run” you might've heard about in algebra class). From there, the edge's length will be $\tiny \inline \dpi{150} {\color{White} \ell = \sqrt{\Delta x^2 + \Delta y^2}}$.

To find out how far around we need to rotate the shape for it to match the corner face, we take the arctangent of the edge opposite angle $\tiny \inline \dpi{150} {\color{White} \theta}$ over the hypotenuse. Depending on how you've oriented the corner piece, this can either be $\tiny \inline \dpi{150} {\color{White} \theta = \arctan(\Delta x / \Delta y)}$ or $\tiny \inline \dpi{150} {\color{White} \theta = \arctan(\Delta y / \Delta x)}$. Google Search's built-in calculator is fabulous for this, as can be seen in the picture below.

4. Now that we know the corner edge's length, we need a way to get our shape to match that length. We do this by scaling it down, but in order to do that, we need to find the appropriate scaling factor $\tiny \inline \dpi{150} {\color{White} k}$. Wolfram|Alpha to the rescue! $\tiny \inline \dpi{150} {\color{White} k = \ell / w}$, where $\tiny \inline \dpi{150} {\color{White} \ell}$ is the corner edge length we found earlier (in my case, 50.249378 units) and $\tiny \inline \dpi{150} {\color{White} w}$ is the width of our shape (in my case, 64 units).

Once you've gotten the scaling factor, hit CTRL+M to open the transformation dialog. Select “Scale” on the left side, and put the scaling factor into the three fields on the right. It is recommended that you only scale the shape along one axis and leave the other two at 0 (or 1) as in most cases scaling on the vertical axis is not desirable, and scaling on the horizontal axis perpendicular to your shape's longer edge may result in diverging vertices. This is something I forgot to do when I was taking these screenshots — I should've just scaled the shape along Y and left the other two axes alone.

Hit enter to perform the transformation. Use CTRL+B to snap the resulting shape to the grid, and manually realign the shape's outer corner with the corresponding corner piece vertex. If you've done any vertical scaling, be sure to realign the brushes in the side views as well.

5. Now the rotation. Since geometry in Hammer cannot be rotated about an arbitrary point, we're going to have to “trick” Hammer with a helper brush, which will serve as our rotator gizmo. Grab the block tool and make a large brush (it has to look larger than your shape in the top view) centered around the shape's outer corner. This is crucial, so make sure you get it right!

6. Select both the shape and the helper brush, and once again open the transformation dialog with CTRL+M. Remember that arctangent calculation from earlier? Take the resulting angle (make sure it's in degrees) and put it into the Z field. Again, depending on the initial orientation of your corner piece, you may need to take the angle's negative value (e.g. 5.7105931° → -5.7105931°) or even its complementary angle (e.g. 5.7105931° → 84.2894069°) instead. (Complementary angles are angles that add up to 90 degrees.)

7. One last step: slicing the rotated shape so it doesn't stick out. This is pretty straightforward — just grab the clipping tool and slice the shape along the corner piece's inner edge.

8. Rinse and repeat for the second face and any other faces/corners after that.

Take careful note of how brush slicing is performed on non-axis-aligned faces: you select the shape and then drag the clipping gizmo from the shape's corner to the innermost vertex of the corner piece. Some gaps in the brushwork might pop up here, either due to Hammer's decimal loss issue or your sloppiness; CTRL+B and the vertex tool are your friends!

Conclusion: You can do all sorts of perverted crap with this method, so use it to your advantage. It can even be further expanded to include displacements.

I hope this was an enjoyable and informative read and that the techniques provided herein will prove helpful to you in your own maps. Thanks for reading, and have a nice day!

Another technique (click image for video):

• Thanks x 6
Last edited: May 1, 2013
2. ### Tarry H SrumanLarge Orphanage Proprietor

Messages:
871
Positive Ratings:
820
This seems like it would run into a lot of decimal loss errors.

3. ### KonstantinUbL1: Registered

Messages:
9
Positive Ratings:
10
Hasn't been much of a problem for me so far. You could always use VertAlert if you save over it so much that decimal loss becomes an issue.

• Thanks x 1
4. ### aaFaux RhinocerosAlso known as Dr. Element

Messages:
1,470
Positive Ratings:
1,363
Are you telling me that i can actually USE high-school math for something?

Heresy

• Thanks x 1
5. ### aaPocketfunc_croc

Messages:
4,476
Positive Ratings:
2,204
Oh cool. Hammer has gotten into a nasty habit of randomly moving vertices of shapes as simple as rounded-cornered rectangular prisms off-grid for me, so maybe this will come in handy.

6. ### aaSebaＤＲ． ＢＩＧ ＦＵＣＫＥＲ， ＰＨＤ

Messages:
2,363
Positive Ratings:
2,365
I read this on Facepunch, was definitely intrigued. Thanks for posting it here as well!

• Thanks x 1