|
From: Matthias B. <ba...@ir...> - 2004-10-05 17:56:59
|
brett hartshorn wrote:
> body.getRotation() seems to return a long list of values that must be carefully mapped to a
> matrix. Is there a way to get a simpler value like a vector or quat of a body's rotation? I'm
> following tutorial3.py here is how its getting and setting rotation.
>
> R = body.getRotation()
> T = mat4()
> T[0,0] = R[0]
> T[0,1] = R[1]
> T[0,2] = R[2]
> T[1,0] = R[3]
> T[1,1] = R[4]
> T[1,2] = R[5]
> T[2,0] = R[6]
> T[2,1] = R[7]
> T[2,2] = R[8]
> T[3] = (x,y,z,1.0)
Well, the code could actually be a bit shorter:
R = body.getRotation()
T = mat4()
T.setMat3(mat3(R))
T[3] = (x,y,z,1.0)
You could also call getQuaternion() on the body, but to my knowledge
OpenGL has no function that allows you to specify a rotation as a
quaternion. That's why a 4x4 matrix is constructed from the 3x3 rotation
matrix and the translation vector.
- Matthias -
|