• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

gluLookAtでMultiplyされる行列を自前で作る場合、以下のようにすればokです。

If you want to get the matrix that is generated by gluLookAt, here is the way to do it.

c>>
//gluLookAt(
// eye[0], eye[1], eye[2],
// at[0], at[1], at[2],
// 0.0, 1.0, 0.0);
// equivalent pseudo code
float lookat[16];
midentity(lookat);
vec3 s = (vec3)&lookat[0];
vec3 u = (vec3)&lookat[4];
vec3 f = (vec3)&lookat[8];
vec3 t = (vec3)&lookat[12];
vcpy(t, &eye);
vneg(t);
vsub(f, &at, &eye);
vnormalize(f);
vec3 up = {0, 1, 0};
vcross(s, f, &up);
vcross(u, s, f);
vneg(f);
glMultMatrixf(lookat);
<<--

posted by takiuchi takiuchi on Sun 16 Aug 2009 at 14:34 with 0 comments