mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-08-14 01:28:02 +00:00
rewrite Scene class
This commit is contained in:
parent
9fcdfd2773
commit
630967a07f
2 changed files with 37 additions and 20 deletions
27
src/Scene.cc
27
src/Scene.cc
|
@ -1,18 +1,17 @@
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
|
|
||||||
Scene::Scene(const nlohmann::json &output) {
|
void Scene::setRaysPerPixel(const Eigen::VectorXi &raysPerPixel) {
|
||||||
for (auto i = output.begin(); i != output.end(); ++i) {
|
this->raysPerPixel = raysPerPixel;
|
||||||
if (i->contains("filename")) {
|
|
||||||
this->name = (*i)["filename"].get<string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i->contains("size")) {
|
|
||||||
this->width = (*i)["size"].at(0).get<int>();
|
|
||||||
this->height = (*i)["size"].at(1).get<int>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string Scene::getName() { return this->name; }
|
void Scene::setAntialiasing(bool antialiasing) {
|
||||||
int Scene::getWidth() { return this->width; }
|
this->antialiasing = antialiasing;
|
||||||
int Scene::getHeight() { return this->height; }
|
}
|
||||||
|
|
||||||
|
void Scene::setTwoSideRender(bool twoSideRender) {
|
||||||
|
this->twoSideRender = twoSideRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::setGlobalIllum(bool globalIllum) {
|
||||||
|
this->globalIllum = globalIllum;
|
||||||
|
}
|
||||||
|
|
30
src/Scene.h
30
src/Scene.h
|
@ -1,23 +1,41 @@
|
||||||
#ifndef SCENE_H_
|
#ifndef SCENE_H_
|
||||||
#define SCENE_H_
|
#define SCENE_H_
|
||||||
|
|
||||||
#include "../external/json.hpp"
|
#include <Eigen/Core>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
using Eigen::Vector3f;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
class Scene {
|
class Scene {
|
||||||
public:
|
public:
|
||||||
Scene(const nlohmann::json &);
|
Scene(string name, int width, int height, float fov, const Vector3f ¢er,
|
||||||
string getName();
|
const Vector3f &up, const Vector3f &lookAt, const Vector3f &ai,
|
||||||
int getWidth();
|
const Vector3f &bgc)
|
||||||
int getHeight();
|
: name(name), width(width), height(height), fov(fov), center(center),
|
||||||
|
up(up), lookAt(lookAt), ai(ai), backgroundColor(bgc) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string name;
|
string name;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
float fov;
|
||||||
|
Vector3f center;
|
||||||
|
Vector3f up;
|
||||||
|
Vector3f lookAt;
|
||||||
|
Vector3f ai; // ambient intensity
|
||||||
|
Vector3f backgroundColor;
|
||||||
|
|
||||||
|
Eigen::VectorXi raysPerPixel;
|
||||||
|
bool antialiasing = false;
|
||||||
|
bool twoSideRender = false;
|
||||||
|
bool globalIllum = false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setRaysPerPixel(const Eigen::VectorXi &);
|
||||||
|
void setAntialiasing(bool);
|
||||||
|
void setTwoSideRender(bool);
|
||||||
|
void setGlobalIllum(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !SCENE_H_
|
#endif // !SCENE_H_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue