#include "opt.h"
#include "post.h"
#include "renderer.h"
+#include "vrinput.h"
#include "exman.h"
#include "blob_exhibit.h"
static float mouse_speed = 0.5f;
static bool show_walk_mesh, noclip = false;
-static bool have_headtracking, should_swap;
+static bool have_headtracking, have_handtracking, should_swap;
static int prev_mx, prev_my;
static bool bnstate[8];
should_swap = goatvr_should_swap() != 0;
user_eye_height = goatvr_get_eye_height();
have_headtracking = goatvr_have_headtracking();
+ have_handtracking = goatvr_have_handtracking();
goatvr_recenter();
}
glClearColor(1, 1, 1, 1);
+ if(!init_vrhands()) {
+ return false;
+ }
+
mscn = new MetaScene;
if(!mscn->load(opt.scenefile ? opt.scenefile : "data/museum.scene")) {
return false;
if(opt.vr) {
goatvr_shutdown();
}
+ destroy_vrhands();
delete rend;
}
mouse_view_matrix.pre_rotate_y(deg_to_rad(cam_theta));
mouse_view_matrix.pre_translate(-cam_pos.x, -cam_pos.y, -cam_pos.z);
+
+ // update hand-tracking
+ if(have_handtracking) {
+ update_vrhands();
+ }
}
static void set_light(int idx, const Vec3 &pos, const Vec3 &color)
glLoadMatrixf(view_matrix[0]);
draw_scene();
+ draw_vrhands();
}
goatvr_draw_done();
--- /dev/null
+#include <string.h>
+#include "vrinput.h"
+#include "scene.h"
+
+VRHand vrhand[2];
+
+static Scene *scn;
+
+bool init_vrhands()
+{
+ scn = new Scene;
+ if(!(scn->load("data/vrhands.obj"))) {
+ return false;
+ }
+ return true;
+}
+
+void destroy_vrhands()
+{
+ delete scn;
+ scn = 0;
+}
+
+void update_vrhands()
+{
+ for(int i=0; i<2; i++) {
+ if(!(vrhand[i].src = goatvr_get_hand_tracker(i))) {
+ vrhand[i].valid = false;
+ continue;
+ }
+ goatvr_source_position(vrhand[i].src, &vrhand[i].pos.x);
+ goatvr_source_orientation(vrhand[i].src, &vrhand[i].rot.x);
+ float *mat = goatvr_source_matrix(vrhand[i].src);
+ memcpy(vrhand[i].xform[0], mat, 16 * sizeof(float));
+ vrhand[i].valid = true;
+ }
+}
+
+void draw_vrhands()
+{
+}