GLKMatrix4MakeLookAt
iOS 5 のドキュメントは、が と同じように動作することを明らかにしていgluLookAt
ます。
定義は次のとおりです。
static __inline__ GLKMatrix4 GLKMatrix4MakeLookAt(float eyeX, float eyeY, float eyeZ,
float centerX, float centerY, float centerZ,
float upX, float upY, float upZ)
{
GLKVector3 ev = { eyeX, eyeY, eyeZ };
GLKVector3 cv = { centerX, centerY, centerZ };
GLKVector3 uv = { upX, upY, upZ };
GLKVector3 n = GLKVector3Normalize(GLKVector3Add(ev, GLKVector3Negate(cv)));
GLKVector3 u = GLKVector3Normalize(GLKVector3CrossProduct(uv, n));
GLKVector3 v = GLKVector3CrossProduct(n, u);
GLKMatrix4 m = { u.v[0], v.v[0], n.v[0], 0.0f,
u.v[1], v.v[1], n.v[1], 0.0f,
u.v[2], v.v[2], n.v[2], 0.0f,
GLKVector3DotProduct(GLKVector3Negate(u), ev),
GLKVector3DotProduct(GLKVector3Negate(v), ev),
GLKVector3DotProduct(GLKVector3Negate(n), ev),
1.0f };
return m;
}
これからカメラ情報を抽出しようとしています:
1. Read the camera position
GLKVector3 cPos = GLKVector3Make(mx.m30, mx.m31, mx.m32);
2. Read the camera right vector as `u` in the above
GLKVector3 cRight = GLKVector3Make(mx.m00, mx.m10, mx.m20);
3. Read the camera up vector as `u` in the above
GLKVector3 cUp = GLKVector3Make(mx.m01, mx.m11, mx.m21);
4. Read the camera look-at vector as `n` in the above
GLKVector3 cLookAt = GLKVector3Make(mx.m02, mx.m12, mx.m22);
2 つの質問があります。
ルックアット ベクトルは、定義されているように否定されているように見え
(eye - center)
ます(center - eye)
。確かにGLKMatrix4MakeLookAt
、カメラ位置を呼び出し、抽出した視線(0,0,-10)
の中心がである場合、つまり、私が期待するもののネガです。では、抽出したものを否定する必要がありますか?(0,0,1)
(0,0,-1)
抽出するカメラ位置は、ビュー変換行列にビュー回転行列を乗算した結果であるため、その定義では内積になります。私はこれが間違っていると思います - 他の方法で位置を計算する方法を誰か提案できますか?
お時間をいただきありがとうございました。