Hayate wrote:Pick a point inside the object, then the normal for any face points away from that point if the number of other faces crossed by the line segment joining the point to the face is even, otherwise it points towards the point.
Alternatively pick a point outside, and do the same but reversing away from/towards.
Hayate wrote:Then pick any arbitrary point, render both images and manually pick the best one.
quickfur wrote:To understand why this is necessary, consider, say, a mesh of 6 triangles that tile a nonplanar hexagon. If we just blindly take the cross products of the triangle vertices in any order, some normals will point up and some will point down. We can't sanely interpolate normals in this case, because they will vary from a positive vector to a negative vector where there is no actual "flip" in the surface's curvature. (You may also get zero at some points, which is ridiculous.) So we must reorient the triangles so that the normals always points up (or down, it doesn't matter which as long as all of the triangles have normals pointing the same way).
Hayate wrote:My algorithm works for this example - perhaps you didn't understand the idea or are the conditions different for 4D objects?
quickfur wrote:Hayate wrote:My algorithm works for this example - perhaps you didn't understand the idea or are the conditions different for 4D objects?
Did I misunderstand what you meant? You said "render both images" - of what? A single face, or the entire 2-manifold? What did you mean by "manually pick" - run the program N times to correctly render N faces? Maybe I misunderstood what you meant, but manually picking (i.e. by the user) an orientation for each face is not feasible, because I may be using hundreds and thousands of faces to represent a projected 2-manifold.
Hayate wrote:[...]The algorithm is this:
1. Pick any point with random floating-point coordinates.
2. For each facet in the object, draw a line from the point to the facet.
3. If said line intersects an even number of facets, the normal of the target facet points one way (either towards or away from the point), otherwise it points the other way.
4. If by mere fluke the line happens to be perpendicular to the normal, it is impossible to solve the orientation for that facet, so pick a different point and try again (though this is very unlikely to happen since the point had random floating-point coordinates).
5. Render the image with those normals.
6. Repeat 1-5, reversing the directions of the normals.
7. Now you have two images, a right one and a wrong one. Manually pick the correct image.
But, I'm glad you solved the problem anyway - very nice images of the cubinder there!
Users browsing this forum: No registered users and 0 guests