rollout rolTest "Sel Back Faces" ( -- Filter Functions ------------------------------------------------------------ function filterObj item = ( ((classOf item) == Editable_Poly) or ((classOf item) == Editable_Mesh) ) function filterCamera item = ((superClassOf item) == Camera) -- Interface ------------------------------------------------------------------- pickButton pbtObj "Object" message:"Pick an Editable Poly or Editable Mesh" filter:filterObj autoDisplay:true width:90 height:16 align:#left offset:[-6, 14] toolTip:"Editable Poly / Mesh" pickButton pbtCamera "Camera" message:"Pick a Camera" filter:filterCamera autoDisplay:true width:90 height:16 align:#left offset:[-6, -2] toolTip:"Camera" groupBox gbxNodes " Nodes " width:98 height:56 align:#left offset:[-10, -56] label lbFrameA "From" align:#left offset:[-4, 15] across:2 spinner spFrameA range:[-99999, 99999, 0] type:#integer fieldWidth:45 align:#left offset:[-11, 14] label lbFrameZ "To" align:#left offset:[-4, -1] across:2 spinner spFrameZ range:[-99999, 99999, 100] type:#integer fieldWidth:45 align:#left offset:[-11, -2] groupBox gbxFrames " Frame Span " width:98 height:56 align:#left offset:[-10, -56] progressBar pbPercent width:98 height:7 value:0 color:(color 0 197 0) align:#center offset:[0, -2] button btSelect "Select Faces" width:98 height:16 align:#center offset:[0, -5] -- Functions ------------------------------------------------------------------- function getBackFacesInRange obj camScan iFrameA iFrameZ &progress: = ( local p3ViewDir = [0,0,0] local p3ViewPos = [0,0,0] local p3FaceCenter = [0,0,0] local p3ScanDir = [0,0,0] if (classOf obj == Editable_Poly) then ( local baFaces = #{1..(polyOp.getNumFaces obj)} local baBackFaces = baFaces local baFrameBackFaces = #{} for iFrame = iFrameA to iFrameZ by 1 do ( at time iFrame ( p3ViewDir = -camScan.transform.row3 p3ViewPos = camScan.position baFrameBackFaces = #{} for iFace in baFaces do ( p3FaceCenter = polyOp.getSafeFaceCenter obj iFace if (p3FaceCenter == undefined) then p3FaceCenter = polyOp.getFaceCenter obj iFace if (camScan.orthoProjection) then p3ScanDir = p3ViewDir else p3ScanDir = normalize (p3FaceCenter - p3ViewPos) p3FaceNormal = polyOp.getFaceNormal obj iFace if ((dot p3FaceNormal p3ScanDir) > 0) then baFrameBackFaces[iFace] = true ) baBackFaces *= baFrameBackFaces ) if (progress != unsupplied) then progress = ((iFrame - iFrameA) as Float) / (iFrameZ - iFrameA) * 100 ) polyOp.setFaceSelection obj baBackFaces forceCompleteRedraw() ) else if (classOf obj == Editable_Mesh) then ( local baFaces = #{1..(meshOp.getNumFaces obj)} local baBackFaces = baFaces local baFrameBackFaces = #{} for iFrame = iFrameA to iFrameZ by 1 do ( at time iFrame ( p3ViewDir = -camScan.transform.row3 p3ViewPos = camScan.position baFrameBackFaces = #{} for iFace in baFaces do ( p3FaceCenter = meshOp.getFaceCenter obj iFace if (camScan.orthoProjection) then p3ScanDir = p3ViewDir else p3ScanDir = normalize (p3FaceCenter - p3ViewPos) p3FaceNormal = getFaceNormal obj iFace if ((dot p3FaceNormal p3ScanDir) > 0) then baFrameBackFaces[iFace] = true ) baBackFaces *= baFrameBackFaces ) if (progress != unsupplied) then progress = ((iFrame - iFrameA) as Float) / (iFrameZ - iFrameA) * 100 ) setFaceSelection obj baBackFaces forceCompleteRedraw() ) else ( throw "Wrong input in function getBackFacesInRange()" ) ) -- Events ---------------------------------------------------------------------- on pbtObj rightClick do pbtObj.object = undefined on pbtCamera rightClick do pbtCamera.object = undefined on btSelect pressed do if ( (pbtObj.object != undefined) and (pbtCamera.object != undefined) ) then ( getBackFacesInRange pbtObj.object pbtCamera.object spFrameA.value spFrameZ.value progress:&pbPercent.value pbPercent.value = 0 ) ) -- End Rollout createDialog rolTest 104 147 style:#(#style_toolwindow, #style_border, #style_sysmenu)