From a65c61e066fecc441ebf651987dc56deb78a4247 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sat, 20 Jan 2018 18:37:20 +0200 Subject: [PATCH] foo --- src/app.cc | 3 ++- src/ui_exhibit.cc | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/app.cc b/src/app.cc index b1587f5..7f173f3 100644 --- a/src/app.cc +++ b/src/app.cc @@ -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 } diff --git a/src/ui_exhibit.cc b/src/ui_exhibit.cc index dd09678..9b42c45 100644 --- a/src/ui_exhibit.cc +++ b/src/ui_exhibit.cc @@ -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); -- 1.7.10.4