Vertex Proxy: setRGBA

setRGBA(col)
  • sets the vertex color.

col:

  • RGBA float list: [ r, g, b, a]
or
  • 4 byte integer with one byte per color channel in the RGBA format.

a:

  • alpha color channel of the vertex
  • Type:  float number
  • Range: 0.0 to 1.0
b:
  • blue color channel of the vertex
  • Type:  float number
  • Range: 0.0 to 1.0
g:
  • green color channel of the vertex
  • Type:  float number
  • Range: 0.0 to 1.0
r:
  • red color channel of the vertex
  • Type:  float number
  • Range: 0.0 to 1.0
Note:
  • For the alpha channel to work, alpha must be enabled.
Sample Code

############################# set the color of the vertex

# import bge
import bge

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

# get object that owns this controller
obj = cont.owner
 
# Get a list of the mesh
meshList = obj.meshes

# Get the first mesh on the object
mesh = meshList[0]
 
# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# color is red
col = [ 1.0, 0.0, 0.0, 1.0]

# set the color
vert.setRGBA(col)