
transformUV(matID, matrix, uv_index, uv_index_from)
- Moves/rotates the UV 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.
- Type: float list [4x4 matrix]
- Type: integer
- -1 = all UV index
- 0 = first UV index on material
- 1 = second UV index on material
- uv index to copy from
- Type: integer
- -1 to transform the current uv.
- 0 = first UV index on material
- 1 = second UV index on material
Note:
- UV's are rotated and moved in the UV/Image Editor.
- The rotation transform uses the cosine of the angle.
matrix example:
- 4x4 matrix. Example moves the UV mapping but doesn't rotate it.
- ([ 1.0, 0.0, 0.0, 0.5], [ 0.0, 1.0, 0.0, 0.0], [ 0.0, 0.0, 1.0, 0.0], [ 0.0, 0.0, 0.0, 1.0])
- The first part -- [ 1.0, 0.0, 0.0, 0.5 ]:
Consists of two parts. 3D vector uses the object axis.
1. U-axis 3D vector -- 1.0, 0.0, 0.0 -- which is a rotation transform.
2. U-axis distance -- 0.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. V-axis 3D vector -- 0.0, 1.0, 0.0 -- which is a rotation transform.
2. V-axis distance -- 0.0 -- which is the movement transform.
- The third part--[ 0.0, 0.0, 1.0, 0.0]:
Not sure. UV mapping only has 2 axis--U and V
- 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 ]
- 4x4 matrix. Rotates the UV mapping 30 degrees.
- ([ 0.866, -0.5, 0.0, 0.0], [ 0.5, 0.866, 0.0, 0.0], [ 0.0, 0.0, 1.0, 0.0], [ 0.0, 0.0, 0.0, 1.0])

Sample Code
############################# transform the UV mapping
# 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 Same orientation. Move 0.1 on U axis
matrix = ([ 1.0, 0.0, 0.0, 0.1], [ 0.0, 1.0, 0.0, 0.0], [ 0.0, 0.0, 1.0, 0.0], [ 0.0, 0.0, 0.0, 1.0])
# first UV index
uv_index = 0
# transform the current UV Mapping
uv_index_from = -1
# move first UV 0.1 on U axis
mesh.transformUV(matID, matrix, uv_index, uv_index_from )