fixed scale in VR
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Tue, 2 Aug 2016 01:37:55 +0000 (04:37 +0300)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Tue, 2 Aug 2016 01:37:55 +0000 (04:37 +0300)
src/app.cc
src/backdrop.cc
src/fs.cc
src/fs.h
src/icon.cc
src/opt.cc
src/opt.h

index 9b83c21..6ed9b8e 100644 (file)
@@ -71,7 +71,7 @@ bool app_init(int argc, char **argv)
                return false;
        }
 
-       if(!init_fs()) {
+       if(!init_fs(opt.path)) {
                return false;
        }
 
@@ -97,7 +97,7 @@ void app_draw()
                        goatvr_draw_eye(i);
 
                        glMatrixMode(GL_PROJECTION);
-                       glLoadMatrixf(goatvr_projection_matrix(i, 0.5, 1000.0));
+                       glLoadMatrixf(goatvr_projection_matrix(i, 0.1, 200.0));
 
                        view_matrix = goatvr_view_matrix(i);
                        view_matrix.pre_rotate_x(deg_to_rad(cam_phi));
@@ -147,7 +147,7 @@ void app_reshape(int x, int y)
        glViewport(0, 0, x, y);
 
        Mat4 mat;
-       mat.perspective(deg_to_rad(60), win_aspect, 0.5, 500.0);
+       mat.perspective(deg_to_rad(60), win_aspect, 0.1, 200.0);
 
        glMatrixMode(GL_PROJECTION);
        glLoadMatrixf(mat[0]);
index 2a11c97..de0df58 100644 (file)
@@ -47,7 +47,7 @@ bool init_backdrop()
        tex_grid->set_anisotropy(glcaps.max_aniso);
 
        mesh_skydome = new Mesh;
-       gen_sphere(mesh_skydome, 500.0, 32, 16, 1, 0.5);
+       gen_sphere(mesh_skydome, 100.0, 32, 16, 1, 0.5);
        mesh_skydome->flip();
 
        glClearColor(fog_color.x, fog_color.y, fog_color.z, 1.0);
index 0da07e5..a3e5b81 100644 (file)
--- a/src/fs.cc
+++ b/src/fs.cc
@@ -25,7 +25,7 @@ static dtx_font *fat_font;
 #define FAT_FONT_SZ    32
 
 
-bool init_fs()
+bool init_fs(const char *path)
 {
        iconrend = new ShapesIcons;
        if(!iconrend->init()) {
@@ -37,7 +37,7 @@ bool init_fs()
                return false;
        }
 
-       cur_node = get_fsnode(0);
+       cur_node = get_fsnode(path);
        cur_node->expand();
        return true;
 }
@@ -73,7 +73,7 @@ static float icon_angle(int col, int ncols, float max_angle = 0.0f)
 void draw_fs()
 {
        static const float row_spacing = 2.0;
-       static const float radius = 5;
+       static const float radius = 0.6;
        static const float umax = 0.42;
        static const float max_icon_angle = M_PI * 2.0 * umax;
 
@@ -82,7 +82,7 @@ void draw_fs()
        Mat4 base_xform;
        base_xform.rotate(time_sec, 0, 0);
        base_xform.rotate(0, 0, time_sec * 0.5);
-       base_xform.translate(0, 2, 0);
+       base_xform.translate(0, 1.65, 0);
 
        glUseProgram(0);
        glDisable(GL_TEXTURE_2D);
@@ -115,8 +115,8 @@ void draw_fs()
                glPushMatrix();
                xform = Mat4::identity;
                xform.translate(-dtx_string_width(node->path.get_name()) / 2.0, 0, 0);
-               xform.scale(0.01);
-               xform.translate(0, 1 + row * row_spacing, -radius);
+               xform.scale(0.001);
+               xform.translate(0, 1.54 + row * row_spacing, -radius);
                xform.rotate_y(angle);
                glMultMatrixf(xform[0]);
 
index 0eb72ed..c1b171e 100644 (file)
--- a/src/fs.h
+++ b/src/fs.h
@@ -27,7 +27,7 @@ public:
        bool expand();
 };
 
-bool init_fs();
+bool init_fs(const char *path = 0);
 void cleanup_fs();
 
 void draw_fs();
index ee7ccba..b6cefff 100644 (file)
@@ -45,18 +45,20 @@ ShapesIcons::~ShapesIcons()
 
 bool ShapesIcons::init()
 {
+       const float s = 0.12;
+
        for(int i=0; i<NUM_SHAPES; i++) {
                priv->shape[i] = new Mesh;
        }
 
        Mat4 xform;
 
-       gen_geosphere(priv->shape[SHAPE_SPHERE], 0.5, 0);
-       gen_box(priv->shape[SHAPE_BOX], 0.7, 0.7, 0.7);
-       gen_torus(priv->shape[SHAPE_TORUS], 0.4, 0.1, 12, 6);
+       gen_geosphere(priv->shape[SHAPE_SPHERE], 0.5 * s, 0);
+       gen_box(priv->shape[SHAPE_BOX], 0.7 * s, 0.7 * s, 0.7 * s);
+       gen_torus(priv->shape[SHAPE_TORUS], 0.4 * s, 0.1 * s, 12, 6);
 
-       gen_cone(priv->shape[SHAPE_CONE], 0.5, 1.0, 8, 2, 1);
-       xform.translation(0, -0.33, 0);
+       gen_cone(priv->shape[SHAPE_CONE], 0.5 * s, 1.0 * s, 8, 2, 1);
+       xform.translation(0, -0.33 * s, 0);
        priv->shape[SHAPE_CONE]->apply_xform(xform, Mat4::identity);
 
        return true;
index de3f5a3..6698f8c 100644 (file)
@@ -27,6 +27,7 @@ static optcfg_option options[] = {
 };
 
 static int opt_handler(optcfg *oc, int opt, void *cls);
+static int arg_handler(optcfg *oc, const char *arg, void *cls);
 
 bool init_options(int argc, char **argv, const char *cfgfile)
 {
@@ -38,6 +39,7 @@ bool init_options(int argc, char **argv, const char *cfgfile)
 
        optcfg *oc = optcfg_init(options);
        optcfg_set_opt_callback(oc, opt_handler, 0);
+       optcfg_set_arg_callback(oc, arg_handler, 0);
 
        if(cfgfile) {
                optcfg_parse_config_file(oc, cfgfile);
@@ -94,5 +96,15 @@ static int opt_handler(optcfg *oc, int optid, void *cls)
                optcfg_print_options(oc);
                exit(0);
        }
-       return true;
+       return 0;
+}
+
+static int arg_handler(optcfg *oc, const char *arg, void *cls)
+{
+       if(opt.path) {
+               fprintf(stderr, "unexpected argument: %s\n", arg);
+               return -1;
+       }
+       opt.path = arg;
+       return 0;
 }
index fc4d672..d47d8e3 100644 (file)
--- a/src/opt.h
+++ b/src/opt.h
@@ -6,6 +6,7 @@ struct Options {
        bool vr;
        bool srgb;
        bool fullscreen;
+       const char *path;
 };
 
 extern Options opt;