camera bug and mesh class
This commit is contained in:
@@ -4,18 +4,22 @@
|
||||
|
||||
Camera::Camera(int width, int height)
|
||||
: position({0,0,0}),
|
||||
direction({0,0,1}),
|
||||
right({(float)width/(float)height,0,0}),
|
||||
up({0,1,0}) { }
|
||||
direction({0,0,1}),
|
||||
right({(float)width/(float)height,0,0}),
|
||||
up({0,1,0}),
|
||||
width(width),
|
||||
height(height) { }
|
||||
|
||||
Camera::Camera(glm::vec3 position, glm::vec3 direction, glm::vec3 right, glm::vec3 up)
|
||||
: position(position), direction(direction), right(right), up(up) { }
|
||||
|
||||
Camera::Camera(glm::vec3 position, int width, int height)
|
||||
: position(position),
|
||||
direction({0,0,1}),
|
||||
right({(float)width/(float)height,0,0}),
|
||||
up({0,1,0}) { }
|
||||
direction({0,0,1}),
|
||||
right({(float)width/(float)height,0,0}),
|
||||
up({0,1,0}),
|
||||
width(width),
|
||||
height(height) { }
|
||||
|
||||
void Camera::LookAt(glm::vec3 position, glm::vec3 sky, glm::vec3 lookAt, float angle, int width, int height) {
|
||||
float rightL = width / (float) height;
|
||||
@@ -28,9 +32,9 @@ void Camera::LookAt(glm::vec3 position, glm::vec3 sky, glm::vec3 lookAt, float a
|
||||
|
||||
Ray Camera::CastRay(int x, int y, float spX, float spY) {
|
||||
// TODO: ACTUALLY GET A WORKING CAMERA
|
||||
float camX = (((float)x + spX) / (float)600 * 2.0f - 1.0f) * getAspectRatio(600, 600) * getFovAdjustment(45.0f);
|
||||
float camX = (((float)x + spX) / (float)width * 2.0f - 1.0f) * getAspectRatio(width, height) * getFovAdjustment(45.0f);
|
||||
// 1.0 is taken first here as y is in the vertical
|
||||
float camY = (1.0f - ((float)y + spY) / (float)600 * 2.0f) * getFovAdjustment(45.0f);
|
||||
float camY = (1.0f - ((float)y + spY) / (float)height * 2.0f) * getFovAdjustment(45.0f);
|
||||
Ray ray{ {0.0f, 0.0f, 0.0f}, {camX, camY, -1.0f} };
|
||||
ray.direction = glm::normalize(ray.direction);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user