Mesh Proxy: transform

transform(matID, matrix)
• Moves/rotates the vertices of a material on a game object

matID:

• Type = integer
• -1 = all materials
• 0 = first material on mesh
• 1 = second material on mesh
• 2 = third material on mesh
• etc.
matrix:
• Type: float list [4x4 matrix]
Note:
• Doesn't move/rotate the object center of the game object.

• matID = -1: Transform all materials on mesh.

• The rotation transform uses the cosine of the angle.
matrix example:
• 4x4 matrix.  Example moves but doesn't rotate the material.
• ([ 1.0, 0.0, 0.0,  2.5], [ 0.0, 1.0, 0.0, 0.0], [ 0.0, 0.0, 1.0, 3.1], [ 0.0, 0.0, 0.0, 1.0])
• The first part -- [ 1.0, 0.0, 0.0,  2.5 ]:
Consists of two parts.  3D vector uses the object axis.
1.  X-axis 3D vector -- 1.0, 0.0, 0.0 -- which is a rotation transform.
2.  X-axis distance -- 2.5 -- which is the movement transform.
• The second part -- [ 0.0, 1.0, 0.0, 0.0]:
Consists of two parts.  3D vector uses the object axis.
1.  Y-axis 3D vector -- 0.0, 1.0, 0.0 -- which is a rotation transform.
2.  Y-axis distance -- 0.0 -- which is the movement transform.
• The third part--[ 0.0, 0.0, 1.0, 3.1]:
Consists of two parts.  3D vector uses the object axis.
1.  Z-axis 3D vector -- 1.0, 0.0, 0.0 -- which is a rotation transform.
2.  Z-axis distance -- 3.1 -- which is the movement transform.
• The fourth part--[ 0.0, 0.0, 0.0, 1.0 ]:
Not sure what this is.
Everything I've read says that this is always [ 0.0, 0.0, 0.0, 1.0 ]
matrix example:
• 4x4 matrix.  Rotates the material 30 degrees around the game object's X axis.
• ([ 1.0, 0.0, 0.0,  0.0], [ 0.0, 0.866, -0.5, 0.0], [ 0.0, 0.5, 0.866, 0.0], [ 0.0, 0.0, 0.0, 1.0])
Sample Code

############################# transform the vertex of the material

# 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]

# transform all materials on mesh
matID = -1

# 4x4 matrix
matrix = ([ 1.0, 0.0, 0.0,  -2.5], [ 0.0, 1.0, 0.0, 0.0], [ 0.0, 0.0, 1.0, 3.5], [ 0.0, 0.0, 0.0, 1.0])

# transform material vertex
mesh.transform(matID, matrix)