diff --git a/Source/TestMain.cpp b/Source/TestMain.cpp index 6255f26..1424077 100644 --- a/Source/TestMain.cpp +++ b/Source/TestMain.cpp @@ -27,7 +27,7 @@ public: Vec3(0.5, 0.5, 0), Vec3(0.5, 0.5, 0), }; - testFrustumClippedEqualsExpected(vecs, camera, frustum, 6); + testFrustumClippedEqualsExpected(vecs, camera, 6); beginTest("Focal Plane Frustum Out-Of-Bounds"); @@ -47,11 +47,11 @@ public: Vec3(-10, 10, 0), Vec3(-1, 1, 0), }; - testFrustumClippedEqualsExpected(vecs2, camera, frustum, 12); + testFrustumClippedEqualsExpected(vecs2, camera, 12); beginTest("Behind Camera Out-Of-Bounds"); - double minZWorldCoords = -focalLength + frustum.nearDistance; + double minZWorldCoords = -focalLength + camera.getFrustum().nearDistance; Vec3 vecs3[] = { Vec3(0, 0, -focalLength), Vec3(0, 0, minZWorldCoords), @@ -62,7 +62,7 @@ public: Vec3(-10, 10, -100), Vec3(-0.1, 0.1, minZWorldCoords), }; - testFrustumClippedEqualsExpected(vecs3, camera, frustum, 6); + testFrustumClippedEqualsExpected(vecs3, camera, 6); beginTest("3D Point Out-Of-Bounds"); @@ -74,7 +74,7 @@ public: Vec3(0.5, 0.5, minZWorldCoords), }; - testFrustumClipOccurs(vecs4, camera, frustum, 5); + testFrustumClipOccurs(vecs4, camera, 5); } Vec3 project(Vec3& p, double focalLength) { @@ -93,21 +93,21 @@ public: return "Expected: " + vec3ToString(expected) + ", Actual: " + vec3ToString(actual); } - void testFrustumClippedEqualsExpected(Vec3 vecs[], Camera& camera, Frustum& frustum, int length) { + void testFrustumClippedEqualsExpected(Vec3 vecs[], Camera& camera, int length) { for (int i = 0; i < length; i++) { Vec3 p = vecs[2 * i]; p = camera.toCameraSpace(p); - frustum.clipToFrustum(p); + camera.getFrustum().clipToFrustum(p); p = camera.toWorldSpace(p); expect(mathter::AlmostEqual(p, vecs[2 * i + 1]), errorMessage(p, vecs[2 * i + 1])); } } - void testFrustumClipOccurs(Vec3 vecs[], Camera& camera, Frustum& frustum, int length) { + void testFrustumClipOccurs(Vec3 vecs[], Camera& camera, int length) { for (int i = 0; i < length; i++) { Vec3 p = vecs[i]; p = camera.toCameraSpace(p); - frustum.clipToFrustum(p); + camera.getFrustum().clipToFrustum(p); p = camera.toWorldSpace(p); expect(!mathter::AlmostEqual(p, vecs[i]), errorMessage(p, vecs[i])); } diff --git a/Source/obj/Camera.cpp b/Source/obj/Camera.cpp index ec4ecfc..d19fb74 100644 --- a/Source/obj/Camera.cpp +++ b/Source/obj/Camera.cpp @@ -1,6 +1,4 @@ #include "Camera.h" -#include "../shape/Line.h" -#include Camera::Camera() : frustum(1, 1, 0.1, 100) { viewMatrix = mathter::Identity(); @@ -12,22 +10,6 @@ void Camera::setPosition(Vec3& position) { viewMatrix(2, 3) = -position.z; } -void Camera::findZPos(std::vector& vertices) { - float x = 0.0; - float y = 0.0; - float z = -1.0; - - //for (int i = 0; i < MAX_NUM_STEPS; i++) { - // z += CAMERA_MOVE_INCREMENT; - // for (size_t j = 0; j < std::min(VERTEX_SAMPLES, (int) vertices.size()); j++) { - // Vec3 vertex{vertices[j * 3], vertices[j * 3 + 1], vertices[j * 3 + 2]}; - // // check whether it's in the camera frustum - // } - //} - - viewMatrix = mathter::Translation(x, y, z); -} - Vec3 Camera::toCameraSpace(Vec3& point) { return viewMatrix * point; } diff --git a/Source/obj/Camera.h b/Source/obj/Camera.h index e9b942a..781458d 100644 --- a/Source/obj/Camera.h +++ b/Source/obj/Camera.h @@ -1,7 +1,5 @@ #pragma once -#include -#include -#include + #include "../mathter/Matrix.hpp" #include "Frustum.h" @@ -12,7 +10,6 @@ public: Camera(); void setPosition(Vec3& position); - void findZPos(std::vector& vertices); Vec3 toCameraSpace(Vec3& point); Vec3 toWorldSpace(Vec3& point); void setFocalLength(double focalLength); diff --git a/osci-render-test.jucer b/osci-render-test.jucer index 6ed36c6..0bea8eb 100644 --- a/osci-render-test.jucer +++ b/osci-render-test.jucer @@ -102,24 +102,6 @@ - - - - - - - - - - - - - -