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     kThirdPerson = 3
00033   };
00034 
00035   enum TouchEvent {
00036     kTouch0Down = 0,
00037     kTouch0Up = 1,
00038     kTouchMove = 2,
00039     kTouch1Down = 5,
00040     kTouch1Up = 6,
00041     kTouchNone = -1
00042   };
00043 
00044   GestureCamera();
00045   ~GestureCamera();
00046 
00047   void OnTouchEvent(int touch_count, TouchEvent event, float x0, float y0,
00048                     float x1, float y1);
00049 
00050   // Get the ray in opengl world frame given the 2d touch position on screen,
00051   // normalized touch_x and normalized touch_y should be the same value get from
00052   // OnTouchEvent, x0 and y0, touch_range is the depth of the touch in
00053   // camera frame.
00054   Segment GetSegmentFromTouch(float normalized_x, float normalized_y,
00055                               float touch_range);
00056 
00057   void SetAnchorPosition(const glm::vec3& pos, const glm::quat & rotation);
00058 
00059   // Set camera type, set render camera's parent position and rotation.
00060   void SetCameraType(CameraType camera_index);
00061 
00062   CameraType GetCameraType() const { return camera_type_; }
00063   float getFOV() const {return field_of_view_ * RADIAN_2_DEGREE;}
00064 
00065  private:
00066   void StartCameraToCurrentTransform();
00067 
00068   // Render camera's parent transformation.
00069   Transform* cam_parent_transform_;
00070 
00071   CameraType camera_type_;
00072 
00073   glm::vec2 cam_start_angle_;
00074   glm::vec2 cam_cur_angle_;
00075   glm::quat cam_cur_target_rot_;
00076 
00077   float cam_start_dist_;
00078   float cam_cur_dist_;
00079 
00080   float start_touch_dist_;
00081   float cur_touch_dist_;
00082 
00083   glm::vec2 touch0_start_position_;
00084 };
00085 }  // namespace tango_gl
00086 #endif  // TANGO_GL_GESTURE_CAMERA_H_


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:16