Hello everyone,
I apologize if I word some things incorrectly, I am actually very new to scripting in Blender (Am more of an AI/Robotics programmer, but am using Blender for a project in my lab)
In any case, I am having trouble coloring a created Mesh. Here is the code I currently have for one of my functions:
def createPlane( x, y, z ):
### PLANE/FLOOR IMPLEMENTATION ###
#Define vertices, faces
verts = [(0,0,0),(x,0,0),(x,y,0),(0,y,0)]
# The number sequence refers to the vertex array items.
# The order will determine how the face is constructed.
faces = [(0,1,2,3)]
# Define mesh and object variables
mymesh = bpy.data.meshes.new("Plane")
#the mesh variable is then referenced by the object variable
myobject = bpy.data.objects.new("Plane", mymesh)
myobject.color = (255,255,255,255) #Can't seem to get this to work
#Set location and scene of object
myobject.location = [0, 0, z]
bpy.context.scene.objects.link(myobject)
#Create mesh
#this method has an optional 'edge' array input. This is left as an empty array
mymesh.from_pydata(verts,[],faces)
mymesh.update(calc_edges=True)
I know that objects have object.color, and I figured that would allow me to add color to my plane, but it is not working.
I am able to add color manually by using Diffuse Color in Editor Type > Material > Diffuse, but is there a way to do this during my script? The worlds I am building get particularly big so I would rather do this automatically.
I am sorry since I have seen threads that have asked similar questions before but none of them seemed to piece together what I needed in order to do this in my script.