added minimum turn option, to discretize turns in VR
[laserbrain_demo] / src / opt.cc
index 18d73f2..15c61cc 100644 (file)
@@ -10,7 +10,11 @@ Options def_opt = {
        1280, 800,
        false,  // vr
        false,  // fullscreen
-       0               // scene file
+       0,              // scene file
+       true,   // music
+       true,   // reflections
+       0,              // data url
+       0.0f    // minimum turn angle
 };
 
 enum {
@@ -19,6 +23,10 @@ enum {
        OPT_FULLSCREEN,
        OPT_WINDOWED,
        OPT_SCENEFILE,
+       OPT_MUSIC,
+       OPT_REFLECT,
+       OPT_DATAURL,
+       OPT_MIN_TURN,
        OPT_HELP
 };
 
@@ -29,6 +37,10 @@ static optcfg_option options[] = {
        {'f', "fullscreen", OPT_FULLSCREEN, "run in fullscreen mode"},
        {'w', "windowed", OPT_WINDOWED, "run in windowed mode"},
        {0, "scene", OPT_SCENEFILE, "scene file to open"},
+       {'m', "music", OPT_MUSIC, "play background audio"},
+       {'r', "reflect", OPT_REFLECT, "render reflections"},
+       {0, "url", OPT_DATAURL, "data URL"},
+       {0, "minturn", OPT_MIN_TURN, "minimum turn angle"},
        {'h', "help", OPT_HELP, "print usage and exit"},
        OPTCFG_OPTIONS_END
 };
@@ -95,8 +107,33 @@ static int opt_handler(optcfg *oc, int optid, void *cls)
                opt.scenefile = strdup(optcfg_next_value(oc));
                break;
 
+       case OPT_MUSIC:
+               opt.music = is_enabled(oc);
+               break;
+
+       case OPT_REFLECT:
+               opt.reflect = is_enabled(oc);
+               break;
+
+       case OPT_DATAURL:
+               opt.data_url = strdup(optcfg_next_value(oc));
+               break;
+
+       case OPT_MIN_TURN:
+               {
+                       int deg;
+                       char *valstr = optcfg_next_value(oc);
+
+                       if(!valstr || sscanf(valstr, "%d", &deg) != 1) {
+                               fprintf(stderr, "minimum turn must be a number >= 0 in degrees\n");
+                               return -1;
+                       }
+                       opt.min_turn = deg;
+               }
+               break;
+
        case OPT_HELP:
-               printf("Usage: vrfileman [options]\nOptions:\n");
+               printf("Usage: demo [options]\nOptions:\n");
                optcfg_print_options(oc);
                exit(0);
        }