added messages to main/Scene, util/Matrix constructor sets matrix to identity
git-svn-id: svn://anubis/fart/trunk@37 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
c32e826ee3
commit
f03b19a022
@ -68,12 +68,28 @@ Scene::~Scene()
|
|||||||
void Scene::load(const char * filename)
|
void Scene::load(const char * filename)
|
||||||
{
|
{
|
||||||
/* TODO: parse file somehow */
|
/* 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()
|
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];
|
m_data = new unsigned char[m_width * m_height * 3];
|
||||||
|
|
||||||
for (int i = 0; i < m_height; i++)
|
for (int i = 0; i < m_height; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < m_width; j++)
|
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);
|
BMP outputImage(m_output_file_name.c_str(), m_width, m_height, m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ class Scene
|
|||||||
void render();
|
void render();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/* private methods */
|
||||||
void load(const char * filename);
|
void load(const char * filename);
|
||||||
void renderPixel(int x, int y, unsigned char * pixel);
|
void renderPixel(int x, int y, unsigned char * pixel);
|
||||||
|
|
||||||
@ -27,8 +28,9 @@ class Scene
|
|||||||
bool m_verbose;
|
bool m_verbose;
|
||||||
double m_vfov;
|
double m_vfov;
|
||||||
|
|
||||||
/* the shapes in the scene */
|
/* private data */
|
||||||
std::vector<Shape *> m_shapes;
|
std::vector<Shape *> m_shapes;
|
||||||
|
Transform m_transform;
|
||||||
|
|
||||||
/* framebuffer */
|
/* framebuffer */
|
||||||
unsigned char * m_data;
|
unsigned char * m_data;
|
||||||
|
@ -39,7 +39,7 @@ int main(int argc, char * argv[])
|
|||||||
{ NULL, 0, NULL, 0 }
|
{ 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)
|
long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
|
@ -8,6 +8,14 @@
|
|||||||
|
|
||||||
Matrix::Matrix()
|
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;
|
m_inverse_calculated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user