d5692b8d94ca1bebe4acc45d9087f5ebef2ef33b
[laserbrain_demo] / src / vrinput.cc
1 #include <string.h>
2 #include <goatvr.h>
3 #include "vrinput.h"
4 #include "scene.h"
5 #include "shader.h"
6
7 VRHand vrhand[2];
8
9 static Scene *scn;
10
11 bool init_vrhands()
12 {
13         scn = new Scene;
14         if(!(scn->load("data/vrhands.obj"))) {
15                 return false;
16         }
17         scn->objects[0]->node->set_position(Vec3(0, 150, 0));
18         scn->objects[1]->node->set_position(Vec3(0, 250, 0));
19         scn->update(0);
20         return true;
21 }
22
23 void destroy_vrhands()
24 {
25         delete scn;
26         scn = 0;
27 }
28
29 void update_vrhands(const Avatar *avatar)
30 {
31         for(int i=0; i<2; i++) {
32                 if(goatvr_hand_active(i)) {
33                         goatvr_hand_position(i, &vrhand[i].pos.x);
34                         goatvr_hand_orientation(i, &vrhand[i].rot.x);
35                         vrhand[i].valid = true;
36                 } else {
37                         vrhand[i].valid = false;
38                 }
39         }
40
41         scn->update(0);
42 }
43
44 void draw_vrhands()
45 {
46         bind_shader(0);
47         scn->draw();
48 }