Hope you find uses for it
BTW Spike1907 i fixed it it works on all the local axis
## Ok, so this script is meant to properly use the setOrientation
## function along all axis. Just change the angle of rotation on
## any of the three axis (found on lines 17-24)
## It also has a function used to multiply the matrices together,
## and it could be modified to multiply matrices of different sizes.
## Script by Spike1907
## Revised by Siegel
## Assisted by maxwildcat
import GameLogic as g
from math import cos, sin, radians
c = g.getCurrentController()
o = c.getOwner()
current=o.getOrientation()
##Rotation on the X axis
xa = radians(45)
##Rotation on the y axis
ya = radians(0)
##Rotation on the z axis
za = radians(0)
#The rotational Matrices
#ROTATIONAL X MATRIX
matX = [[1.0, 0.0, 0.0],
[0.0, cos(xa), sin(xa)],
[0.0, -sin(xa), cos(xa)]]
#ROTATIONAL Y MATRIX
matY = [[cos(ya),0.0,-sin(ya)],
[0.0,1.0,0.0],
[sin(ya),0.0,cos(ya)]]
#ROTATIONAL Z MATRIX
matZ = [[cos(za),sin(za),0.0],
[-sin(za),cos(za),0.0],
[0.0,0.0,1.0]]
##Function used to multiply two matrices together.
##This only works for 3x3 matrices.
def matMult(mat1,mat2):
return [[(mat1[0][0]*mat2[0][0])+(mat1[0][1]*mat2[1][0])+(mat1[0][2]*mat2[2][0]),
(mat1[0][0]*mat2[0][1])+(mat1[0][1]*mat2[1][1])+(mat1[0][2]*mat2[2][1]),
(mat1[0][0]*mat2[0][2])+(mat1[0][1]*mat2[1][2])+(mat1[0][2]*mat2[2][2])],
[(mat1[1][0]*mat2[0][0])+(mat1[1][1]*mat2[1][0])+(mat1[1][2]*mat2[2][0]),
(mat1[1][0]*mat2[0][1])+(mat1[1][1]*mat2[1][1])+(mat1[1][2]*mat2[2][1]),
(mat1[1][0]*mat2[0][2])+(mat1[1][1]*mat2[1][2])+(mat1[1][2]*mat2[2][2])],
[(mat1[2][0]*mat2[0][0])+(mat1[2][1]*mat2[1][0])+(mat1[2][2]*mat2[2][0]),
(mat1[2][0]*mat2[0][1])+(mat1[2][1]*mat2[1][1])+(mat1[2][2]*mat2[2][1]),
(mat1[2][0]*mat2[0][2])+(mat1[2][1]*mat2[1][2])+(mat1[2][2]*mat2[2][2])]]
##Multiply X and Y matrices.
multXY = matMult(matX,matY)
##Multiply product of XY to Z matrix
multXYZ = matMult(multXY,matZ)
##Multiply product of XY and Z to currnet matrix
newXYZ = matMult(current, multXYZ)
##Ok... so now you can add a setOrientation(multXYZ)
o.setOrientation(newXYZ)
##You might need to reset the x y z degrees
##depending on how you use the script.
##x,y,z=0,0,0