I dont understand how to set color in the NMesh Face. I tried following options
face = NMesh.Face()
face.col = [(255,0,0),(0,255,0),(0,0,255), (0,0, 255)]
or
COL=NMesh.Col()
COL.r=140
COL.g=250
COL.b=120
COL.a=0
face.col.append(COL)
or
face.col = [(223,125, 67)]
or
COL=NMesh.Col(230, 123, 255, 0)
HOW?? :o I went through the examples…It doesnt explain(clearly) how to set color either in the Nmesh Object, vertices or Face …or how this should work?
did you call mesh.update()? mesh.hasVertexColours(1) [if mesh doesn’t already have vertex colors: you haven’t entered vertex paint or face select mode…]?
#RND_COLORS.py
# set random colors to every face in a mesh
import Blender
for obj in Blender.Object.GetSelected():
if obj.getType() != "Mesh": continue
mesh = obj.getData()
mesh.hasVertexColours(1)
numfaces = len(mesh.faces)
step = 256*256*256 / numfaces
color = 0
for f in mesh.faces:
r = color / 256 / 256
g = color / 256 - r * 256
b = color - r*256*256 - g * 256
#print r,g,b
# all verticies in face get same color
f.col = len(f.v)*[Blender.NMesh.Col(r,g,b,0)]
color += step
mesh.update()
:o I still see the same grey square. There is no color(red). What could be wrong now? Is there some other settings which I am missing ?? I copy exactly what u have
vertex colors only show up in textured mode unless you assign a material setup with vcol light [vertex colors add light] or vcol paint [vertex color is base material color]
I see it now!! All it needed was ALT+Z (for textured view). Innitially I was expecting and hoping to see some color by pressing F12 (render) or wysiwyg (on screen)
Thanks a alot for your help and your patient z3r0 d. I am going to stick around and write more scripts to explore blender3d API