I've been trying to replicate Hammer's automatic face alignment in Blender using Python. I'm looking to get it 1 to 1.
I know from
Valve that Face Alignment works by projecting on to the face depending on its angle.
I've written some code that goes over every face in my object in Blender, and aligns a camera (which is at the world originof (0 0, 0,) to rotate towards it and then uv project on to it. To put it another way, I'm replicating Face Alignment by getting the angle of the face, using that angle to rotate a camera (so the camera's view is parallel to the surface) and then projects a uv from the camera view on to the surface.
This actually works perfectly... for objects that are flat on the grid. But all other angles don't work quite right.
My issue is not that the process doesn't work, just that there isn't information I can find on how Hammer handles these arbitrary angles.
Left is Blender, right is Hammer. The textures are aligned 1 to 1. All the mesh is "flatly" on the grid.
These objects are at an angle and aren't matched up.
The following is how my script works:
The camera stays in the same location (the world origin) and rotates to match the angle of the face. It then projects the uv from the camera view. It does this for every face.