Per-vertex color / transparency

Hi,

I’m working on a python script (for Blender 2.40) to import a custom dataset (for lightning models, actually) and I’d like to know if there’s a way to set the alpha value of each vertex. NMesh.Col is a list of four numbers, the last of which, the Blender 2.4 Python API assures me, is an alpha value.

However, the value of this so-called “alpha” componenet doesn’t seem to affect the transparency of the object at all. I’d like to be able to make these segments fade from an arbitrary alpha to another, and because of this, textures aren’t the ideal answer.

If you’ll suffer my simple test case, I’ve posted it here. When this is run, it makes a small, 3-sided tube that should fade from solid red to transparent black, but that doesn’t happen. Of course, once the object has been created, you’ll need to add a material to it that allows vertex colors.

Is there some setting I’m missing or is this broken?

Thanks,
Jason


import Blender
import math
    
def make_3cyl(basecolor, endcolor):
    mesh = Blender.NMesh.GetRaw()
    mesh.hasVertexColours(1)    
    vertex = [0.0, 0.0, 0.0]
    for i in range(0, 3):
        vertex[2] = 0.0
        th = 2.0*math.pi*float(i)/float(3)
        vertex[0] = math.cos(th)
        vertex[1] = math.sin(th)
        
        v=Blender.NMesh.Vert(vertex[0], vertex[1], vertex[2])
        mesh.verts.append(v)
        
    for i in range(0, 3):
        vertex[2] = 1.0
        th = 2.0*math.pi*float(i)/float(3)
        vertex[0] = math.cos(th)
        vertex[1] = math.sin(th)
        
        v=Blender.NMesh.Vert(vertex[0], vertex[1], vertex[2])
        mesh.verts.append(v)

    blbasecolor = Blender.NMesh.Col(basecolor[0]*255,basecolor[1]*255, basecolor[2]*255, basecolor[3]*255)
    blendcolor = Blender.NMesh.Col(endcolor[0]*255,endcolor[1]*255, endcolor[2]*255, endcolor[3]*255)
                
    for i in range(0, 3):
        f= Blender.NMesh.Face()
        f.smooth = 1
        f.col = []
        f.v.append(mesh.verts[i])
        if(i < 3):
            f.col.append(blbasecolor)
        else:
            f.col.append(blendcolor)
        f.v.append(mesh.verts[(i+1) % 3])
        if(((i+1) % 3) < 3):
            f.col.append(blbasecolor)
        else:
            f.col.append(blendcolor)
        f.v.append(mesh.verts[(i+1) % 3 + 3])
        if(((i+1) % 3 + 3) < 3):
            f.col.append(blbasecolor)
        else:
            f.col.append(blendcolor)        
        f.v.append(mesh.verts[(i+3)])
        if((i+3) < 3):
            f.col.append(blbasecolor)
        else:
            f.col.append(blendcolor)    
        mesh.faces.append(f)

    mesh.update()
    return mesh

if __name__ == '__main__':
    mesh = make_3cyl([1.0, 0.0, 0.0, 1.0], [0.0, 0.0, 0.0, 0.0])
    Blender.NMesh.PutRaw(mesh,"segment")