[Closed] Changing polygon texture orientation by vertex order
I’m drawing a big urban environment with a lot of houses in there. The 3D model is drawn in AutoCAD and exported to 3DS Max. The windows of the houses are simple rectangles (a polygon with four verts). On these rectangles I face-map an image of a window. But somehow there it goes wrong. The image of the window is rotated by 90 degrees most of the time and sometimes even 180 degrees. I’ve been trying to find out how to draw this rectangle in AutoCAD so that the image would be correctly orientated. But every time it is rotated.
I guess it has something to do with the order of the verts. So I was thinking of writing a small script which checks for every polygon the order of the verts and if need be orients them so that the image will be the right way turned.
Is not a big deal to find every polygon (quad) in the object and to get a list of the verts. But I’m unsure as to what the right order should be of the verts. I have investigated several polygons and I came to the following order (with the normal facing towards you):
42
31
So I have to find out the order of the verts in the normal’s coordinate system to see how it’s oriented and rotate it so that vertex one and three are down in world coordinates. Does this seem like a prudent approach and can you give any pointers? I’m getting more and more familiar with MaxScript, but any help will be greatly appreciated!
I think the important thing is not the numbering of the vertices, but the order they have in face definitions. As far as I can tell, the proper ordering (given the vertex placement in your example) would be these two faces: [3,1,2] and [2,4,3]
That is: [low left, low right, upper right] and [upper right, upper left, low left]
You’ll notice the vertices are put in a counter-clockwise order, which results in facenormals that point toward the viewer.
As for fixing it in a script…hmm. It can certainly be done, but it’s not a one-line fix. It seems to me you must somehow identify two faces/four vertices that make a window, then determine which way the window should be facing (using existing face-normals I guess), determine which vertices are up/down/left/right, delete existing faces and create new ones.
I’m betting there are easier ways to accomplish your goals, either by correcting something at an earlier stage or perhaps by using proper UVW-coordinates.
Have as look at Mesh Army Knife : http://www.phoenixgrafik.de/coding/uvface.html
http://www.phoenixgrafik.de/ (under programming)
It’s a modifier to be used as a replacement for editMesh mod. Maybe not the answer you’re looking for but something to get you started…
-Johan
Thanks for the tip. I’ve started writing a script and am halfway now. But I’m in the midst of moving, so time is very limited. I’ll post the result (or more problems/questions) here next week!