18 #ifndef _GAZEBO_RENDERING_CAMERA_HH_
19 #define _GAZEBO_RENDERING_CAMERA_HH_
21 #include <boost/enable_shared_from_this.hpp>
43 #include "gazebo/msgs/MessageTypes.hh"
84 bool _autoRender =
true);
91 public:
virtual void Load(sdf::ElementPtr _sdf);
94 public:
virtual void Load();
97 public:
virtual void Init();
101 public:
void SetRenderRate(
double _hz);
105 public:
double GetRenderRate()
const;
112 public:
void Render();
119 public:
void Render(
bool _force);
124 public:
virtual void PostRender();
131 public:
virtual void Update();
136 public:
virtual void Fini();
140 public:
bool GetInitialized()
const;
145 public:
void SetWindowId(
unsigned int _windowId);
149 public:
unsigned int GetWindowId()
const;
153 public:
void SetScene(
ScenePtr _scene);
165 public:
virtual void SetWorldPose(
const math::Pose &_pose);
194 public:
void SetClipDist(
float _near,
float _far);
211 public:
void SetImageSize(
unsigned int _w,
unsigned int _h);
215 public:
void SetImageWidth(
unsigned int _w);
219 public:
void SetImageHeight(
unsigned int _h);
223 public:
virtual unsigned int GetImageWidth()
const;
227 public:
unsigned int GetTextureWidth()
const;
231 public:
virtual unsigned int GetImageHeight()
const;
235 public:
unsigned int GetImageDepth()
const;
239 public: std::string GetImageFormat()
const;
243 public:
unsigned int GetTextureHeight()
const;
247 public:
size_t GetImageByteSize()
const;
254 public:
static size_t GetImageByteSize(
unsigned int _width,
255 unsigned int _height,
256 const std::string &_format);
263 public:
double GetZValue(
int _x,
int _y);
267 public:
double GetNearClip();
271 public:
double GetFarClip();
275 public:
void EnableSaveFrame(
bool _enable);
279 public:
bool GetCaptureData()
const;
283 public:
void SetSaveFramePathname(
const std::string &_pathname);
288 public:
bool SaveFrame(
const std::string &_filename);
292 public: Ogre::Camera *GetOgreCamera()
const;
296 public: Ogre::Viewport *GetViewport()
const;
300 public:
unsigned int GetViewportWidth()
const;
304 public:
unsigned int GetViewportHeight()
const;
324 public:
void SetAspectRatio(
float _ratio);
328 public:
float GetAspectRatio()
const;
332 public:
void SetSceneNode(Ogre::SceneNode *_node);
336 public: Ogre::SceneNode *GetSceneNode()
const;
347 public: virtual const
unsigned char *GetImageData(
unsigned int i = 0);
351 public: std::
string GetName() const;
355 public: std::
string GetScopedName() const;
359 public:
void SetName(const std::
string &_name);
362 public:
void ToggleShowWireframe();
366 public:
void ShowWireframe(
bool _s);
375 public:
void GetCameraToViewportRay(
int _screenx,
int _screeny,
376 math::Vector3 &_origin,
377 math::Vector3 &_dir);
381 public:
void SetCaptureData(
bool _value);
384 public:
void SetCaptureDataOnce();
388 public:
void CreateRenderTexture(const std::
string &_textureName);
400 public:
bool GetWorldPointOnPlane(
int _x,
int _y,
401 const math::Plane &_plane, math::Vector3 &_result);
405 public: virtual
void SetRenderTarget(Ogre::RenderTarget *_target);
415 public:
void AttachToVisual(const std::
string &_visualName,
416 bool _inheritOrientation,
417 double _minDist = 0.0,
double _maxDist = 0.0);
427 public:
void AttachToVisual(uint32_t _id,
428 bool _inheritOrientation,
429 double _minDist = 0.0,
double _maxDist = 0.0);
433 public:
void TrackVisual(const std::
string &_visualName);
437 public: Ogre::Texture *GetRenderTexture() const;
441 public: math::Vector3 GetDirection() const;
447 public: template<typename T>
449 {
return newImageFrame.Connect(_subscriber);}
454 {newImageFrame.Disconnect(_c);}
464 public:
static bool SaveFrame(
const unsigned char *_image,
465 unsigned int _width,
unsigned int _height,
int _depth,
466 const std::string &_format,
467 const std::string &_filename);
478 public:
bool IsVisible(
VisualPtr _visual);
484 public:
bool IsVisible(
const std::string &_visualName);
487 public:
bool IsAnimating()
const;
493 public:
virtual bool MoveToPosition(
const math::Pose &_pose,
503 public:
bool MoveToPositions(
const std::vector<math::Pose> &_pts,
505 boost::function<
void()> _onComplete =
NULL);
509 public: std::string GetScreenshotPath()
const;
512 protected:
virtual void RenderImpl();
515 protected:
void ReadPixelBuffer();
520 protected:
bool TrackVisualImpl(
const std::string &_visualName);
525 protected:
virtual bool TrackVisualImpl(
VisualPtr _visual);
536 protected:
virtual bool AttachToVisualImpl(
const std::string &_name,
537 bool _inheritOrientation,
538 double _minDist = 0,
double _maxDist = 0);
549 protected:
virtual bool AttachToVisualImpl(uint32_t _id,
550 bool _inheritOrientation,
551 double _minDist = 0,
double _maxDist = 0);
562 protected:
virtual bool AttachToVisualImpl(
VisualPtr _visual,
563 bool _inheritOrientation,
564 double _minDist = 0,
double _maxDist = 0);
568 protected: std::string GetFrameFilename();
572 protected:
virtual void AnimationComplete();
581 private:
void ConvertRGBToBAYER(
unsigned char *_dst,
unsigned char *_src,
582 std::string _format,
int _width,
int _height);
585 private:
void SetClipDist();
590 private:
static int GetOgrePixelFormat(
const std::string &_format);
594 private:
void OnCmdMsg(ConstCameraCmdPtr &_msg);
597 private:
void CreateCamera();
609 protected: sdf::ElementPtr
sdf;
673 unsigned int,
unsigned int,
unsigned int,