0
$\begingroup$

I am trying to use a python script during runtime of bge to vertex color a mesh. The idea is to click the mouse and vertex color a mesh (the color is not uniform so I can't use object color). A simple version of the code is below and can be illustrated on the standard cube. Put in a logic brick for a mouse left button click and call it "click" along with a python controller running to this script.

cont=bge.logic.getCurrentController()
own=cont.owner
mesh=own.meshes[0]
click=cont.sensors["click"]
if click.positive:
    vertex=mesh.getVertex(0,1)
    vertex.color=[1,0,0,1]

This setup will color one vertex red. However when I parent the object to an armature (single bone) the code fails to do anything to the mesh.

If anyone can tell me where I am wrong or what I can do to achieve the end result in another way please let me know.

$\endgroup$
1
  • $\begingroup$ I believe this may be an error in the base code. Does anyone know where the C/C++/Python code that would control color rendering in bge is in the blender base code? $\endgroup$
    – simman
    Mar 24, 2016 at 12:45

1 Answer 1

1
$\begingroup$
cont=bge.logic.getCurrentController()
own=cont.owner
mesh=own.meshes[0]
click=cont.sensors["click"]
if click.positive:
    vertex=mesh.getVertex(0,1)
    vertex.color=[1,0,0,1]

This code has no relation to a parent of the (controller owning) object. So this should never be an issue.

I can only guess you execute this code at the armature. An armature has no mesh and will fail when you try to access it (line 3).

Hint: When using code you should always have a console window open to see any error messages. If you already have ... please post error messages together with your question.

$\endgroup$
2
  • $\begingroup$ I have the logic bricks set on the mesh. I opened the console window and get no errors. I even tried printing the vertex colors before and after and they all come out correct. I spent some time debugging it until I got down to just the parenting step. I go from functional to no effect by just doing the parenting. $\endgroup$
    – simman
    Mar 24, 2016 at 12:41
  • $\begingroup$ I just replicated this from a basic blender window on the basic cube in about 5 minutes in case someone wants to verify the problem. $\endgroup$
    – simman
    Mar 24, 2016 at 13:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .