orbit_camera.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef OGRE_TOOLS_ORBIT_CAMERA_H_
31 #define OGRE_TOOLS_ORBIT_CAMERA_H_
32 
33 #include "camera_base.h"
34 #include <OgreVector3.h>
35 
36 namespace Ogre
37 {
38  class Camera;
39  class SceneNode;
40  class SceneManager;
41 }
42 
43 namespace rviz
44 {
45 
46 class Shape;
47 
62 class OrbitCamera : public CameraBase
63 {
64 public:
65  OrbitCamera( Ogre::SceneManager* scene_manager );
66  virtual ~OrbitCamera();
67 
72  void zoom( float amount );
77  void setFocalPoint( const Ogre::Vector3& focal_point );
78 
79  float getPitch() { return pitch_; }
80  float getYaw() { return yaw_; }
81  float getDistance() { return distance_; }
82  const Ogre::Vector3& getFocalPoint() { return focal_point_; }
83 
84  virtual void setFrom( CameraBase* camera );
85  virtual void yaw( float angle );
86  virtual void pitch( float angle );
87  virtual void roll( float angle );
88  virtual void setOrientation( float x, float y, float z, float w );
89  virtual void setPosition( float x, float y, float z );
90  virtual void move( float x, float y, float z );
91 
92  virtual Ogre::Vector3 getPosition();
93  virtual Ogre::Quaternion getOrientation();
94 
95  virtual void lookAt( const Ogre::Vector3& point );
96 
97  virtual void mouseLeftDrag( int diff_x, int diff_y, bool ctrl, bool alt, bool shift );
98  virtual void mouseMiddleDrag( int diff_x, int diff_y, bool ctrl, bool alt, bool shift );
99  virtual void mouseRightDrag( int diff_x, int diff_y, bool ctrl, bool alt, bool shift );
100  virtual void scrollWheel( int diff, bool ctrl, bool alt, bool shift );
101 
105  virtual void update();
106 
107  virtual void mouseLeftDown( int x, int y );
108  virtual void mouseMiddleDown( int x, int y );
109  virtual void mouseRightDown( int x, int y );
110  virtual void mouseLeftUp( int x, int y );
111  virtual void mouseMiddleUp( int x, int y );
112  virtual void mouseRightUp( int x, int y );
113 
114  virtual void fromString(const std::string& str);
115  virtual std::string toString();
116 
117 private:
118 
119  Ogre::Vector3 getGlobalFocalPoint();
120 
125  void calculatePitchYawFromPosition( const Ogre::Vector3& position );
129  void normalizePitch();
133  void normalizeYaw();
134 
135  Ogre::Vector3 focal_point_;
136  float yaw_;
137  float pitch_;
138  float distance_;
139 
141 };
142 
143 } // namespace rviz
144 
145 #endif /*OGRE_TOOLS_ORBIT_CAMERA_H_*/
float distance_
The camera&#39;s distance from the focal point.
Definition: orbit_camera.h:138
const Ogre::Vector3 & getFocalPoint()
Definition: orbit_camera.h:82
Ogre::Vector3 focal_point_
The camera&#39;s focal point.
Definition: orbit_camera.h:135
Generic interface for a camera.
Definition: camera_base.h:53
TFSIMD_FORCE_INLINE const tfScalar & y() const
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
Shape * focal_point_object_
Definition: orbit_camera.h:140
TFSIMD_FORCE_INLINE const tfScalar & x() const
float pitch_
The camera&#39;s pitch (rotation around the x-axis), in radians.
Definition: orbit_camera.h:137
TFSIMD_FORCE_INLINE const tfScalar & z() const
TFSIMD_FORCE_INLINE const tfScalar & w() const
float yaw_
The camera&#39;s yaw (rotation around the y-axis), in radians.
Definition: orbit_camera.h:136
An orbital camera, controlled by yaw, pitch, distance, and focal point.
Definition: orbit_camera.h:62


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Wed Aug 28 2019 04:01:51