Hi!
I am abit new to maxscript and I am trying to create a script that will loop through the bojects in scene and delete faces that are not facing the camera. I found a script that works to a point but at certain angles the wrong faces gets deleted. The script I use:
(
for theMesh in Geometry where not theMesh.isHiddenInVpt and classof theMesh != TargetObject do
(
convertToMesh theMesh --convert to EMesh
theMeshCount = theMesh.numfaces --get the number of faces in the object
selArray = #() --init. an array to collect faces
for f = 1 to theMeshCount do --loop through all faces
(
in coordsys (inverse (viewport.GetTM())) theFN = getFaceNormal theMesh f
if theFN.z < 0 then append selArray f -- if Z is negative, add to array
)
setFaceSelection theMesh selArray --set the face selection in the EMesh
max modify mode --go to modify mode
select theMesh --select the mesh
subObjectLevel = 3 --go to Face SO level
modPanel.addModToSelection (deleteMesh()) --add a delete mesh, preserving the SO selection
)
)
I also put a 3dsmax scene on dropbox with a camera001 that shows the problem and a camera002 that works just fine.(saved in 3dsmax 2012):
https://www.dropbox.com/sh/yopvor8kyzl1893/AADOb7_u57ZP7EYmlTub_DyLa?dl=…
Anyone know what I might be missing here or a solution for this?