gluLookAtでMultiplyされる行列を自前で作る場合、以下のようにすればokです。
If you want to get the matrix that is generated by gluLookAt, here is the way to do it.
1 //gluLookAt( 2 // eye[0], eye[1], eye[2], 3 // at[0], at[1], at[2], 4 // 0.0, 1.0, 0.0); 5 // equivalentpseudo code 6 float lookat[16]; 7 midentity(lookat); 8 vec3 *s = (vec3*)&lookat[0]; 9 vec3 *u = (vec3*)&lookat[4]; 10 vec3 *f = (vec3*)&lookat[8]; 11 vec3 *t = (vec3*)&lookat[12]; 12 vcpy(t, &eye); 13 vneg(t); 14 vsub(f, &at, &eye); 15 vnormalize (f); 16 vec3 up = {0, 1, 0}; 17 vcross(s, f, &up); 18 vcross(u, s, f); 19 vneg(f); 20 glMultMatr ixf(lookat);
posted by
takiuchi
on Sun 16 Aug 2009
at 14:44