I am working on an architecture app that uses a lot of transformed shapes and csgs. It’s a lot easer to manage the rotations, positions and scalings of the meshes if create CSGs with identity transform.
It this approach mostly works great but occasionally I can’t successfully apply multimaterials based on face normals, though the approach works fine when I use the mesh transforms and not identity.
See in this playground there is an area of the mesh produced by CSG.FromMesh(mesh,true) that has a vertical face normal?
I know that’s a mouthful. Any suggestions or request of me explaining what the hell I’m doing welcome! Happy Monday, y’all, from Trenton New Jersey!
Ok. Thank you so much, Evgeni and Raanan for the replies and for helping me understand what’s happening. That’s right on both counts. I did make some assumptions. Given what you have told me I am surprised that the mesh is not even worse looking!
Here’s the same thing using the facet normals. And the issue is resolved! The only thing I was unsure of is if I am indexing normals from facet data I need to multiply by 3 to translate this index into an indices index, correct?
You can do it this way or you could simply loop over the triangles of the mesh (so loop the indices 3 by 3), compute the normal of the triangle (cross product of p1 to p2 and p1 to p3) and do your processing with this normal. You don’t really need facet data to do that (it takes a little time/memory to generate these data).