Esempio n. 1
0
// world-to-camera matrix
AffineTransform3d Camera::getMatrix() {
    AffineTransform3d orient;
    // prinicpal axes of camera. 
    // a matrix with these as its columns would make a cam coord in put it in
    // world coords. we want the opposite.
    Vec3d z = -direction.unit();
    Vec3d x = ( up ^ z ).unit();
    Vec3d y = (  z ^ x ).unit();
    std::copy(x.begin(), x.end(), orient.mat.row(0));
    std::copy(y.begin(), y.end(), orient.mat.row(1));
    std::copy(z.begin(), z.end(), orient.mat.row(2));
    transpose(&orient.inv, orient.mat);
    return orient * translation(-position);
}