diff --git a/src/camera.cc b/src/camera.cc index d064f16..413c036 100644 --- a/src/camera.cc +++ b/src/camera.cc @@ -123,6 +123,14 @@ Camera::LookAt(const Vector3& pt) mUp *= upLength; } + +void +Camera::WriteType(std::ostream& ost) + const +{ + ost << "UNKNOWN"; +} + #pragma mark - Perspective Camera PerspectiveCamera::PerspectiveCamera() @@ -155,6 +163,14 @@ PerspectiveCamera::compute_primary_ray(const int x, return Ray(GetOrigin(), direction.normalize()); } + +void +PerspectiveCamera::WriteType(std::ostream& ost) + const +{ + ost << "perspective"; +} + #pragma mark - Orthographic Camera OrthographicCamera::OrthographicCamera() @@ -195,3 +211,26 @@ OrthographicCamera::compute_primary_ray(const int x, y0, GetUp()); return Ray(origin, get_direction()); } + + +void +OrthographicCamera::WriteType(std::ostream& ost) + const +{ + ost << "orthographic"; +} + + +std::ostream& +operator<<(std::ostream& ost, + const Camera& camera) +{ + ost << "[Camera "; + camera.WriteType(ost); + ost << " origin=" << camera.mOrigin + << " direction=" << camera.mDirection + << " right=" << camera.mRight + << " up=" << camera.mUp + << "]"; + return ost; +} diff --git a/src/camera.h b/src/camera.h index 8008be6..b11c23e 100644 --- a/src/camera.h +++ b/src/camera.h @@ -66,6 +66,10 @@ private: * this and mRight determine the aspect ratio of the image. */ Vector3 mUp; + + virtual void WriteType(std::ostream& ost) const; + + friend std::ostream& operator<<(std::ostream& ost, const Camera& camera); }; @@ -78,6 +82,9 @@ public: Ray compute_primary_ray(const int x, const int width, const int y, const int height) const; + +private: + void WriteType(std::ostream& ost) const; }; @@ -90,7 +97,12 @@ public: Ray compute_primary_ray(const int x, const int width, const int y, const int height) const; + +private: + void WriteType(std::ostream& ost) const; }; +std::ostream& operator<<(std::ostream& ost, const Camera& camera); + #endif diff --git a/src/scene.cc b/src/scene.cc index acc8f38..aee639a 100644 --- a/src/scene.cc +++ b/src/scene.cc @@ -150,7 +150,9 @@ Scene::render() { LOG_INFO << "Rendering scene with " << shapes.size() << " objects."; printf("Rendering scene with %lu objects.\n", shapes.size()); + LogObjects(); + LogCamera(); std::chrono::time_point start, end; start = std::chrono::system_clock::now(); @@ -330,6 +332,14 @@ Scene::trace_ray(const Ray &ray, } +void +Scene::LogCamera() + const +{ + LOG_DEBUG << *mCamera; +} + + void Scene::LogObjects() const diff --git a/src/scene.h b/src/scene.h index 0dbeb6a..d8a86ad 100644 --- a/src/scene.h +++ b/src/scene.h @@ -53,6 +53,7 @@ public: private: Color trace_ray(const Ray &ray, const int depth = 0, const float weight = 1.0); + void LogCamera() const; void LogObjects() const; // Pixel dimensions of the image.