UserCamera.hh
00001 /* 00002 * Copyright 2011 Nate Koenig & Andrew Howard 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 /* Desc: Camera for viewing the world 00018 * Author: Nate Koenig 00019 * Date: 19 Jun 2008 00020 */ 00021 00022 #ifndef USERCAMERA_HH 00023 #define USERCAMERA_HH 00024 00025 #include "rendering/Camera.hh" 00026 #include "rendering/RenderTypes.hh" 00027 #include "common/CommonTypes.hh" 00028 00029 namespace Ogre 00030 { 00031 class AnimationState; 00032 } 00033 00034 namespace gazebo 00035 { 00036 namespace rendering 00037 { 00038 class OrbitViewController; 00039 class FPSViewController; 00040 class Visual; 00041 class GUIOverlay; 00042 00045 00047 class UserCamera : public Camera 00048 { 00050 public: UserCamera(const std::string &_name, Scene *_scene); 00051 00053 public: virtual ~UserCamera(); 00054 00056 public: void Load(sdf::ElementPtr _sdf); 00057 public: void Load(); 00058 00060 public: void Init(); 00061 00063 public: virtual void Update(); 00064 00066 public: virtual void PostRender(); 00067 00069 public: void Fini(); 00070 00072 public: void HandleMouseEvent(const common::MouseEvent &_evt); 00073 public: void HandleKeyPressEvent(const std::string &_key); 00074 public: void HandleKeyReleaseEvent(const std::string &_key); 00075 00077 public: void SetViewController(const std::string &_type); 00078 00080 public: void SetViewController(const std::string &_type, 00081 const math::Vector3 &_pos); 00082 00084 public: void Resize(unsigned int _w, unsigned int _h); 00085 00087 public: void SetViewportDimensions(float _x, float _y, 00088 float _w, float _h); 00089 00091 public: float GetAvgFPS() const; 00092 00094 public: float GetTriangleCount() const; 00095 00097 public: void MoveToVisual(VisualPtr _visual ); 00098 public: void MoveToVisual(const std::string &_visualName ); 00099 00100 public: bool MoveToPosition(const math::Vector3 &_end, 00101 double _pitch, double _yaw, double _time); 00102 00103 public: bool MoveToPositions(const std::vector<math::Pose> &_pts, 00104 double _time, 00105 boost::function<void()> _onComplete); 00106 00108 protected: virtual bool AttachToVisualImpl( VisualPtr _visual, 00109 bool _inheritOrientation, double _minDist=0, 00110 double _maxDist=0 ); 00111 00113 protected: virtual bool TrackVisualImpl(VisualPtr _visual); 00114 00116 public: virtual void SetRenderTarget(Ogre::RenderTarget *_target); 00117 00119 public: GUIOverlay *GetGUIOverlay(); 00120 00122 public: void EnableViewController(bool _value) const; 00123 00125 private: void ToggleShowVisual(); 00126 00128 private: void ShowVisual(bool _s); 00129 00130 private: std::string name; 00131 private: static int count; 00132 00133 private: Visual *visual; 00134 00135 private: ViewController *viewController; 00136 private: OrbitViewController *orbitViewController; 00137 private: FPSViewController *fpsViewController; 00138 00139 private: Ogre::AnimationState *animState; 00140 private: boost::function<void()> onAnimationComplete; 00141 00142 private: GUIOverlay *gui; 00143 }; 00145 } 00146 00147 } 00148 #endif

1.7.5.1