THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/06/2011 at 11:38, xxxxxxxx wrote:
ok, so thanks to everybody's help i was successfully able to calculate the face normals and find out which way the polygon is facing. It seems to be working so I Thought this might help some people out!
def FindNormals(op) : #function to find direction of walls and assign to seperate selection tags
polys = op.GetAllPolygons() #get list of polygons in op
doc = c4d.documents.BaseDocument()
i=0
for poly in polys: #find normals
pt_a = op.GetPoint(poly.a)
pt_b = op.GetPoint(poly.b)
pt_c = op.GetPoint(poly.c)
pt_d = op.GetPoint(poly.d)
vector1 = pt_a-pt_b
vector2 = pt_b-pt_c
normal = vector1.Cross(vector2)
normal.Normalize()
nx = normal.x
ny = normal.y
nz = normal.z
if(nx!=0) : #check x normal
print "poly",i,poly,"is facing x to a degree of:",nx
i+=1
elif(ny!=0) : #check y normal
print "poly",i,poly,"is facing y to a degree of:",ny
i+=1
elif(nz!=0) : #check z normal
print "poly",i,poly,"is facing z to a degree of:",nz
i+=1
else:
print "something went wrong"
update: fixed some minor code output issues.