Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef TANGO_GL_GESTURE_CAMERA_H_
00018 #define TANGO_GL_GESTURE_CAMERA_H_
00019
00020 #include "tango-gl/camera.h"
00021 #include "tango-gl/segment.h"
00022 #include "tango-gl/transform.h"
00023 #include "tango-gl/util.h"
00024
00025 namespace tango_gl {
00026 class GestureCamera : public Camera {
00027 public:
00028 enum CameraType {
00029 kFirstPerson = 0,
00030 kThirdPersonFollow = 1,
00031 kTopDown = 2,
00032 kTopOrtho = 3,
00033 kThirdPerson = 4
00034 };
00035
00036 enum TouchEvent {
00037 kTouch0Down = 0,
00038 kTouch0Up = 1,
00039 kTouchMove = 2,
00040 kTouch1Down = 5,
00041 kTouch1Up = 6,
00042 kTouchNone = -1
00043 };
00044
00045 GestureCamera();
00046 ~GestureCamera();
00047
00048 void OnTouchEvent(int touch_count, TouchEvent event, float x0, float y0,
00049 float x1, float y1);
00050
00051
00052
00053
00054
00055 Segment GetSegmentFromTouch(float normalized_x, float normalized_y,
00056 float touch_range);
00057
00058 void SetAnchorPosition(const glm::vec3& pos, const glm::quat & rotation);
00059 void SetAnchorOffset(const glm::vec3& pos) {anchor_offset_ = pos;}
00060 const glm::vec3& GetAnchorOffset() const {return anchor_offset_;}
00061
00062 void SetCameraDistance(float cameraDistance) {cam_cur_dist_ = cameraDistance;}
00063 float GetCameraDistance() const {return cam_cur_dist_;}
00064
00065
00066 void SetCameraType(CameraType camera_index);
00067
00068 CameraType GetCameraType() const { return camera_type_; }
00069 float getFOV() const {return field_of_view_ * RADIAN_2_DEGREE;}
00070
00071 private:
00072 void StartCameraToCurrentTransform();
00073
00074
00075 Transform* cam_parent_transform_;
00076
00077 CameraType camera_type_;
00078
00079 glm::vec2 cam_start_angle_;
00080 glm::vec2 cam_cur_angle_;
00081 glm::quat cam_cur_target_rot_;
00082
00083 float cam_start_dist_;
00084 float cam_start_fov_;
00085 float cam_cur_dist_;
00086 glm::vec3 anchor_offset_;
00087
00088 float start_touch_dist_;
00089 float cur_touch_dist_;
00090
00091 glm::vec2 touch0_start_position_;
00092 };
00093 }
00094 #endif // TANGO_GL_GESTURE_CAMERA_H_