Notifications
Clear all
[Closed] Check if object convex
Nov 22, 2012 12:00 pm
Hi all!
Been bashing my head against this for a few hours trying to figure out what’s going wrong.
Excuse the debug prints and such, might be useful if you’re trying this out (if it’s not something blatantly obvious I’m doing wrong).
Alternatively if anyone has a script already that checks whether an object is convex or not and is willing to share, that’d be great
Here’s the code I have currently:
fn GetAngleBetweenTwoFaces face1 face2 =
(
theAngle = acos(dot face1 face2)
--format" the Angle: %
" theAngle --uncomment this listener output if you want.
return theAngle
)
fn checkConvex obj =
(
onumFaces = polyop.getNumFaces obj
for f=1 to onumFaces do
(
normal_faceBase = polyop.getFaceNormal obj 1
--print("normal_faceBase: " + normal_faceBase as string)
for g=1 to onumFaces do
(
-- avoid self
if (f != g) then
(
normal_faceCompare = polyop.getFaceNormal obj g
--print("normal_faceCompare: " + normal_faceCompare as string)
normalDot2 = GetAngleBetweenTwoFaces normal_faceBase normal_faceCompare
normalDot = dot normal_faceBase normal_faceCompare
--if (normalDot > 0) then
-- convex = false
if (normalDot > 0) then
print("concave!")
--print("normalDot: " + f as string + "->" + g as string + " = " + normalDot as string)
--print("normalDot2: " + f as string + "->" + g as string + " = " + normalDot2 as string)
)
)
)
)
checkConvex $
All I seem to be able to get is positive values. Nothing useful to me if I am to try and check each face normal against each other face normal to determine if the object is convex or not. :banghead:
Any help is greatly appreciated. Cheers!