Notifications
Clear all
[Closed] Flip normal to pos
Mar 20, 2018 2:30 pm
I’m looking for a good solution to flip mesh or poly normals to a target position.
Any thoughts would be great
Si
1 Reply
Mar 20, 2018 2:30 pm
I got it
Targ = Point pos:[(random -50 50),(random -50 50),(random -50 50)] Size:5 wirecolor:yellow
theMesh = Sphere radius:20 smooth:on segs:16
converttomesh theMesh
N1 = random 1 theMesh.numfaces
N2 = random 1 theMesh.numfaces
if N2 > N1 then meshop.flipNormals theMesh #{N1..N2} else meshop.flipNormals theMesh #{N2..N1}
FaceList = #{1..(theMesh.numfaces)}
for f = 1 to theMesh.numfaces do(
dir = normalize(getFaceNormal theMesh f)
Line_Good = (meshop.getFaceCenter theMesh f) + 3 * dir
Line_Bad = (meshop.getFaceCenter theMesh f) - 3 * dir
Line_Start = (meshop.getFaceCenter theMesh f)
dis1 = distance Targ.pos Line_Good
dis2 = distance Targ.pos Line_Bad
if dis1 > dis2 then FaceList[f] = true else FaceList[f] = false
)
meshop.flipNormals theMesh FaceList