summaryrefslogtreecommitdiffhomepage
path: root/SixenseSDK/include/sixense_utils/laser_pointer.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-08-18 05:02:34 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-09 10:27:50 +0200
commit24e37795d2db8fdc6f7809e793dadbae80211d26 (patch)
treef2fd152fb44518222e290e555f0274af18d877bd /SixenseSDK/include/sixense_utils/laser_pointer.hpp
parent9a87e2cb6e588641e3cff52655013594c492e033 (diff)
add SDKs
Diffstat (limited to 'SixenseSDK/include/sixense_utils/laser_pointer.hpp')
-rwxr-xr-xSixenseSDK/include/sixense_utils/laser_pointer.hpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/SixenseSDK/include/sixense_utils/laser_pointer.hpp b/SixenseSDK/include/sixense_utils/laser_pointer.hpp
new file mode 100755
index 0000000..d845ae9
--- /dev/null
+++ b/SixenseSDK/include/sixense_utils/laser_pointer.hpp
@@ -0,0 +1,81 @@
+/*
+ *
+ * SIXENSE CONFIDENTIAL
+ *
+ * Copyright (C) 2011 Sixense Entertainment Inc.
+ * All Rights Reserved
+ *
+ */
+
+#ifndef SIXENSE_PORT_UTILS_LASER_POINTER_HPP
+#define SIXENSE_PORT_UTILS_LASER_POINTER_HPP
+
+#pragma warning(push)
+#pragma warning( disable:4251 )
+
+#include "sixense_utils/export.hpp"
+#include "sixense_utils/interfaces.hpp"
+
+#include "sixense_math.hpp"
+
+using sixenseMath::Vector2;
+using sixenseMath::Vector3;
+using sixenseMath::Matrix3;
+
+namespace sixenseUtils {
+
+ // LaserPointer computes a ray that shoots from the controller and intersects with the screen.
+ class SIXENSE_UTILS_EXPORT LaserPointer {
+
+ public:
+ LaserPointer();
+
+ void setScreenSize( Vector2 width_and_height_in_mm );
+ void setScreenCenterOffsetFromBase( Vector3 offset_in_mm );
+
+ Vector2 getScreenSize();
+ Vector3 getScreenCenterOffsetFromBase();
+
+ Vector2 getIntersection( Vector3 position, Matrix3 rotation );
+
+ private:
+ Vector2 _width_and_height_in_mm;
+ Vector3 _offset_in_mm;
+
+ };
+
+
+ // This class can be used to compute the required parameters for the LaserPointer by having the user aim the controller at the
+ // corners of the screen.
+ class SIXENSE_UTILS_EXPORT LaserPointerCalib {
+ public:
+
+ LaserPointerCalib() { _has_computed = false; }
+
+ // Calibrate using 4 ray casts, bottom left and top right from 2 distinct positions in space
+ bool compute(
+ Vector3 bottom_left_ray_from_point_A,
+ Vector3 top_right_ray_from_point_A,
+ Vector3 bottom_left_ray_from_point_B,
+ Vector3 top_right_ray_from_point_B );
+
+ // Calibrate using 2 ray casts plus the screen size, bottom left and top right
+ bool compute(
+ float screen_width_in_mm, float screen_aspect,
+ Vector3 bottom_left_ray_from_point_A,
+ Vector3 top_right_ray_from_point_A );
+
+ bool hasComputed() { return _has_computed; }
+ Vector2 getScrenSize();
+ Vector3 setScreenCenterOffsetFromBase();
+
+ private:
+ bool _has_computed;
+ Vector2 _width_and_height_in_mm;
+ Vector3 _offset_in_mm;
+ };
+};
+
+#pragma warning(pop)
+
+#endif