X-Git-Url: http://git.treefish.org/~alex/seamulator.git/blobdiff_plain/721ef20fdcc8171b0cdcf7ee3402a0fb6eb37f46..6280f60567d99bd059818523fcdb0a710173b3d9:/src/seamulator.cpp diff --git a/src/seamulator.cpp b/src/seamulator.cpp index 92dfac6..ffbf586 100644 --- a/src/seamulator.cpp +++ b/src/seamulator.cpp @@ -1,20 +1,19 @@ #include #include +#include #include +#include #include #include "sea.h" #include "seaview.h" #include "watersurface.h" -const int LATTICE_SIZE{128}; -const double LATTICE_EXTEND{10}; const int INIT_WINDOW_POS_X{50}; const int INIT_WINDOW_POS_Y{50}; const int INIT_WINDOW_WIDTH{800}; const int INIT_WINDOW_HEIGHT{600}; -const double INIT_VIEW_DISTANCE{LATTICE_EXTEND * 1.5}; const double INIT_VIEW_AZIMUTH{0}; const double INIT_VIEW_ALTITUDE{M_PI / 4}; const char WINDOW_TITLE[]{"seamulator"}; @@ -23,18 +22,33 @@ SeaPtr sea; WaterSurfacePtr surface; std::unique_ptr seaView; +struct Settings { + double windSpeed; + int latticeSize; + double latticeExtend; + double amplitudeFactor; +}; + void glDisplayFunc(); void glReshapeFunc(int width, int height); void glMouseFunc(int button, int state, int x, int y); void glMotionFunc(int x, int y); +Settings parseArguments(int argc, char** argv); + +namespace po = boost::program_options; int main(int argc, char** argv) { - std::srand(std::time(0)); + Settings settings = parseArguments(argc, argv); - surface = std::make_shared(LATTICE_SIZE, LATTICE_EXTEND); - sea = std::make_shared(surface, 10, 0.0000001); - seaView = std::make_unique(INIT_VIEW_DISTANCE, INIT_VIEW_AZIMUTH, + std::srand(std::time(0)); + surface = std::make_shared(settings.latticeSize, + settings.latticeExtend); + sea = std::make_shared(surface, + settings.windSpeed, + settings.amplitudeFactor); + seaView = std::make_unique(settings.latticeExtend * 1.5, + INIT_VIEW_AZIMUTH, INIT_VIEW_ALTITUDE); glutInit(&argc, argv); @@ -54,6 +68,46 @@ int main(int argc, char** argv) return 0; } +Settings parseArguments(int argc, char** argv) +{ + po::options_description desc("Available options"); + desc.add_options() + ("help,h", "show this help") + ("windspeed,w", po::value()->default_value(10), + "wind speed (m/s)") + ("size,s", po::value()->default_value('s'), + "lattice size (s|l)") + ("amplitude,a", po::value()->default_value(1), + "amplitude multiplicator") + ; + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + exit(1); + } + + Settings settings; + + settings.windSpeed = vm["windspeed"].as(); + + if (vm["size"].as() == 'l') { + settings.latticeSize = 256; + settings.latticeExtend = 20; + settings.amplitudeFactor = vm["amplitude"].as() * 0.00000004; + } + else { + settings.latticeSize = 128; + settings.latticeExtend = 10; + settings.amplitudeFactor = vm["amplitude"].as() * 0.0000001; + } + + return settings; +} + void glDisplayFunc() { glClear(GL_COLOR_BUFFER_BIT);