How to get (almost) perfect texture rotations for brush faces in Hammer 3.5 using Blender
This tutorial applies to the Hammer Editor 3.5
UPDATE: I have removed the old tutorial since it was totally dispensable. Read the comments by 3zzzTyle for further information about this topic.
Aligning Textures on edges works by selecting the neighboring face and then pressing ALT while applying the selected texture to faces. In almost every case this will apply the correct rotation, scale and shift.
In cases where this doesn't produce the expected result, try switching the texture alignment of the face to "Face" instead of "World" and it might work perfectly after all.
It's defnitely good to know a lot of ways how to do this. However I will have to go through the math stuff a lot of times until I get it and in most cases I would rather go with the automatic texture alignment or Blender. But still good to know ofc. Thank you a lot for explaining!
Yep, something as simple as arc aligned to one of major planes can be textured in matter of minutes. Here I have 3 arcs, 16 segments each. Top sides have their texture coordinates copied from inner (as in, inner respective to arc) side planes of the same brush.
Calculating required angle on your own isn't that hard, though.
Lets make some basic brush and shift one of its ends to an arbitrary position. Now we have lost the desired alignment of the texture on top side (naturally, on bottom side as well).
To calculate required texture rotation angle, I draw a selection rectangle in such way that one of longer edges of our distorted brush will lie on diagonal line of that selection (Take a look at the top view projection). Next, I use dimensions of this selection (as shown in the bottom status bar) - 352 x 192 Hammer units - to calculate tangent of the angle between longer edge of our brush and X axis. Why X axis? Because brush edges were aligned in a parallel manner to this axis before vertex manipulation.
Finally comes the time for some math. Tangent equals length of side opposite to corner of triangle divided by length of side adjacent to it. The corner we're looking at is corner made by edge of brush and X axis - again, looking from top 2D projection. So the tangent will be 192 / 352 = 0.54545454... or 0.(54) for short. Now it's matter of using inverse function, arctangent to get the angle itself. Using any calculator (in my case, Windows calculator) will suffice.
It's a common practice to use radians instead of degrees in scientific software, Windows calc being no exception. Therefore, it gives answer of 0.497105741... - the right angle expressed in radians. To convert it to degrees, which VHE uses, simply multiply this number by 180 and divide by pi (3.14159 should be enough). After that, you should end up with value of 28.48 degrees.
Here we go, works like a charm. As a finishing touch, you might want to do something about texture scale, since top side of the brush is a bit "thinner" when viewing from top - because of the way we sheared one end before. The most fast way to do so is to use "Fit" button in texturing window and manually copy the smaller value in X/Y scale fields to bigger value, like that.
Good luck & feel free to include anything in this tutorial if you found it useful.
You know, what you just mentioned is exactely what I was looking for in the first place. It's the first time I hear about it and apparently it couldn't be easier. Although, I played around a bit and it does not seem to work for absolutely any situation (just some crazy stuff with distorted/rotated brushes) but of course it is still way easier and faster for 99% of Goldsource mapping.
So, thanks a lot for mentioning!
Let's just use my method as an emergency alternative then :D