added --field-of-view and m_vfov to Scene

git-svn-id: svn://anubis/fart/trunk@36 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-01-23 14:43:49 +00:00
parent 73cdd1a5a1
commit c32e826ee3
4 changed files with 24 additions and 2 deletions

View File

@ -15,6 +15,7 @@ Scene::Scene(map<string, const char *> options,
m_height = 600; m_height = 600;
m_multisample_level = 1; m_multisample_level = 1;
m_output_file_name = "fart.bmp"; m_output_file_name = "fart.bmp";
m_vfov = 60.0;
m_verbose = false; m_verbose = false;
m_data = NULL; m_data = NULL;
@ -37,6 +38,10 @@ Scene::Scene(map<string, const char *> options,
{ {
m_multisample_level = atoi(it->second); m_multisample_level = atoi(it->second);
} }
else if (it->first == "field-of-view")
{
m_vfov = atof(it->second);
}
else if (it->first == "output-file") else if (it->first == "output-file")
{ {
m_output_file_name = it->second; m_output_file_name = it->second;

View File

@ -19,13 +19,19 @@ class Scene
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);
/* rendering parameters */
int m_width; int m_width;
int m_height; int m_height;
int m_multisample_level; int m_multisample_level;
std::string m_output_file_name; std::string m_output_file_name;
bool m_verbose; bool m_verbose;
unsigned char * m_data; double m_vfov;
/* the shapes in the scene */
std::vector<Shape *> m_shapes; std::vector<Shape *> m_shapes;
/* framebuffer */
unsigned char * m_data;
}; };
#endif #endif

View File

@ -17,6 +17,7 @@ void usage(const char * progname)
cout << " -w|--width <image-width>" << endl; cout << " -w|--width <image-width>" << endl;
cout << " -h|--height <image-height>" << endl; cout << " -h|--height <image-height>" << endl;
cout << " -m|--multisample <level>" << endl; cout << " -m|--multisample <level>" << endl;
cout << " -f|--field-of-view <vertical-fov>" << endl;
cout << " -v|--verbose" << endl; cout << " -v|--verbose" << endl;
exit(42); exit(42);
} }
@ -33,11 +34,12 @@ int main(int argc, char * argv[])
{ "width", required_argument, NULL, 'w' }, { "width", required_argument, NULL, 'w' },
{ "height", required_argument, NULL, 'h' }, { "height", required_argument, NULL, 'h' },
{ "multisample", required_argument, NULL, 'm' }, { "multisample", required_argument, NULL, 'm' },
{ "field-of-view", required_argument, NULL, 'f' },
{ "verbose", no_argument, NULL, 'v' }, { "verbose", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
while ((opt = getopt_long(argc, argv, "o:w:h:m:", while ((opt = getopt_long(argc, argv, "o:w:h:m:f:",
long_options, &option_index)) != -1) long_options, &option_index)) != -1)
{ {
switch (opt) switch (opt)
@ -57,6 +59,9 @@ int main(int argc, char * argv[])
case 'm': case 'm':
scene_options["multisample"] = optarg; scene_options["multisample"] = optarg;
break; break;
case 'f':
scene_options["field-of-view"] = optarg;
break;
case 'v': case 'v':
scene_options["verbose"] = optarg; scene_options["verbose"] = optarg;
break; break;

View File

@ -4,11 +4,17 @@
#include "util/Solver.h" #include "util/Solver.h"
#include "util/Ray.h" #include "util/Ray.h"
#include "util/Transform.h"
class Shape class Shape
{ {
public: public:
virtual Solver::Result intersect(const Ray & ray) = 0; virtual Solver::Result intersect(const Ray & ray) = 0;
void setTransform(const Transform & t) { m_transform = t; }
Transform & getTransform() { return m_transform; }
protected:
Transform m_transform;
}; };
#endif #endif