I’m having a problem figuring out the proper rotation orders and the proper matrix to use for the object chop that is computing rotation angles for a shader. Basically I have a 3d controller that is outputting 6 Degrees of freedom and then a network using null components and an object chop to accumulate my transformations and rotations. My problem is I can’t figure out which rotation matrix to use inside of a shader. The controller works fine to control the Touch camera but I’m having a hard time controlling a camera perfectly inside of GLSL Top shader. I would prefer to use the XYZ rotation order but any order will work as long as the camera doesn’t flip around when it gets to a certain angle (the angle/axis it flips on changes with different rotation orders and matrices). Below are a couple of the matrices I’ve been using.[code]// Return rotation matrix
mat3 rotationAngleMatrix1(vec3 r)
{
float cx = cos(radians(r.x));
float sx = sin(radians(r.x));
float cy = cos(radians(r.y));
float sy = sin(radians(r.y));
float cz = cos(radians(r.z));
float sz = sin(radians(r.z));
return mat3(cy*cz, cy*sz, -sy,
sx*sy*cz-cx*sz, cx*cz+sx*sy*sz, sx*cy,
sx*sz+cx*sy*cz, cx*sy*sz-sx*cz, cx*cy );
}
// Return rotation matrix
mat3 rotationMatrixXYZ1(vec3 r)
{
float c1 = cos(radians(-r.x));
float s1 = sin(radians(-r.x));
float c2 = cos(radians(-r.y));
float s2 = sin(radians(-r.y));
float c3 = cos(radians(-r.z));
float s3 = sin(radians(-r.z));
return mat3(c2*c3,c1*s3+c3*s1*s2,s1*s3-c1*c3*s2,
-c2*s3,c1*c3-s1*s2*s3,c3*s1+c1*s2*s3,
s2,-c2*s1,c1*c2);
}
// Return rotation matrix
mat3 rotationMatrixXYZ(vec3 r)
{
float c1 = cos(radians(r.x));
float s1 = sin(radians(r.x));
float c2 = cos(radians(r.y));
float s2 = sin(radians(r.y));
float c3 = cos(radians(r.z));
float s3 = sin(radians(r.z));
return mat3(c2*c3,-c2*s3,s2,
c1*s3+c3*s1*s2, c1*c3-s1*s2*s3, -c2*s1,
s1*s3-c1*c3*s2, c3*s1+c1*s2*s3, c1*c2);
}
// Return rotation matrix
mat3 rotationMatrixXYZ3(vec3 r)
{
float c1 = cos(radians(r.x));
float s1 = sin(radians(r.x));
float c2 = cos(radians(r.y));
float s2 = sin(radians(r.y));
float c3 = cos(radians(r.z));
float s3 = sin(radians(r.z));
return mat3(c1*c3-s1*s2*s3,-c2*s1, c1*s3+c3*s1*s2,
c3*s1+c1*s2*s3,c1*c2,s1*s3-c1*c3*s2,
-c2*c3,s2,c2*c3);
}[/code]
Could anyone suggestion the proper matrix for an XYZ rotation order with this component?
3dx_Camera_Control.tox (28.4 KB)