MAXScript FAQ > Working With Editable Meshes > How Do I Get Faces With Normals Facing Away? |
Can anyone tell me how to get faces that have normals pointing outside of the current viewport?
You can get the face normal in viewspace, then you just have to check the sign of the Z component. If it is negative, it is facing away from the camera!
Result:All triangles facing away from the camera will be deleted!
The image on the left shows the teapot with deleted backfaces as seen from a camera viewport. The image on the right shows the teapot and the camera as seen from the side. Note that for the screenshot, the backface culling was disabled (you can see the backfaces on the right image), but the left image looks just like it would with backface culling enabled! This is because the script deletes the same faces the viewport backface culling would skip!