foo
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 20 Jan 2018 16:37:20 +0000 (18:37 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 20 Jan 2018 16:37:20 +0000 (18:37 +0200)
src/app.cc
src/ui_exhibit.cc

index b1587f5..7f173f3 100644 (file)
@@ -362,8 +362,9 @@ static void update(float dt)
        if(have_handtracking) {
                update_vrhands(&avatar);
        } else {
+               // TODO do this properly
                // set the position of the left hand at a suitable position for the exhibit UI
-               Vec3 dir = transpose(mouse_view_matrix.upper3x3()) * Vec3(0, 0, -1);
+               dir = transpose(mouse_view_matrix.upper3x3()) * Vec3(-0.47, 0, -1);
                exslot_left.node.set_position(avatar.pos + dir * 30); // magic: distance in front
        }
 
index dd09678..9b42c45 100644 (file)
@@ -50,7 +50,7 @@ bool exui_init()
        ui_width = ui_height * aspect;
 
        rtarg = new RenderTarget;
-       if(!rtarg->create(ui_width, ui_height, GL_RGB)) {
+       if(!rtarg->create(ui_width, ui_height, GL_RGBA)) {
                error_log("failed to create exui render target\n");
                return false;
        }
@@ -116,7 +116,8 @@ static void draw_2d_ui()
        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
-       glOrtho(0, ui_width, 0, ui_height, -1, 1);
+       glTranslatef(-1, 1, 0);
+       glScalef(2.0 / ui_width, -2.0 / ui_height, 1);
 
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
@@ -161,10 +162,25 @@ void exui_draw()
        // place UI image into the scene
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
+
+       Mat4 mvmat;
+       glGetFloatv(GL_MODELVIEW_MATRIX, mvmat[0]);
+
+       /*
        if(parent) {
                glMultMatrixf(parent->get_matrix()[0]);
        }
        glTranslatef(pos.x, pos.y, pos.z);
+       */
+       if(parent) {
+               mvmat = parent->get_matrix() * mvmat;
+       }
+       mvmat.translate(pos.x, pos.y, pos.z);
+
+       mvmat[0][0] = mvmat[1][1] = mvmat[2][2] = 1.0f;
+       mvmat[0][1] = mvmat[0][2] = mvmat[1][0] = mvmat[2][0] = mvmat[1][2] = mvmat[2][1] = 0.0f;
+
+       glLoadMatrixf(mvmat[0]);
 
        glPushAttrib(GL_ENABLE_BIT);
        glEnable(GL_BLEND);