diff --git a/main/Scene.cc b/main/Scene.cc index 3cde950..ba0aef8 100644 --- a/main/Scene.cc +++ b/main/Scene.cc @@ -68,12 +68,28 @@ Scene::~Scene() void Scene::load(const char * filename) { /* TODO: parse file somehow */ - m_shapes.push_back(new Sphere(2.0)); + Shape * shape = new Sphere(2.0); + m_transform.translate(2.0, 6.0, 1.0); + shape->setTransform(m_transform); + m_shapes.push_back(shape); } void Scene::render() { + if (m_verbose) + { + cout << " *** Beginning scene render ***" << endl; + cout << "Parameters:" << endl; + cout << "----------------------------------------" << endl; + cout << " Width: " << m_width << endl; + cout << " Height: " << m_height << endl; + cout << " Multisample Level: " << m_multisample_level << endl; + cout << " Vertical Field of View: " << m_vfov << endl; + cout << "----------------------------------------" << endl; + } + m_data = new unsigned char[m_width * m_height * 3]; + for (int i = 0; i < m_height; i++) { for (int j = 0; j < m_width; j++) @@ -82,6 +98,11 @@ void Scene::render() } } + if (m_verbose) + { + cout << " *** Ending scene render ***" << endl; + cout << "Writing output file '" << m_output_file_name << '\'' << endl; + } BMP outputImage(m_output_file_name.c_str(), m_width, m_height, m_data); } diff --git a/main/Scene.h b/main/Scene.h index ad29b8f..8003c8d 100755 --- a/main/Scene.h +++ b/main/Scene.h @@ -16,6 +16,7 @@ class Scene void render(); private: + /* private methods */ void load(const char * filename); void renderPixel(int x, int y, unsigned char * pixel); @@ -27,8 +28,9 @@ class Scene bool m_verbose; double m_vfov; - /* the shapes in the scene */ + /* private data */ std::vector m_shapes; + Transform m_transform; /* framebuffer */ unsigned char * m_data; diff --git a/main/fart.cc b/main/fart.cc index f00ae65..ac52090 100644 --- a/main/fart.cc +++ b/main/fart.cc @@ -39,7 +39,7 @@ int main(int argc, char * argv[]) { NULL, 0, NULL, 0 } }; - while ((opt = getopt_long(argc, argv, "o:w:h:m:f:", + while ((opt = getopt_long(argc, argv, "o:w:h:m:f:v", long_options, &option_index)) != -1) { switch (opt) diff --git a/util/Matrix.cc b/util/Matrix.cc index 39a9ae3..b6e36bc 100644 --- a/util/Matrix.cc +++ b/util/Matrix.cc @@ -8,6 +8,14 @@ Matrix::Matrix() { + /* set matrix to the identity matrix */ + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + { + m_matrix[i][j] = i == j ? 1.0 : 0.0; + } + } m_inverse_calculated = false; }