Game Engine Lighting and moving Vertices via Python

Hi All,

I’m manipulating my mesh vertex positions using python

mesh = own.meshes[0]
vertex = mesh.getVertex(0,§)
vertex.XYZ = [pos[0],pos[1],3]

The actual manipulation of the Vertices works very well, and I have all the control I want over their position and it works well for my needs. However, my biggest issue is that Blender doesn’t seem to want to properly shade/light or recalculate the shading/lighting on the vertices moved through my python code. As seen below, Vertices that are moved ‘normally’ via edit mode and then run in the BGE have correct lighting/shading applied. Vertices on that same mesh that are moved in the BGE via python do not have correct lighting/Python applied.

Is this an issue any one has delt with? Am I able to get blender to recalculate shaders while running the BGE/Python script?


Well, you must also modify normals, I am not sure how is it done, though…

Right. I can use vertexNormals() to set the normals of a vertex, but this gives mixed results. Aren’t the shading/normals calculated on a face, and not on the vertex? Is the normal not dictated by the arrangement of vertices and how they form a face? Is there a known function for altering the normal of the face (something like this made up code: face = own.getFace(0,1) , face.setNormal())