gesture_camera.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2014 Google Inc. All Rights Reserved.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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   // Get the ray in opengl world frame given the 2d touch position on screen,
00052   // normalized touch_x and normalized touch_y should be the same value get from
00053   // OnTouchEvent, x0 and y0, touch_range is the depth of the touch in
00054   // camera frame.
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   // Set camera type, set render camera's parent position and rotation.
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   // Render camera's parent transformation.
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 }  // namespace tango_gl
00094 #endif  // TANGO_GL_GESTURE_CAMERA_H_


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jun 6 2019 21:59:20