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); 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 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 setVFOV(double vfov) { m_vfov = vfov; }
void setAmbientLight(const Color & al) { m_ambient_light = al; } void setAmbientLight(const Color & al) { m_ambient_light = al; }
void renderPixel(int x, int y, unsigned char * pixel); void renderPixel(int x, int y, unsigned char * pixel);
void setMaxDepth(int d) { m_max_depth = d; }
int getWidth() { return m_width; } int getWidth() { return m_width; }
int getHeight() { return m_height; } int getHeight() { return m_height; }
int getMultisampleLevel() { return m_multisample_level; } int getMultisampleLevel() { return m_multisample_level; }
int getAmbientOcclusionLevel() { return m_ambient_occlusion_level; } int getAmbientOcclusionLevel() { return m_ambient_occlusion_level; }
double getVFOV() { return m_vfov; } double getVFOV() { return m_vfov; }
int getMaxDepth() { return m_max_depth; }
protected: protected:
/* private methods */ /* private methods */

View File

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