From 9aaed2d6e82904a10158e9137041d293be42661a Mon Sep 17 00:00:00 2001 From: vonhyou Date: Thu, 14 Mar 2024 18:54:57 -0400 Subject: [PATCH] reformat rt --- src/RayTracer.cc | 12 ++++++------ src/Scene.cc | 24 ++++++++++++------------ src/Scene.h | 46 +++++++++++++++++++++++----------------------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/RayTracer.cc b/src/RayTracer.cc index 6d877cf..c1081aa 100644 --- a/src/RayTracer.cc +++ b/src/RayTracer.cc @@ -43,11 +43,11 @@ void RayTracer::calculateColor(const HitRecord &hit, Output *buffer, int i) { } void RayTracer::render(Scene *scene) { - int width = scene->getWidth(); - int height = scene->getHeight(); - Vector3f cameraPos = scene->getCenter(); - Vector3f lookAt = scene->getLookAt(); - float vpHeight = 2 * tan(scene->getFov() / 180 * M_PI / 2) * lookAt.norm(); + int width = scene->width(); + int height = scene->height(); + Vector3f cameraPos = scene->center(); + Vector3f lookAt = scene->lookAt(); + float vpHeight = 2 * tan(scene->fov() / 180 * M_PI / 2) * lookAt.norm(); float vpWidth = vpHeight * width / height; Vector3f vpU = Vector3f(vpWidth, 0, 0); Vector3f vpV = Vector3f(0, -vpHeight, 0); @@ -58,7 +58,7 @@ void RayTracer::render(Scene *scene) { Vector3f pxUpperLeft = vpUpperLeft + (du + dv) / 2.0; Output *buffer = - new Output(scene->getBackgroundColor(), scene->getName(), width, height); + new Output(scene->backgroundColor(), scene->name(), width, height); for (int y = 0; y < height; ++y) for (int x = 0; x < width; ++x) { diff --git a/src/Scene.cc b/src/Scene.cc index 9c48128..fcc395f 100644 --- a/src/Scene.cc +++ b/src/Scene.cc @@ -1,33 +1,33 @@ #include "Scene.h" -string Scene::getName() const { return name; } +string Scene::name() const { return name_; } -int Scene::getWidth() { return width; } +int Scene::width() { return width_; } -int Scene::getHeight() { return height; } +int Scene::height() { return height_; } -float Scene::getFov() { return fov; } +float Scene::fov() { return fov_; } -Vector3f Scene::getCenter() const { return center; } +Vector3f Scene::center() const { return center_; } -Vector3f Scene::getUpVector() const { return up; } +Vector3f Scene::up() const { return up_; } -Vector3f Scene::getLookAt() const { return lookAt; } +Vector3f Scene::lookAt() const { return lookAt_; } -Vector3f Scene::getBackgroundColor() const { return backgroundColor; } +Vector3f Scene::backgroundColor() const { return bgc_; } void Scene::setRaysPerPixel(const Eigen::VectorXi &raysPerPixel) { - this->raysPerPixel = raysPerPixel; + this->raysPerPixel_ = raysPerPixel; } void Scene::setAntialiasing(bool antialiasing) { - this->antialiasing = antialiasing; + this->antialiasing_ = antialiasing; } void Scene::setTwoSideRender(bool twoSideRender) { - this->twoSideRender = twoSideRender; + this->twoSideRender_ = twoSideRender; } void Scene::setGlobalIllum(bool globalIllum) { - this->globalIllum = globalIllum; + this->globalIllum_ = globalIllum; } diff --git a/src/Scene.h b/src/Scene.h index 8ac10e0..0eecdce 100644 --- a/src/Scene.h +++ b/src/Scene.h @@ -12,34 +12,34 @@ public: Scene(string name, int width, int height, float fov, const Vector3f ¢er, const Vector3f &up, const Vector3f &lookAt, const Vector3f &ai, const Vector3f &bgc) - : name(name), width(width), height(height), fov(fov), center(center), - up(up), lookAt(lookAt), ai(ai), backgroundColor(bgc) {} + : name_(name), width_(width), height_(height), fov_(fov), center_(center), + up_(up), lookAt_(lookAt), ai_(ai), bgc_(bgc) {} private: - string name; - int width; - int height; - float fov; - Vector3f center; - Vector3f up; - Vector3f lookAt; - Vector3f ai; // ambient intensity - Vector3f backgroundColor; + string name_; + int width_; + int height_; + float fov_; + Vector3f center_; + Vector3f up_; + Vector3f lookAt_; + Vector3f ai_; // ambient intensity + Vector3f bgc_; - Eigen::VectorXi raysPerPixel; - bool antialiasing = false; - bool twoSideRender = false; - bool globalIllum = false; + Eigen::VectorXi raysPerPixel_; + bool antialiasing_ = false; + bool twoSideRender_ = false; + bool globalIllum_ = false; public: - string getName() const; - int getWidth(); - int getHeight(); - float getFov(); - Vector3f getCenter() const; - Vector3f getUpVector() const; - Vector3f getLookAt() const; - Vector3f getBackgroundColor() const; + string name() const; + int width(); + int height(); + float fov(); + Vector3f center() const; + Vector3f up() const; + Vector3f lookAt() const; + Vector3f backgroundColor() const; void setRaysPerPixel(const Eigen::VectorXi &); void setAntialiasing(bool); void setTwoSideRender(bool);