Now that I have my transformations applied to a vertex shader, I realized that no matter what translations have occurred, the rotation is always around the origin. Here is my rotation code (pulled from Matrix4f in lwjgl-util). Any ideas on why this rotation doesn’t rotate round translated coordinate would be appreciated.
// all matrix values are in the same order as Matrix4f.java from lwjgl
public Matrix rotate(float radians, float x, float y, float z) {
Matrix src = this;
float c = (float) Math.cos(radians);
float s = (float) Math.sin(radians);
float oneminusc = 1.0f - c;
float xy = x*y;
float yz = y*z;
float xz = x*z;
float xs = x*s;
float ys = y*s;
float zs = z*s;
float f00 = x*x*oneminusc+c;
float f01 = xy*oneminusc+zs;
float f02 = xz*oneminusc-ys;
// n[3] not used
float f10 = xy*oneminusc-zs;
float f11 = y*y*oneminusc+c;
float f12 = yz*oneminusc+xs;
// n[7] not used
float f20 = xz*oneminusc+ys;
float f21 = yz*oneminusc-xs;
float f22 = z*z*oneminusc+c;
float t00 = src.m00 * f00 + src.m10 * f01 + src.m20 * f02;
float t01 = src.m01 * f00 + src.m11 * f01 + src.m21 * f02;
float t02 = src.m02 * f00 + src.m12 * f01 + src.m22 * f02;
float t03 = src.m03 * f00 + src.m13 * f01 + src.m23 * f02;
float t10 = src.m00 * f10 + src.m10 * f11 + src.m20 * f12;
float t11 = src.m01 * f10 + src.m11 * f11 + src.m21 * f12;
float t12 = src.m02 * f10 + src.m12 * f11 + src.m22 * f12;
float t13 = src.m03 * f10 + src.m13 * f11 + src.m23 * f12;
m20 = src.m00 * f20 + src.m10 * f21 + src.m20 * f22;
m21 = src.m01 * f20 + src.m11 * f21 + src.m21 * f22;
m22 = src.m02 * f20 + src.m12 * f21 + src.m22 * f22;
m23 = src.m03 * f20 + src.m13 * f21 + src.m23 * f22;
m00 = t00;
m01 = t01;
m02 = t02;
m03 = t03;
m10 = t10;
m11 = t11;
m12 = t12;
m13 = t13;
return this;
}
Any help would be appreciated,
CopyableCougar4