kopia lustrzana https://github.com/jameshball/osci-render
Remove unneccessary functions and imports
rodzic
eaf5a3eb9c
commit
e52406aec0
|
@ -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]));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#include "Camera.h"
|
||||
#include "../shape/Line.h"
|
||||
#include <numbers>
|
||||
|
||||
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<float>& 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;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <JuceHeader.h>
|
||||
|
||||
#include "../mathter/Matrix.hpp"
|
||||
#include "Frustum.h"
|
||||
|
||||
|
@ -12,7 +10,6 @@ public:
|
|||
Camera();
|
||||
|
||||
void setPosition(Vec3& position);
|
||||
void findZPos(std::vector<float>& vertices);
|
||||
Vec3 toCameraSpace(Vec3& point);
|
||||
Vec3 toWorldSpace(Vec3& point);
|
||||
void setFocalLength(double focalLength);
|
||||
|
|
|
@ -102,24 +102,6 @@
|
|||
<FILE id="V3Q6n2" name="Frustum.cpp" compile="1" resource="0" file="Source/obj/Frustum.cpp"/>
|
||||
<FILE id="m9wauB" name="Frustum.h" compile="0" resource="0" file="Source/obj/Frustum.h"/>
|
||||
</GROUP>
|
||||
<GROUP id="{2FFB1E70-C58F-FC28-4D59-AF861B331B54}" name="shape">
|
||||
<FILE id="J5Nnzj" name="CircleArc.cpp" compile="1" resource="0" file="Source/shape/CircleArc.cpp"/>
|
||||
<FILE id="oNmrlE" name="CircleArc.h" compile="0" resource="0" file="Source/shape/CircleArc.h"/>
|
||||
<FILE id="u8e3mP" name="CubicBezierCurve.cpp" compile="1" resource="0"
|
||||
file="Source/shape/CubicBezierCurve.cpp"/>
|
||||
<FILE id="aJoApp" name="CubicBezierCurve.h" compile="0" resource="0"
|
||||
file="Source/shape/CubicBezierCurve.h"/>
|
||||
<FILE id="bbtKzH" name="Line.cpp" compile="1" resource="0" file="Source/shape/Line.cpp"/>
|
||||
<FILE id="Q4bPoy" name="Line.h" compile="0" resource="0" file="Source/shape/Line.h"/>
|
||||
<FILE id="tZJGSA" name="Point.cpp" compile="1" resource="0" file="Source/shape/Point.cpp"/>
|
||||
<FILE id="LaJfn7" name="Point.h" compile="0" resource="0" file="Source/shape/Point.h"/>
|
||||
<FILE id="sRz2K2" name="QuadraticBezierCurve.cpp" compile="1" resource="0"
|
||||
file="Source/shape/QuadraticBezierCurve.cpp"/>
|
||||
<FILE id="DB78dq" name="QuadraticBezierCurve.h" compile="0" resource="0"
|
||||
file="Source/shape/QuadraticBezierCurve.h"/>
|
||||
<FILE id="NrZ4bk" name="Shape.cpp" compile="1" resource="0" file="Source/shape/Shape.cpp"/>
|
||||
<FILE id="QmxyPg" name="Shape.h" compile="0" resource="0" file="Source/shape/Shape.h"/>
|
||||
</GROUP>
|
||||
<FILE id="bQ1rDR" name="TestMain.cpp" compile="1" resource="0" file="Source/TestMain.cpp"/>
|
||||
</GROUP>
|
||||
</MAINGROUP>
|
||||
|
|
Ładowanie…
Reference in New Issue