arvr_nodes.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. /*************************************************************************/
  2. /* arvr_nodes.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "arvr_nodes.h"
  31. #include "core/os/input.h"
  32. #include "servers/arvr/arvr_interface.h"
  33. #include "servers/arvr_server.h"
  34. ////////////////////////////////////////////////////////////////////////////////////////////////////
  35. void ARVRCamera::_notification(int p_what) {
  36. switch (p_what) {
  37. case NOTIFICATION_ENTER_TREE: {
  38. // need to find our ARVROrigin parent and let it know we're its camera!
  39. ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
  40. if (origin != NULL) {
  41. origin->set_tracked_camera(this);
  42. }
  43. }; break;
  44. case NOTIFICATION_EXIT_TREE: {
  45. // need to find our ARVROrigin parent and let it know we're no longer its camera!
  46. ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
  47. if (origin != NULL) {
  48. origin->clear_tracked_camera_if(this);
  49. }
  50. }; break;
  51. };
  52. };
  53. String ARVRCamera::get_configuration_warning() const {
  54. if (!is_visible() || !is_inside_tree())
  55. return String();
  56. // must be child node of ARVROrigin!
  57. ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
  58. if (origin == NULL) {
  59. return TTR("ARVRCamera must have an ARVROrigin node as its parent");
  60. };
  61. return String();
  62. };
  63. Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const {
  64. // get our ARVRServer
  65. ARVRServer *arvr_server = ARVRServer::get_singleton();
  66. ERR_FAIL_NULL_V(arvr_server, Vector3());
  67. Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
  68. ERR_FAIL_COND_V(arvr_interface.is_null(), Vector3());
  69. if (!is_inside_tree()) {
  70. ERR_EXPLAIN("Camera is not inside scene.");
  71. ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
  72. };
  73. Size2 viewport_size = get_viewport()->get_camera_rect_size();
  74. Vector2 cpos = get_viewport()->get_camera_coords(p_pos);
  75. Vector3 ray;
  76. CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
  77. float screen_w, screen_h;
  78. cm.get_viewport_size(screen_w, screen_h);
  79. ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_w, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_h, -get_znear()).normalized();
  80. return ray;
  81. };
  82. Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const {
  83. // get our ARVRServer
  84. ARVRServer *arvr_server = ARVRServer::get_singleton();
  85. ERR_FAIL_NULL_V(arvr_server, Vector2());
  86. Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
  87. ERR_FAIL_COND_V(arvr_interface.is_null(), Vector2());
  88. if (!is_inside_tree()) {
  89. ERR_EXPLAIN("Camera is not inside scene.");
  90. ERR_FAIL_COND_V(!is_inside_tree(), Vector2());
  91. };
  92. Size2 viewport_size = get_viewport()->get_visible_rect().size;
  93. CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
  94. Plane p(get_camera_transform().xform_inv(p_pos), 1.0);
  95. p = cm.xform4(p);
  96. p.normal /= p.d;
  97. Point2 res;
  98. res.x = (p.normal.x * 0.5 + 0.5) * viewport_size.x;
  99. res.y = (-p.normal.y * 0.5 + 0.5) * viewport_size.y;
  100. return res;
  101. };
  102. Vector3 ARVRCamera::project_position(const Point2 &p_point) const {
  103. // get our ARVRServer
  104. ARVRServer *arvr_server = ARVRServer::get_singleton();
  105. ERR_FAIL_NULL_V(arvr_server, Vector3());
  106. Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
  107. ERR_FAIL_COND_V(arvr_interface.is_null(), Vector3());
  108. if (!is_inside_tree()) {
  109. ERR_EXPLAIN("Camera is not inside scene.");
  110. ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
  111. };
  112. Size2 viewport_size = get_viewport()->get_visible_rect().size;
  113. CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
  114. Size2 vp_size;
  115. cm.get_viewport_size(vp_size.x, vp_size.y);
  116. Vector2 point;
  117. point.x = (p_point.x / viewport_size.x) * 2.0 - 1.0;
  118. point.y = (1.0 - (p_point.y / viewport_size.y)) * 2.0 - 1.0;
  119. point *= vp_size;
  120. Vector3 p(point.x, point.y, -get_znear());
  121. return get_camera_transform().xform(p);
  122. };
  123. Vector<Plane> ARVRCamera::get_frustum() const {
  124. // get our ARVRServer
  125. ARVRServer *arvr_server = ARVRServer::get_singleton();
  126. ERR_FAIL_NULL_V(arvr_server, Vector<Plane>());
  127. Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
  128. ERR_FAIL_COND_V(arvr_interface.is_null(), Vector<Plane>());
  129. ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>());
  130. Size2 viewport_size = get_viewport()->get_visible_rect().size;
  131. CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
  132. return cm.get_projection_planes(get_camera_transform());
  133. };
  134. ARVRCamera::ARVRCamera(){
  135. // nothing to do here yet for now..
  136. };
  137. ARVRCamera::~ARVRCamera(){
  138. // nothing to do here yet for now..
  139. };
  140. ////////////////////////////////////////////////////////////////////////////////////////////////////
  141. void ARVRController::_notification(int p_what) {
  142. switch (p_what) {
  143. case NOTIFICATION_ENTER_TREE: {
  144. set_process_internal(true);
  145. }; break;
  146. case NOTIFICATION_EXIT_TREE: {
  147. set_process_internal(false);
  148. }; break;
  149. case NOTIFICATION_INTERNAL_PROCESS: {
  150. // get our ARVRServer
  151. ARVRServer *arvr_server = ARVRServer::get_singleton();
  152. ERR_FAIL_NULL(arvr_server);
  153. // find the tracker for our controller
  154. ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
  155. if (tracker == NULL) {
  156. // this controller is currently turned off
  157. is_active = false;
  158. button_states = 0;
  159. } else {
  160. is_active = true;
  161. set_transform(tracker->get_transform(true));
  162. int joy_id = tracker->get_joy_id();
  163. if (joy_id >= 0) {
  164. int mask = 1;
  165. // check button states
  166. for (int i = 0; i < 16; i++) {
  167. bool was_pressed = (button_states & mask) == mask;
  168. bool is_pressed = Input::get_singleton()->is_joy_button_pressed(joy_id, i);
  169. if (!was_pressed && is_pressed) {
  170. emit_signal("button_pressed", i);
  171. button_states += mask;
  172. } else if (was_pressed && !is_pressed) {
  173. emit_signal("button_release", i);
  174. button_states -= mask;
  175. };
  176. mask = mask << 1;
  177. };
  178. } else {
  179. button_states = 0;
  180. };
  181. };
  182. }; break;
  183. default:
  184. break;
  185. };
  186. };
  187. void ARVRController::_bind_methods() {
  188. ClassDB::bind_method(D_METHOD("set_controller_id", "controller_id"), &ARVRController::set_controller_id);
  189. ClassDB::bind_method(D_METHOD("get_controller_id"), &ARVRController::get_controller_id);
  190. ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_controller_id", "get_controller_id");
  191. ClassDB::bind_method(D_METHOD("get_controller_name"), &ARVRController::get_controller_name);
  192. // passthroughs to information about our related joystick
  193. ClassDB::bind_method(D_METHOD("get_joystick_id"), &ARVRController::get_joystick_id);
  194. ClassDB::bind_method(D_METHOD("is_button_pressed", "button"), &ARVRController::is_button_pressed);
  195. ClassDB::bind_method(D_METHOD("get_joystick_axis", "axis"), &ARVRController::get_joystick_axis);
  196. ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRController::get_is_active);
  197. ClassDB::bind_method(D_METHOD("get_hand"), &ARVRController::get_hand);
  198. ClassDB::bind_method(D_METHOD("get_rumble"), &ARVRController::get_rumble);
  199. ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &ARVRController::set_rumble);
  200. ADD_PROPERTY(PropertyInfo(Variant::REAL, "rumble", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_rumble", "get_rumble");
  201. ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::INT, "button")));
  202. ADD_SIGNAL(MethodInfo("button_release", PropertyInfo(Variant::INT, "button")));
  203. };
  204. void ARVRController::set_controller_id(int p_controller_id) {
  205. // We don't check any bounds here, this controller may not yet be active and just be a place holder until it is.
  206. // Note that setting this to 0 means this node is not bound to a controller yet.
  207. controller_id = p_controller_id;
  208. };
  209. int ARVRController::get_controller_id(void) const {
  210. return controller_id;
  211. };
  212. String ARVRController::get_controller_name(void) const {
  213. // get our ARVRServer
  214. ARVRServer *arvr_server = ARVRServer::get_singleton();
  215. ERR_FAIL_NULL_V(arvr_server, String());
  216. ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
  217. if (tracker == NULL) {
  218. return String("Not connected");
  219. };
  220. return tracker->get_name();
  221. };
  222. int ARVRController::get_joystick_id() const {
  223. // get our ARVRServer
  224. ARVRServer *arvr_server = ARVRServer::get_singleton();
  225. ERR_FAIL_NULL_V(arvr_server, 0);
  226. ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
  227. if (tracker == NULL) {
  228. return 0;
  229. };
  230. return tracker->get_joy_id();
  231. };
  232. int ARVRController::is_button_pressed(int p_button) const {
  233. int joy_id = get_joystick_id();
  234. if (joy_id == -1) {
  235. return false;
  236. };
  237. return Input::get_singleton()->is_joy_button_pressed(joy_id, p_button);
  238. };
  239. float ARVRController::get_joystick_axis(int p_axis) const {
  240. int joy_id = get_joystick_id();
  241. if (joy_id == -1) {
  242. return 0.0;
  243. };
  244. return Input::get_singleton()->get_joy_axis(joy_id, p_axis);
  245. };
  246. real_t ARVRController::get_rumble() const {
  247. // get our ARVRServer
  248. ARVRServer *arvr_server = ARVRServer::get_singleton();
  249. ERR_FAIL_NULL_V(arvr_server, 0.0);
  250. ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
  251. if (tracker == NULL) {
  252. return 0.0;
  253. };
  254. return tracker->get_rumble();
  255. };
  256. void ARVRController::set_rumble(real_t p_rumble) {
  257. // get our ARVRServer
  258. ARVRServer *arvr_server = ARVRServer::get_singleton();
  259. ERR_FAIL_NULL(arvr_server);
  260. ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
  261. if (tracker != NULL) {
  262. tracker->set_rumble(p_rumble);
  263. };
  264. };
  265. bool ARVRController::get_is_active() const {
  266. return is_active;
  267. };
  268. ARVRPositionalTracker::TrackerHand ARVRController::get_hand() const {
  269. // get our ARVRServer
  270. ARVRServer *arvr_server = ARVRServer::get_singleton();
  271. ERR_FAIL_NULL_V(arvr_server, ARVRPositionalTracker::TRACKER_HAND_UNKNOWN);
  272. ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
  273. if (tracker == NULL) {
  274. return ARVRPositionalTracker::TRACKER_HAND_UNKNOWN;
  275. };
  276. return tracker->get_hand();
  277. };
  278. String ARVRController::get_configuration_warning() const {
  279. if (!is_visible() || !is_inside_tree())
  280. return String();
  281. // must be child node of ARVROrigin!
  282. ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
  283. if (origin == NULL) {
  284. return TTR("ARVRController must have an ARVROrigin node as its parent");
  285. };
  286. if (controller_id == 0) {
  287. return TTR("The controller id must not be 0 or this controller will not be bound to an actual controller");
  288. };
  289. return String();
  290. };
  291. ARVRController::ARVRController() {
  292. controller_id = 0;
  293. is_active = true;
  294. button_states = 0;
  295. };
  296. ARVRController::~ARVRController(){
  297. // nothing to do here yet for now..
  298. };
  299. ////////////////////////////////////////////////////////////////////////////////////////////////////
  300. void ARVRAnchor::_notification(int p_what) {
  301. switch (p_what) {
  302. case NOTIFICATION_ENTER_TREE: {
  303. set_process_internal(true);
  304. }; break;
  305. case NOTIFICATION_EXIT_TREE: {
  306. set_process_internal(false);
  307. }; break;
  308. case NOTIFICATION_INTERNAL_PROCESS: {
  309. // get our ARVRServer
  310. ARVRServer *arvr_server = ARVRServer::get_singleton();
  311. ERR_FAIL_NULL(arvr_server);
  312. // find the tracker for our anchor
  313. ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id);
  314. if (tracker == NULL) {
  315. // this anchor is currently not available
  316. is_active = false;
  317. } else {
  318. is_active = true;
  319. Transform transform;
  320. // we'll need our world_scale
  321. real_t world_scale = arvr_server->get_world_scale();
  322. // get our info from our tracker
  323. transform.basis = tracker->get_orientation();
  324. transform.origin = tracker->get_position(); // <-- already adjusted to world scale
  325. // our basis is scaled to the size of the plane the anchor is tracking
  326. // extract the size from our basis and reset the scale
  327. size = transform.basis.get_scale() * world_scale;
  328. transform.basis.orthonormalize();
  329. // apply our reference frame and set our transform
  330. set_transform(arvr_server->get_reference_frame() * transform);
  331. };
  332. }; break;
  333. default:
  334. break;
  335. };
  336. };
  337. void ARVRAnchor::_bind_methods() {
  338. ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &ARVRAnchor::set_anchor_id);
  339. ClassDB::bind_method(D_METHOD("get_anchor_id"), &ARVRAnchor::get_anchor_id);
  340. ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_anchor_id", "get_anchor_id");
  341. ClassDB::bind_method(D_METHOD("get_anchor_name"), &ARVRAnchor::get_anchor_name);
  342. ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRAnchor::get_is_active);
  343. ClassDB::bind_method(D_METHOD("get_size"), &ARVRAnchor::get_size);
  344. ClassDB::bind_method(D_METHOD("get_plane"), &ARVRAnchor::get_plane);
  345. };
  346. void ARVRAnchor::set_anchor_id(int p_anchor_id) {
  347. // We don't check any bounds here, this anchor may not yet be active and just be a place holder until it is.
  348. // Note that setting this to 0 means this node is not bound to an anchor yet.
  349. anchor_id = p_anchor_id;
  350. };
  351. int ARVRAnchor::get_anchor_id(void) const {
  352. return anchor_id;
  353. };
  354. Vector3 ARVRAnchor::get_size() const {
  355. return size;
  356. };
  357. String ARVRAnchor::get_anchor_name(void) const {
  358. // get our ARVRServer
  359. ARVRServer *arvr_server = ARVRServer::get_singleton();
  360. ERR_FAIL_NULL_V(arvr_server, String());
  361. ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id);
  362. if (tracker == NULL) {
  363. return String("Not connected");
  364. };
  365. return tracker->get_name();
  366. };
  367. bool ARVRAnchor::get_is_active() const {
  368. return is_active;
  369. };
  370. String ARVRAnchor::get_configuration_warning() const {
  371. if (!is_visible() || !is_inside_tree())
  372. return String();
  373. // must be child node of ARVROrigin!
  374. ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
  375. if (origin == NULL) {
  376. return TTR("ARVRAnchor must have an ARVROrigin node as its parent");
  377. };
  378. if (anchor_id == 0) {
  379. return TTR("The anchor id must not be 0 or this anchor will not be bound to an actual anchor");
  380. };
  381. return String();
  382. };
  383. Plane ARVRAnchor::get_plane() const {
  384. Vector3 location = get_translation();
  385. Basis orientation = get_transform().basis;
  386. Plane plane(location, orientation.get_axis(1).normalized());
  387. return plane;
  388. };
  389. ARVRAnchor::ARVRAnchor() {
  390. anchor_id = 0;
  391. is_active = true;
  392. };
  393. ARVRAnchor::~ARVRAnchor(){
  394. // nothing to do here yet for now..
  395. };
  396. ////////////////////////////////////////////////////////////////////////////////////////////////////
  397. String ARVROrigin::get_configuration_warning() const {
  398. if (!is_visible() || !is_inside_tree())
  399. return String();
  400. if (tracked_camera == NULL)
  401. return TTR("ARVROrigin requires an ARVRCamera child node");
  402. return String();
  403. };
  404. void ARVROrigin::_bind_methods() {
  405. ClassDB::bind_method(D_METHOD("set_world_scale", "world_scale"), &ARVROrigin::set_world_scale);
  406. ClassDB::bind_method(D_METHOD("get_world_scale"), &ARVROrigin::get_world_scale);
  407. ADD_PROPERTY(PropertyInfo(Variant::REAL, "world_scale"), "set_world_scale", "get_world_scale");
  408. };
  409. void ARVROrigin::set_tracked_camera(ARVRCamera *p_tracked_camera) {
  410. tracked_camera = p_tracked_camera;
  411. };
  412. void ARVROrigin::clear_tracked_camera_if(ARVRCamera *p_tracked_camera) {
  413. if (tracked_camera == p_tracked_camera) {
  414. tracked_camera = NULL;
  415. };
  416. };
  417. float ARVROrigin::get_world_scale() const {
  418. // get our ARVRServer
  419. ARVRServer *arvr_server = ARVRServer::get_singleton();
  420. ERR_FAIL_NULL_V(arvr_server, 1.0);
  421. return arvr_server->get_world_scale();
  422. };
  423. void ARVROrigin::set_world_scale(float p_world_scale) {
  424. // get our ARVRServer
  425. ARVRServer *arvr_server = ARVRServer::get_singleton();
  426. ERR_FAIL_NULL(arvr_server);
  427. arvr_server->set_world_scale(p_world_scale);
  428. };
  429. void ARVROrigin::_notification(int p_what) {
  430. switch (p_what) {
  431. case NOTIFICATION_ENTER_TREE: {
  432. set_process_internal(true);
  433. }; break;
  434. case NOTIFICATION_EXIT_TREE: {
  435. set_process_internal(false);
  436. }; break;
  437. case NOTIFICATION_INTERNAL_PROCESS: {
  438. // get our ARVRServer
  439. ARVRServer *arvr_server = ARVRServer::get_singleton();
  440. ERR_FAIL_NULL(arvr_server);
  441. // set our world origin to our node transform
  442. arvr_server->set_world_origin(get_global_transform());
  443. // check if we have a primary interface
  444. Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
  445. if (arvr_interface.is_valid() && tracked_camera != NULL) {
  446. // get our positioning transform for our headset
  447. Transform t = arvr_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, Transform());
  448. // now apply this to our camera
  449. tracked_camera->set_transform(t);
  450. };
  451. }; break;
  452. default:
  453. break;
  454. };
  455. };
  456. ARVROrigin::ARVROrigin() {
  457. tracked_camera = NULL;
  458. };
  459. ARVROrigin::~ARVROrigin(){
  460. // nothing to do here yet for now..
  461. };