Blender Materials: diffuseColor

diffuseColor
  • get/set the diffuse color of the material

Type:
  • float list: [ red, green, blue ]

red: 

  • range: 0.0 to 1.0

green: 

  • range: 0.0 to 1.0

blue: 

  • range: 0.0 to 1.0
Note:
  • Properties menu >> Material >> Diffuse >> Color bar
Sample Code

################## get the diffuse reflection color

# import bge
import bge

# get the current controller
controller = bge.logic.getCurrentController()

# get object that owns this controller
obj = controller.owner
 
# There's only one mesh on my model
mesh = obj.meshes[0]

# And only one material on the mesh
mat = mesh.materials[0]

# get diffuse reflection color
mat_diff_col = mat.diffuseColor

Sample Code

################## set the diffuse reflection color

# import bge
import bge

# get the current controller
controller = bge.logic.getCurrentController()

# get object that owns this controller
obj = controller.owner
 
# There's only one mesh on my model
mesh = obj.meshes[0]

# And only one material on the mesh
mat = mesh.materials[0]

# set diffuse reflection color
mat.diffuseColor = [ 0.0, 0.0, 0.1 ]