added command-line options --ambient-occlusion and --preview, console displays max depth parameter

git-svn-id: svn://anubis/fart/trunk@282 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2010-07-09 16:18:51 +00:00
parent 17d69c54ce
commit 340742d27b
3 changed files with 37 additions and 13 deletions

View File

@ -60,6 +60,10 @@ Scene::Scene(const map<string, const char *> & options,
{
m_max_depth = atoi(it->second);
}
else if (it->first == "ambient-occlusion")
{
m_ambient_occlusion_level = atoi(it->second);
}
}
/* view plane distance is calculated based on the field of view */

View File

@ -35,11 +35,13 @@ class Scene
void setVFOV(double vfov) { m_vfov = vfov; }
void setAmbientLight(const Color & al) { m_ambient_light = al; }
void renderPixel(int x, int y, unsigned char * pixel);
void setMaxDepth(int d) { m_max_depth = d; }
int getWidth() { return m_width; }
int getHeight() { return m_height; }
int getMultisampleLevel() { return m_multisample_level; }
int getAmbientOcclusionLevel() { return m_ambient_occlusion_level; }
double getVFOV() { return m_vfov; }
int getMaxDepth() { return m_max_depth; }
protected:
/* private methods */

View File

@ -26,6 +26,8 @@ void usage(const char * progname)
cout << " -m|--multisample <level>" << endl;
cout << " -f|--field-of-view <vertical-fov>" << endl;
cout << " -d|--max-depth <max-recursion-depth>" << endl;
cout << " -a|--ambient-occlusion <ambient-occlusion-level>" << endl;
cout << " -p|--preview (means -w400 -h300 -m1 -d8 -a0)" << endl;
cout << " --hosts <hosts-file>" << endl;
exit(42);
}
@ -90,25 +92,32 @@ int main(int argc, char * argv[])
bool child = false;
static const struct option long_options[] = {
{ "output-file", required_argument, NULL, 'o' },
{ "width", required_argument, NULL, 'w' },
{ "height", required_argument, NULL, 'h' },
{ "multisample", required_argument, NULL, 'm' },
{ "field-of-view", required_argument, NULL, 'f' },
{ "max-depth", required_argument, NULL, 'd' },
{ "help", no_argument, NULL, 256 },
{ "host", required_argument, NULL, 257 },
{ "port", required_argument, NULL, 258 },
{ "hosts", required_argument, NULL, 259 },
{ "child", no_argument, NULL, 260 },
{ NULL, 0, NULL, 0 }
{ "ambient-occlusion", required_argument, NULL, 'a' },
{ "output-file", required_argument, NULL, 'o' },
{ "width", required_argument, NULL, 'w' },
{ "height", required_argument, NULL, 'h' },
{ "multisample", required_argument, NULL, 'm' },
{ "field-of-view", required_argument, NULL, 'f' },
{ "max-depth", required_argument, NULL, 'd' },
{ "preview", no_argument, NULL, 'p' },
{ "help", no_argument, NULL, 256 },
{ "host", required_argument, NULL, 257 },
{ "port", required_argument, NULL, 258 },
{ "hosts", required_argument, NULL, 259 },
{ "child", no_argument, NULL, 260 },
{ NULL, 0, NULL, 0 }
};
while ((opt = getopt_long(argc, argv, "o:w:h:m:f:d:",
while ((opt = getopt_long(argc, argv, "a:o:w:h:m:f:d:p",
long_options, &option_index)) != -1)
{
switch (opt)
{
case 'a':
scene_options["ambient-occlusion"] = optarg;
client_options.push_back("--ambient-occlusion");
client_options.push_back(optarg);
break;
case 'o':
output_file_name = optarg;
break;
@ -137,6 +146,14 @@ int main(int argc, char * argv[])
client_options.push_back("--max-depth");
client_options.push_back(optarg);
break;
case 'p':
scene_options["ambient-occlusion"] = "0";
scene_options["width"] = "400";
scene_options["height"] = "300";
scene_options["multisample"] = "1";
scene_options["max-depth"] = "8";
client_options.push_back("--preview");
break;
case 256:
usage(argv[0]);
break;
@ -189,6 +206,7 @@ int main(int argc, char * argv[])
cout << " Multisample Level: " << scene.getMultisampleLevel() << endl;
cout << " Ambient Occlusion Level: " << scene.getAmbientOcclusionLevel() << endl;
cout << " Vertical Field of View: " << scene.getVFOV() << endl;
cout << " Max Depth: " << scene.getMaxDepth() << endl;
cout << "----------------------------------------" << endl;
}