Rename Scene::camera -> mCamera
This commit is contained in:
parent
6f04526d36
commit
3ec5b20f16
2 changed files with 26 additions and 6 deletions
25
src/scene.cc
25
src/scene.cc
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
Scene::Scene()
|
Scene::Scene()
|
||||||
: width(640), height(480),
|
: width(640), height(480),
|
||||||
camera(new PerspectiveCamera()),
|
mCamera(new PerspectiveCamera()),
|
||||||
max_depth(5),
|
max_depth(5),
|
||||||
min_weight(1e-4),
|
min_weight(1e-4),
|
||||||
ambient(new AmbientLight()),
|
ambient(new AmbientLight()),
|
||||||
|
@ -31,9 +31,9 @@ Scene::Scene()
|
||||||
|
|
||||||
Scene::~Scene()
|
Scene::~Scene()
|
||||||
{
|
{
|
||||||
if (camera) {
|
if (mCamera) {
|
||||||
delete camera;
|
delete mCamera;
|
||||||
camera = NULL;
|
mCamera = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ambient != NULL) {
|
if (ambient != NULL) {
|
||||||
|
@ -81,6 +81,21 @@ Scene::get_height()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Camera*
|
||||||
|
Scene::GetCamera()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return mCamera;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Scene::SetCamera(Camera* camera)
|
||||||
|
{
|
||||||
|
mCamera = camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AmbientLight &
|
AmbientLight &
|
||||||
Scene::get_ambient()
|
Scene::get_ambient()
|
||||||
const
|
const
|
||||||
|
@ -136,7 +151,7 @@ Scene::render()
|
||||||
Vector3 o, d;
|
Vector3 o, d;
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
primary_ray = camera->compute_primary_ray(x, width, y, height);
|
primary_ray = mCamera->compute_primary_ray(x, width, y, height);
|
||||||
Color c = trace_ray(primary_ray);
|
Color c = trace_ray(primary_ray);
|
||||||
pixels[y * width + x] = c;
|
pixels[y * width + x] = c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,15 @@ public:
|
||||||
~Scene();
|
~Scene();
|
||||||
|
|
||||||
bool is_rendered() const;
|
bool is_rendered() const;
|
||||||
|
|
||||||
int get_width() const;
|
int get_width() const;
|
||||||
void set_width(int w) { width = w; }
|
void set_width(int w) { width = w; }
|
||||||
int get_height() const;
|
int get_height() const;
|
||||||
void set_height(int h) { height = h; }
|
void set_height(int h) { height = h; }
|
||||||
|
|
||||||
|
Camera* GetCamera() const;
|
||||||
|
void SetCamera(Camera* camera);
|
||||||
|
|
||||||
AmbientLight &get_ambient() const;
|
AmbientLight &get_ambient() const;
|
||||||
const Color *get_pixels() const;
|
const Color *get_pixels() const;
|
||||||
|
|
||||||
|
@ -50,7 +55,7 @@ private:
|
||||||
// Pixel dimensions of the image.
|
// Pixel dimensions of the image.
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
Camera *camera;
|
Camera *mCamera;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ray tracing parameters. max_depth indicates the maximum depth of the ray tree. min_weight indicates the minimum
|
* Ray tracing parameters. max_depth indicates the maximum depth of the ray tree. min_weight indicates the minimum
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue