PolyLine face direction

Hello everyone,

I wrote script that imports data from an old game I am working with. The script works very nice, it basically read the data from the game and recreates the geometry in Blender using the PolyFill function.

My only problem now is the faces direction. I am not sure, but it looks like that PolyFill simply ignores the clockwise order and chose some random direction for the faces.

I wrote this small code as a test:


import Blender 
Vector= Blender.Mathutils.Vector 
 
polyline= [Vector(-5.0, -5.0, 0.0), Vector(5.0, -5.0, 0.0), Vector(5.0, 5.0, 0.0), Vector(-5.0, 5.0, 0.0)] 
 
fill= Blender.Geometry.PolyFill([polyline]) 
 
me= Blender.Mesh.New() 
me.verts.extend(polyline) 
me.faces.extend(fill) 
 
ob= Blender.Object.New('Mesh') 
ob.link(me) 
scn = Blender.Scene.GetCurrent() 
scn.link(ob) 
 
Blender.Redraw()

Now I added polyline.reverse()


 import Blender 
Vector= Blender.Mathutils.Vector 
 
polyline= [Vector(-5.0, -5.0, 0.0), Vector(5.0, -5.0, 0.0), Vector(5.0, 5.0, 0.0), Vector(-5.0, 5.0, 0.0)] 
polyline.reverse() 
 
fill= Blender.Geometry.PolyFill([polyline]) 
 
me= Blender.Mesh.New() 
me.verts.extend(polyline) 
me.faces.extend(fill) 
 
ob= Blender.Object.New('Mesh') 
ob.link(me) 
scn = Blender.Scene.GetCurrent() 
scn.link(ob) 
 
Blender.Redraw() 

Both codes generates exactly the same faces. Aren’t they supose to be generating faces with diferent normal directions?

Thanks,
Canassa

With polyfill you need to check the normal of the resulting polyline faces,
Iv added a wrapper function called
BPyMesh.ngon() thats a lot better for importers, it does error checking, normal flipping and returns a fan of tris if it cant scanfill.

polyfill just uses blenders scanfill, but I could make it enforce the order of the line,
thanks for the hint.

Oh, Thanks for clarifying this issue :slight_smile:

I will include some code in my script to check the faces normals.

Thanks,
Canassa