Forum: Poser Python Scripting


Subject: Flipping Normals

redspark opened this issue on Jun 21, 2020 ยท 13 posts


redspark posted Sun, 21 June 2020 at 11:23 PM

It seems that there are three parts to the Geometry's mesh: Vertices, Polygons and Sets. The Vertices are just the X,Y,Z coordinates of each point in the mesh. Polygons are defined as two numbers: the Set Index and the number of vertices in the polygon. The Set list is a 1 dimensional array of the vertices that make up all polygons. The Polygon Set Index from the polygon definition tells us the first point in the polygon from the set list and the number of vertices from the polygon definition tells us how many more array elements that polygon takes up. I didn't change the order of the lists of the vertices or the polygons. However, I did use the polygon data to reverse the set list.

So if we have polygon A defined as: [8, 4]. That means that Set[8] is the starting point in the polygon and Set[11] is the last point in the polygon. (Set[8], Set[9], Set[10], Set[11]) So then if we swap the values in 11 and 8 and 9 and 10 around, we have reversed the order of the vertices for that polygon. You just have to repeat that for each polygon in the geometry until all of the polygons have been reversed. That seems to do that trick.

I've only tried it on the Sphere prop but it is working so far. 😁

J