Camera and rays

This commit is contained in:
Ben Kyd
2019-07-30 01:23:45 +01:00
parent f8dba5442b
commit 3bb08e48ca
8 changed files with 43 additions and 20 deletions

View File

@@ -7,15 +7,23 @@ Camera::Camera(glm::vec3 point, glm::vec3 dir, float w, float h, float f) {
}
void Camera::Update() {
// Vector3 x_c = c->position;
glm::vec3 up = {0.0f, -1.0f, 0.0f};
glm::vec3 c0 = point + (direction * focalLen);
glm::vec3 uX = glm::normalize(glm::cross(direction, up));
glm::vec3 uY = glm::cross((direction * -1.0f), uX);
planeCenter = c0;
planeDirX = uX;
planeDirY = uY;
// Vector3 x_c = c->position;
// Vector3 u_c = c->direction;
// double z_p = c->focalLength;
// Vector3 v_up = vec3_make(0.0, -1.0, 0.0);
// Vector3 c_0 = vec3_add(x_c, vec3_mult(u_c, z_p));
// Vector3 u_x = vec3_unit(vec3_cross(u_c, v_up));
// Vector3 u_y = vec3_cross(vec3_mult(u_c, -1.0), u_x);
// Vector3 c_0 = vec3_add(position, vec3_mult(direction, focalLength));
// Vector3 u_x = vec3_unit(vec3_cross(direction, v_up));
// Vector3 u_y = vec3_cross(vec3_mult(direction, -1.0), u_x);
// c->planeCenter = c_0;
// c->planeDirectionX = u_x;
// c->planeDirectionY = u_y;
// // Vector3 u_z = vec3_mult(u_c, -1.0); // Normal to the view plane
// Vector3 u_z = vec3_mult(direction, -1.0); // Normal to the view plane
}