Flipping The Normal Of A Polygon?

I have a plane and I want to flip the normal without using bpy.ops.

Can this be done?

I tried…


    if flip_normal == True:
        me.polygons[0].normal = me.polygons[0].normal * -1

But for some reason the normal is read only?

Because I am creating the mesh on-the-fly I also tried altering the construct routine. But the normal always faces the wrong way.


def returnPlaneMesh(passedScene, passedName = "Plane", size = 1.0, plane_type = 0, flip_normal = False):
    v = []
    e = []

    if plane_type == 0:
        # Square pixels.
        w = 1
        h = 1
    if plane_type == 1:
         # 16:9 aspect ratio.
         w = 1.6
         h = 0.9
    if plane_type == 2:
        # 4:3 aspect ratio.
        w = 1
        h = 3/4 

    v.append(Vector ((-size*w,size*h,0)))
    v.append(Vector ((size*w,size*h,0)))
    v.append(Vector ((size*w,-size*h,0)))
    v.append(Vector ((-size*w,-size*h,0))) 
    f=[[0,1,2,3]]

    me = bpy.data.meshes.new(name= ("me_" + passedName))
    me.from_pydata(v, e, f )
    me.validate(verbose = True)  # useful for development when the mesh may be invalid.
    if flip_normal == True:
        me.polygons[0].normal = me.polygons[0].normal * -1 
    return me

Shouldn’t f=[[3,2,1,0]] produce a back facing mesh?

reversing the vert order actually work, but i tried with a cube and normals look different from flipped face via operator…

maybe use bmesh module?