You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
voidlookat(Vec3f eye, Vec3f center, Vec3f up) {
Vec3f z = (eye-center).normalize();
Vec3f x = cross(up,z).normalize();
Vec3f y = cross(z,x).normalize();
ModelView = Matrix::identity();
for (int i=0; i<3; i++) {
ModelView[0][i] = x[i];
ModelView[1][i] = y[i];
ModelView[2][i] = z[i];
ModelView[i][3] = -center[i];
}
}
From the formula we derived, ModelView transformation matrix should be (R.T|-R.T x T) = (M_inv|0) x (Identity|-Tr).
But here the translation is not combined with rotation part.
Should be like this:
voidlookat(Vec3f eye, Vec3f center, Vec3f up) {
// find camera local basis to build rotation matrix
Vec3f z = (eye - center).normalize();
// up and z share the same plane
Vec3f x = (up ^ z).normalize();
// up and y not necessarily aligned
Vec3f y = (z ^ x).normalize();
// build transformation matrix// M_inv = M.T// R|T inv ==> R.T|-R.T T
Matrix M_inv = Matrix::identity(4);
Matrix Tr = Matrix::identity(4);
for (int i = 0; i < 3; ++i) {
M_inv[0][i] = x[i];
M_inv[1][i] = y[i];
M_inv[2][i] = z[i];
Tr[i][3] = -center[i];
}
ModelView = M_inv * Tr;
}
The text was updated successfully, but these errors were encountered:
https://github.com/ssloy/tinyrenderer/blob/f037c7a0517a632c7391b35131f9746a8f8bb235/our_gl.cpp
From the formula we derived, ModelView transformation matrix should be (R.T|-R.T x T) = (M_inv|0) x (Identity|-Tr).
But here the translation is not combined with rotation part.
Should be like this:
The text was updated successfully, but these errors were encountered: