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"
35 
36 namespace Ogre
37 {
38 class Camera;
39 class SceneNode;
40 class SceneManager;
41 } // namespace Ogre
42 
43 namespace rviz
44 {
45 class Shape;
46 
61 class OrbitCamera : public CameraBase
62 {
63 public:
64  OrbitCamera(Ogre::SceneManager* scene_manager);
65  ~OrbitCamera() override;
66 
72  void zoom(float amount);
77  void setFocalPoint(const Ogre::Vector3& focal_point);
78 
79  float getPitch()
80  {
81  return pitch_;
82  }
83  float getYaw()
84  {
85  return yaw_;
86  }
87  float getDistance()
88  {
89  return distance_;
90  }
91  const Ogre::Vector3& getFocalPoint()
92  {
93  return focal_point_;
94  }
95 
96  void setFrom(CameraBase* camera) override;
97  void yaw(float angle) override;
98  void pitch(float angle) override;
99  void roll(float angle) override;
100  void setOrientation(float x, float y, float z, float w) override;
101  void setPosition(float x, float y, float z) override;
102  void move(float x, float y, float z) override;
103 
104  Ogre::Vector3 getPosition() override;
105  Ogre::Quaternion getOrientation() override;
106 
107  void lookAt(const Ogre::Vector3& point) override;
108 
109  void mouseLeftDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift) override;
110  void mouseMiddleDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift) override;
111  void mouseRightDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift) override;
112  void scrollWheel(int diff, bool ctrl, bool alt, bool shift) override;
113 
118  void update() override;
119 
120  void mouseLeftDown(int x, int y) override;
121  void mouseMiddleDown(int x, int y) override;
122  void mouseRightDown(int x, int y) override;
123  void mouseLeftUp(int x, int y) override;
124  void mouseMiddleUp(int x, int y) override;
125  void mouseRightUp(int x, int y) override;
126 
127  void fromString(const std::string& str) override;
128  std::string toString() override;
129 
130 private:
131  Ogre::Vector3 getGlobalFocalPoint();
132 
137  void calculatePitchYawFromPosition(const Ogre::Vector3& position);
141  void normalizePitch();
145  void normalizeYaw();
146 
147  Ogre::Vector3 focal_point_;
148  float yaw_;
149  float pitch_;
150  float distance_;
151 
153 };
154 
155 } // namespace rviz
156 
157 #endif /*OGRE_TOOLS_ORBIT_CAMERA_H_*/
rviz::OrbitCamera
An orbital camera, controlled by yaw, pitch, distance, and focal point.
Definition: orbit_camera.h:61
rviz::OrbitCamera::yaw_
float yaw_
The camera's yaw (rotation around the y-axis), in radians.
Definition: orbit_camera.h:148
rviz::OrbitCamera::getOrientation
Ogre::Quaternion getOrientation() override
Get the orientation of this camera.
Definition: orbit_camera.cpp:159
rviz::OrbitCamera::mouseRightDown
void mouseRightDown(int x, int y) override
Definition: orbit_camera.cpp:325
rviz::OrbitCamera::mouseMiddleDrag
void mouseMiddleDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift) override
Handle a middle mouse button drag.
Definition: orbit_camera.cpp:279
Ogre
Definition: axes_display.h:35
camera_base.h
rviz::OrbitCamera::mouseLeftDrag
void mouseLeftDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift) override
Handle a left mouse button drag.
Definition: orbit_camera.cpp:273
rviz::OrbitCamera::normalizeYaw
void normalizeYaw()
Normalizes the camera's yaw in the range [0, 2*pi)
Definition: orbit_camera.cpp:86
rviz::OrbitCamera::setOrientation
void setOrientation(float x, float y, float z, float w) override
Set the orientation of the camera from a quaternion.
Definition: orbit_camera.cpp:197
rviz::OrbitCamera::lookAt
void lookAt(const Ogre::Vector3 &point) override
Point the camera at the specified point.
Definition: orbit_camera.cpp:253
rviz::OrbitCamera::getGlobalFocalPoint
Ogre::Vector3 getGlobalFocalPoint()
Definition: orbit_camera.cpp:96
rviz::OrbitCamera::setPosition
void setPosition(float x, float y, float z) override
Set the position of the camera.
Definition: orbit_camera.cpp:243
rviz::CameraBase
Generic interface for a camera.
Definition: camera_base.h:53
rviz::OrbitCamera::setFocalPoint
void setFocalPoint(const Ogre::Vector3 &focal_point)
Set the focal point of the camera. Keeps the pitch/yaw/distance the same.
Definition: orbit_camera.cpp:222
rviz::OrbitCamera::move
void move(float x, float y, float z) override
Move the camera relative to its orientation.
Definition: orbit_camera.cpp:229
rviz::OrbitCamera::getPosition
Ogre::Vector3 getPosition() override
Get the position of this camera.
Definition: orbit_camera.cpp:154
rviz::OrbitCamera::zoom
void zoom(float amount)
Move in/out from the focal point, ie. adjust distance_ by amount.
Definition: orbit_camera.cpp:210
rviz::OrbitCamera::pitch
void pitch(float angle) override
Pitch the camera.
Definition: orbit_camera.cpp:141
rviz
Definition: add_display_dialog.cpp:54
rviz::OrbitCamera::~OrbitCamera
~OrbitCamera() override
Definition: orbit_camera.cpp:69
rviz::OrbitCamera::calculatePitchYawFromPosition
void calculatePitchYawFromPosition(const Ogre::Vector3 &position)
Calculates pitch and yaw values given a new position and the current focal point.
Definition: orbit_camera.cpp:164
ogre_vector.h
rviz::OrbitCamera::scrollWheel
void scrollWheel(int diff, bool ctrl, bool alt, bool shift) override
Handle a scrollwheel change.
Definition: orbit_camera.cpp:303
rviz::OrbitCamera::getPitch
float getPitch()
Definition: orbit_camera.h:79
rviz::OrbitCamera::getYaw
float getYaw()
Definition: orbit_camera.h:83
rviz::OrbitCamera::mouseRightUp
void mouseRightUp(int x, int y) override
Definition: orbit_camera.cpp:340
rviz::OrbitCamera::focal_point_object_
Shape * focal_point_object_
Definition: orbit_camera.h:152
rviz::OrbitCamera::update
void update() override
Calculates the camera's position and orientation from the yaw, pitch, distance and focal point.
Definition: orbit_camera.cpp:108
rviz::OrbitCamera::pitch_
float pitch_
The camera's pitch (rotation around the x-axis), in radians.
Definition: orbit_camera.h:149
rviz::OrbitCamera::mouseMiddleDown
void mouseMiddleDown(int x, int y) override
Definition: orbit_camera.cpp:320
rviz::OrbitCamera::yaw
void yaw(float angle) override
Yaw the camera.
Definition: orbit_camera.cpp:132
rviz::OrbitCamera::roll
void roll(float angle) override
Roll the camera.
Definition: orbit_camera.cpp:150
rviz::OrbitCamera::distance_
float distance_
The camera's distance from the focal point.
Definition: orbit_camera.h:150
rviz::Shape
Definition: shape.h:51
rviz::OrbitCamera::getFocalPoint
const Ogre::Vector3 & getFocalPoint()
Definition: orbit_camera.h:91
rviz::OrbitCamera::OrbitCamera
OrbitCamera(Ogre::SceneManager *scene_manager)
Definition: orbit_camera.cpp:54
rviz::OrbitCamera::mouseMiddleUp
void mouseMiddleUp(int x, int y) override
Definition: orbit_camera.cpp:335
rviz::OrbitCamera::focal_point_
Ogre::Vector3 focal_point_
The camera's focal point.
Definition: orbit_camera.h:147
rviz::OrbitCamera::toString
std::string toString() override
Returns a string representation of the camera's configuration.
Definition: orbit_camera.cpp:364
rviz::OrbitCamera::getDistance
float getDistance()
Definition: orbit_camera.h:87
rviz::OrbitCamera::mouseRightDrag
void mouseRightDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift) override
Handle a right mouse button drag.
Definition: orbit_camera.cpp:291
rviz::OrbitCamera::mouseLeftDown
void mouseLeftDown(int x, int y) override
Definition: orbit_camera.cpp:315
rviz::OrbitCamera::fromString
void fromString(const std::string &str) override
Loads the camera's configure from the supplied string (generated through toString())
Definition: orbit_camera.cpp:345
rviz::OrbitCamera::normalizePitch
void normalizePitch()
Normalizes the camera's pitch, preventing it from reaching vertical (or turning upside down)
Definition: orbit_camera.cpp:74
rviz::OrbitCamera::mouseLeftUp
void mouseLeftUp(int x, int y) override
Definition: orbit_camera.cpp:330
rviz::OrbitCamera::setFrom
void setFrom(CameraBase *camera) override
Set the position/orientation of this camera from another camera.
Definition: orbit_camera.cpp:184


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:10