Dylancyclone / VMF2OBJ

Convert source-engine VMF files into OBJ files with materials (including brushes, displacements, entities, and models)
MIT License
109 stars 6 forks source link

Displacement orientation problems #6

Closed Dylancyclone closed 4 years ago

Dylancyclone commented 4 years ago

Sometimes, the orientation of displacements is incorrect. I'm having trouble tracking down the source of the issue, but it seems to occur more often in decompiled maps compared to "raw" vmf maps built in hammer. See an example here: https://youtu.be/3CgoCSRIGqI?t=90

According to the VDC, there is an attribute of displacements called startposition that is supposed to indicate the bottom left corner of the displacement, but unless I'm missing something, this value doesn't seem to be spitting out useful information. (and bottom-left corner relative to what? ) https://developer.valvesoftware.com/wiki/Valve_Map_Format#Dispinfo

The annoying part is that the overall dimensions of the converted displacement are correct, it's just the order in which the vertices are loaded that is incorrect. This isn't a problem for square displacements since the converted result can easily be mirrored into position, but rectangular displacements are a little more difficult to fix quickly.

Dylancyclone commented 4 years ago

Here's what I've found so far:

...unless the startposition point is on a line formed by the brush that makes up the displacement, rather than the actual displacement. Which would be kind of dumb, and incredibly counter-intuitive, but I guess is a possibility. Which could explain why the problem is worse in decompiled maps since it spits out less user-friendly data.

Dylancyclone commented 4 years ago

I finally found the answer. The startposition attribute isn't necessarily on a line with one of the sides of the brush, but it is placed nearest the point that is deemed the "bottom-left" corner of the displacement. Orienting all the other point around this makes everything line up beautifully. It hurts that I got so close for so long and find the solution just days after making the project public, but I am so so happy this works now. This bug has plagued me for months.

This picture makes me so happy

image