Skip to content

Commit

Permalink
Change the default position of the camera in RenderPanel, plus minor …
Browse files Browse the repository at this point in the history
…refactoring. (#205)
  • Loading branch information
botteroa-si authored and wjwwood committed Mar 8, 2018
1 parent 8718ef5 commit 8587f5b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions rviz_common/include/rviz_common/render_panel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <mutex>
#include <vector>

#include <OgreVector3.h>
#include <QWidget> // NOLINT: cpplint is unable to handle the include order here

#include "rviz_common/visibility_control.hpp"
Expand Down Expand Up @@ -95,6 +96,7 @@ class RVIZ_COMMON_PUBLIC RenderPanel : public QWidget
*/
QSize
sizeHint() const override;
static const Ogre::Vector3 default_camera_pose_;

// TODO(wjwwood): reenable these and pass down to rviz_rendering::RenderWindow
#if 0
Expand Down
12 changes: 7 additions & 5 deletions rviz_common/src/rviz_common/render_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "rviz_common/render_panel.hpp"

#include <memory>
#include <sstream>
#include <string>

#include <OgreCamera.h>
#include <OgreSceneManager.h>
Expand Down Expand Up @@ -104,12 +104,12 @@ void RenderPanel::initialize(DisplayContext * context, bool use_main_scene)
if (use_main_scene) {
rviz_rendering::RenderWindowOgreAdapter::setSceneManager(
render_window_, context_->getSceneManager());
std::stringstream ss;
std::string camera_name;
static int count = 0;
ss << "RenderPanelCamera" << count++;
auto default_camera_ = context_->getSceneManager()->createCamera(ss.str());
camera_name = "RenderPanelCamera" + std::to_string(count++);
auto default_camera_ = context_->getSceneManager()->createCamera(camera_name);
default_camera_->setNearClipDistance(0.01f);
default_camera_->setPosition(Ogre::Vector3(0, 10, 15));
default_camera_->setPosition(default_camera_pose_);
default_camera_->lookAt(Ogre::Vector3(0, 0, 0));

rviz_rendering::RenderWindowOgreAdapter::setOgreCamera(render_window_, default_camera_);
Expand Down Expand Up @@ -288,6 +288,8 @@ RenderPanel::sizeHint() const
return QSize(320, 240);
}

const Ogre::Vector3 RenderPanel::default_camera_pose_ = Ogre::Vector3(999999, 999999, 999999);

#if 0
void RenderPanel::showContextMenu(std::shared_ptr<QMenu> menu)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void CameraDisplay::clear()
"Topic may not exist.");

rviz_rendering::RenderWindowOgreAdapter::getOgreCamera(
render_panel_->getRenderWindow())->setPosition(Ogre::Vector3(999999, 999999, 999999));
render_panel_->getRenderWindow())->setPosition(rviz_common::RenderPanel::default_camera_pose_);
}

void CameraDisplay::update(float wall_dt, float ros_dt)
Expand Down

0 comments on commit 8587f5b

Please sign in to comment.