reformat rt

This commit is contained in:
Shuo Feng 2024-03-14 18:54:57 -04:00
parent 368039b57c
commit 9aaed2d6e8
Signed by: sfeng
GPG key ID: 1E83AE6CD1C037B1
3 changed files with 41 additions and 41 deletions

View file

@ -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) {

View file

@ -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;
}

View file

@ -12,34 +12,34 @@ public:
Scene(string name, int width, int height, float fov, const Vector3f &center,
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);