## 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 import math as m c = g.getCurrentController() o = c.getOwner() cos = m.cos sin = m.sin ##Rotation on the X axis xa = m.radians(o.x) ##Rotation on the y axis ya = m.radians(o.y) ##Rotation on the z axis za = m.radians(o.z) #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, mat3): return [[(mat1[0][0]*mat2[0][0]*mat3[0][0])+(mat1[1][0]*mat2[1][0]*mat3[1][0])+(mat1[2][0]*mat2[2][0]*mat3[2][0]), (mat1[0][0]*mat2[0][1]*mat3[0][1])+(mat1[1][0]*mat2[1][1]*mat3[1][1])+(mat1[2][0]*mat2[2][1]*mat3[2][1]), (mat1[0][0]*mat2[0][2]*mat3[0][2])+(mat1[1][0]*mat2[1][2]*mat3[1][2])+(mat1[2][0]*mat2[2][2]*mat3[2][2])], [(mat1[0][1]*mat2[0][0]*mat3[0][0])+(mat1[1][1]*mat2[1][0]*mat3[1][0])+(mat1[2][1]*mat2[2][0]*mat3[2][0]), (mat1[0][1]*mat2[0][1]*mat3[0][1])+(mat1[1][1]*mat2[1][1]*mat3[1][1])+(mat1[2][1]*mat2[2][1]*mat3[2][1]), (mat1[0][1]*mat2[0][2]*mat3[0][2])+(mat1[1][1]*mat2[1][2]*mat3[1][2])+(mat1[2][1]*mat2[2][2]*mat3[2][2])], [(mat1[0][2]*mat2[0][0]*mat3[0][0])+(mat1[1][2]*mat2[1][0]*mat3[1][0])+(mat1[2][2]*mat2[2][0]*mat3[2][0]), (mat1[0][2]*mat2[0][1]*mat3[0][1])+(mat1[1][2]*mat2[1][1]*mat3[1][1])+(mat1[2][2]*mat2[2][1]*mat3[2][1]), (mat1[0][2]*mat2[0][2]*mat3[0][2])+(mat1[1][2]*mat2[1][2]*mat3[1][2])+(mat1[2][2]*mat2[2][2]*mat3[2][2])]] ##Multiply X and Y matrices. ##Multiply product of XYZ multXYZ = matMult(matX, matY, matZ) ##Ok... so now you can add a setOrientation(multXYZ) o.setOrientation(multXYZ)