fixed hand tracking world position, and picking up objects in VR
[laserbrain_demo] / src / vrinput.cc
index d5692b8..6bb2aaa 100644 (file)
@@ -28,10 +28,18 @@ void destroy_vrhands()
 
 void update_vrhands(const Avatar *avatar)
 {
+       Quat qbodyrot;
+       qbodyrot.set_rotation(Vec3(0, 1, 0), -deg_to_rad(avatar->get_body_rotation()));
+       Vec3 pos = avatar->get_position();
+
        for(int i=0; i<2; i++) {
                if(goatvr_hand_active(i)) {
                        goatvr_hand_position(i, &vrhand[i].pos.x);
                        goatvr_hand_orientation(i, &vrhand[i].rot.x);
+
+                       vrhand[i].pos = rotate(vrhand[i].pos, qbodyrot) + pos;
+                       vrhand[i].rot = qbodyrot * vrhand[i].rot;
+
                        vrhand[i].valid = true;
                } else {
                        vrhand[i].valid = false;