diff --git a/CMakeLists.txt b/CMakeLists.txt index b5ceac8..9168ee2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,8 @@ file(GLOB SourceFiles ${SrcDIR}/core/* ${SrcDIR}/engine/* ${SrcDIR}/display/* - ${SrcDIR}/primatives/* + ${SrcDIR}/definitions/* + ${SrcDIR}/primatives/definitions/* ${SrcDIR}/util/* ${TestDIR}/${CurrentTest} ) diff --git a/src/definitions/camera.cpp b/src/definitions/camera.cpp new file mode 100644 index 0000000..8ec6ef9 --- /dev/null +++ b/src/definitions/camera.cpp @@ -0,0 +1,21 @@ +#include "camera.hpp" + +Camera::Camera(glm::vec3 point, glm::vec3 dir, float w, float h, float f) { + point = point; + direction = dir; + w = w; h = h; focalLen = f; +} + +void Camera::Update() { + // 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); + // 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 +} diff --git a/src/definitions/camera.hpp b/src/definitions/camera.hpp index 58f1259..05981c0 100644 --- a/src/definitions/camera.hpp +++ b/src/definitions/camera.hpp @@ -5,9 +5,16 @@ class Camera { public: + Camera(glm::vec3 point, glm::vec3 dir, float w, float h, float f = 500.0f); + + void Update(); + glm::vec3 point; - glm::vec3 look; - float fov; + glm::vec3 direction; + glm::vec3 planeCenter; + glm::vec3 planeDirX; + glm::vec3 planeDirY; + float focalLen, w, h; }; #endif diff --git a/src/definitions/ray.cpp b/src/definitions/ray.cpp index 40ef2ca..218afab 100644 --- a/src/definitions/ray.cpp +++ b/src/definitions/ray.cpp @@ -3,6 +3,15 @@ #include "camera.hpp" #include "scene.hpp" -Ray GeneratePrimaryRay(int x, int y, Scene& scene, float xSubPix = 0.5f, float ySubPix = 0.5f) { - +Ray GeneratePrimaryRay(int x, int y, Scene& scene, float xSubPix, float ySubPix) { + // double dy = 1.0; + // double dx = 1.0; + // double py = (- c->height / 2.0) + dy * ((double)y + 0.5); + // double px = (- c->width / 2.0) + dx * ((double)x + 0.5); + // Vector3 p = vec3_add3(c->planeCenter, + // vec3_mult(c->planeDirectionX, px), + // vec3_mult(c->planeDirectionY, py)); + // Vector3 u_r = vec3_unit(vec3_sub(p, c->position)); + // return ray_make(c->position, u_r); + return {}; } diff --git a/src/definitions/scene.hpp b/src/definitions/scene.hpp index 31d5b5f..0b60dfd 100644 --- a/src/definitions/scene.hpp +++ b/src/definitions/scene.hpp @@ -7,6 +7,7 @@ class Camera; class Primative; class Scene { +public: Camera* camera; std::vector objects; }; diff --git a/src/inferno.hpp b/src/inferno.hpp index 4087757..d430aa9 100644 --- a/src/inferno.hpp +++ b/src/inferno.hpp @@ -8,8 +8,8 @@ #include "common.hpp" // Give the user access to the base classes to define shit -#include "definitions/camera.hpp" #include "definitions/scene.hpp" +#include "definitions/camera.hpp" class Display; class Renderer; @@ -18,7 +18,6 @@ class Renderer; // and the renderer passes a full framebuffer (different depending on mode) to either the // display or an image generator, undecided how this will work but it will make for some // interesting features, ImGui can be used for settings inside the progressive mode gui - class InfernoEngine { public: InfernoEngine(); diff --git a/test/main.cpp b/test/main.cpp index eec80de..146f088 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -11,7 +11,10 @@ int main(int argc, char** argv) { std::cout << "Error initializing window: " << inferno.LastError() << std::endl; } - inferno.SetScene(new Scene()); + Scene* scene = new Scene(); + scene->camera = new Camera({0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f}, 600, 600); + + inferno.SetScene(scene); inferno.Ready(); inferno.Render();