[Bf-python] povanim

Willian Padovani Germano wgermano at ig.com.br
Sat Jul 5 23:14:18 CEST 2003


On Sat, 2003-07-05 at 16:09, jms wrote:
> > Povanim needs a signal to export Vertex Color  and it seems that it is not
> > emited when the button VertCol is not set on...
> >

Ok, I looked at how things are done.  We fall into a deeper issue here.

Blender internals:

In a mesh struct, there are two pointers to arrays where vertex colors
can be stored: one where they should, in an mcol block and another
inside a struct named TFace (yes, TexFace).  What happens in Blender is
that when you add vertex colors and there's a texture, the mcol block is
copied to the tface->col block and deleted.  So with texfaces, there's
no mcol, it gets copied to the texface vertex colors block.  Anytime you
paint vertices, this info gets updated there, if there are textured
faces (that's what the mutually exclusive buttons were telling us).

And NMesh only has one place to store vertex colors: nmesh.faces.col

Let's say COL = nmesh.faces.col, to save typing.

If you have vcolors, as you know, COL holds them.  And if you have
uv-textures (linked to materials), COL holds the color of the material
that contains the texture you applied.

If you have both vcolors and uv-tex, the colors in COL will be the
vcolors if you pushed the "VCol Paint" button in the Material window. 
There's also a TexFace button there to make the texture also influence
vcolors.

> If a mesh has vertex colours AND uvcoords then the functions hasVertexcolours()
> and hasFaceUV() return : 0 and 1,  but povanim is waiting for 1 and 1.

That's it, but this is internal to Blender, the double storage.  Once
you mix both modes, the program copies vertex colors from their place to
the one pointed by the TFace struct. Only a change to Blender's core
will change that.  There's an old comment in NMesh.c exactly about this.

================================

There's one thing you can do: on each material of your model, turn the
"VCol Paint" button "on".  Then in Python check the material:

me = NMesh.GetRaw("my_mesh")
mat = me.materials[0]
if mat: has_vcols = mat.mode & mat.Modes['VColPaint']

If has_vcols isn't zero, then you can use the me.faces.col as vertex
colors.

Only thing is that I didn't implement the mat.Modes dict yet (duh!). 
The next version will have it, sorry.

If this solution doesn't prove good enough, tell us, please.

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list