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 } // 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_*/
float distance_
The camera&#39;s distance from the focal point.
Definition: orbit_camera.h:150
const Ogre::Vector3 & getFocalPoint()
Definition: orbit_camera.h:91
Ogre::Vector3 focal_point_
The camera&#39;s focal point.
Definition: orbit_camera.h:147
Generic interface for a camera.
Definition: camera_base.h:53
IMETHOD Vector diff(const Vector &p_w_a, const Vector &p_w_b, double dt=1)
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:152
float pitch_
The camera&#39;s pitch (rotation around the x-axis), in radians.
Definition: orbit_camera.h:149
float yaw_
The camera&#39;s yaw (rotation around the y-axis), in radians.
Definition: orbit_camera.h:148
An orbital camera, controlled by yaw, pitch, distance, and focal point.
Definition: orbit_camera.h:61


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:24