All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UserCamera.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Nate Koenig
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: Camera for viewing the world
18  * Author: Nate Koenig
19  * Date: 19 Jun 2008
20  */
21 
22 #ifndef _USERCAMERA_HH_
23 #define _USERCAMERA_HH_
24 
25 #include <string>
26 #include <vector>
27 
28 #include "rendering/Camera.hh"
29 #include "rendering/RenderTypes.hh"
30 #include "common/CommonTypes.hh"
31 
32 namespace gazebo
33 {
34  namespace rendering
35  {
36  class OrbitViewController;
37  class FPSViewController;
38  class Visual;
39  class GUIOverlay;
40  class SelectionBuffer;
41 
44 
47  class UserCamera : public Camera
48  {
52  public: UserCamera(const std::string &_name, Scene *_scene);
53 
55  public: virtual ~UserCamera();
56 
59  public: void Load(sdf::ElementPtr _sdf);
60 
62  public: void Load();
63 
65  public: void Init();
66 
68  public: virtual void Update();
69 
71  public: virtual void PostRender();
72 
74  public: void Fini();
75 
78  public: virtual void SetWorldPose(const math::Pose &_pose);
79 
82  public: void HandleMouseEvent(const common::MouseEvent &_evt);
83 
86  public: void HandleKeyPressEvent(const std::string &_key);
87 
90  public: void HandleKeyReleaseEvent(const std::string &_key);
91 
94  public: void SetViewController(const std::string &_type);
95 
99  public: void SetViewController(const std::string &_type,
100  const math::Vector3 &_pos);
101 
105  public: void Resize(unsigned int _w, unsigned int _h);
106 
112  public: void SetViewportDimensions(float _x, float _y,
113  float _w, float _h);
114 
117  public: float GetAvgFPS() const;
118 
121  public: float GetTriangleCount() const;
122 
125  public: void MoveToVisual(VisualPtr _visual);
126 
127  // Doxygen automatically pulls in the correct documentation.
128  public: virtual bool MoveToPosition(const math::Pose &_pose,
129  double _time);
130 
133  public: void MoveToVisual(const std::string &_visualName);
134 
139  public: virtual void SetRenderTarget(Ogre::RenderTarget *_target);
140 
145  public: GUIOverlay *GetGUIOverlay();
146 
152  public: void EnableViewController(bool _value) const;
153 
159  public: VisualPtr GetVisual(const math::Vector2i &mousePos,
160  std::string &mod);
161 
164  public: VisualPtr GetVisual(const math::Vector2i &_mousePos) const;
165 
168  public: void SetFocalPoint(const math::Vector3 &_pt);
169 
181  protected: virtual bool AttachToVisualImpl(VisualPtr _visual,
182  bool _inheritOrientation, double _minDist = 0,
183  double _maxDist = 0);
184 
190  protected: virtual bool TrackVisualImpl(VisualPtr _visual);
191 
192 
194  private: void ToggleShowVisual();
195 
199  private: void ShowVisual(bool _show);
200 
203  private: void OnMoveToVisualComplete();
204 
206  private: Visual *visual;
207 
209  private: ViewController *viewController;
210 
212  private: OrbitViewController *orbitViewController;
213 
215  private: FPSViewController *fpsViewController;
216 
218  private: GUIOverlay *gui;
219 
221  // private: Ogre::SceneNode *axisNode;
222 
224  private: SelectionBuffer *selectionBuffer;
225  };
227  }
228 }
229 #endif