[TUTORIAL] Creating Complex Curves and Corner Pieces

KonstantinUb

L1: Registered
Dec 7, 2012
9
12
track.png


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
png.latex
.

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
png.latex
over the hypotenuse. Depending on how you've oriented the corner piece, this can either be
png.latex
or
png.latex
. 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
png.latex
. Wolfram|Alpha to the rescue!
png.latex
, where
png.latex
is the corner edge length we found earlier (in my case, 50.249378 units) and
png.latex
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):

 
Last edited:

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
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.

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.
 

Seba

DR. BIG FUCKER, PHD
aa
Jun 9, 2009
2,364
2,728
I read this on Facepunch, was definitely intrigued. Thanks for posting it here as well!