SHARE
TWEET

Untitled

a guest Mar 19th, 2015 276 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <gazebo-2.0/gazebo/math/Pose.hh>
  2. #include <boost/bind.hpp>
  3. #include <gazebo/gazebo.hh>
  4. #include <gazebo/physics/physics.hh>
  5. #include <gazebo/common/common.hh>
  6. #include <gazebo/math/Matrix4.hh>
  7. #include <stdio.h>
  8. #include <cmath>
  9. #include <stdlib.h>
  10. #include <time.h>
  11. #include <iostream>
  12. #include <ostream>
  13. #include "gazebo/transport/transport.hh"
  14. #include "gazebo/msgs/msgs.hh"
  15. #include "gazebo/msgs/vector3d.pb.h"
  16. #include <gazebo/rendering/rendering.hh>
  17. #include <gazebo/gui/gui.hh>
  18.  
  19. using namespace std;
  20. using namespace gazebo;
  21.  
  22. class SystemGUI : public SystemPlugin
  23. {
  24.  
  25.  
  26.  
  27. public: void Load(int /*_argc*/, char ** /*_argv*/)
  28. {
  29.         cout<<"Load()!"<<endl;
  30.         this->connections.push_back(event::Events::ConnectPreRender(boost::bind(&SystemGUI::Update, this)));
  31.  
  32. }
  33. public:void Init()
  34. {
  35.         cout<<"Init()!"<<endl;
  36.         //get_scene() 不能放在Load()
  37.         scene = rendering::get_scene();
  38.         text=new rendering::MovableText();
  39. }
  40. private: void Update()
  41. {
  42.  
  43.         if (!this->userCam)
  44.         {
  45.                 cout<<"enter one time"<<endl;
  46.                 this->userCam = gui::get_active_camera();
  47.                 userCam->SetAspectRatio (3);
  48.  
  49.  
  50.                 text->Load("_TEXT__","0N", "Arial", 200);
  51.                 text->SetShowOnTop(true);
  52.                 TextNode =world_visual->GetRootVisual()->GetSceneNode()->createChildSceneNode("_TEXT_NODE_");
  53.                 TextNode->attachObject(text);
  54.  
  55.                 }
  56.  
  57.  
  58.  
  59.  
  60.         scene->DrawLine(math::Vector3(0,0,0),math::Vector3(10,10,10),"XX");
  61.         if (!scene || !scene->GetInitialized())
  62.                 return;
  63.  
  64. }
  65.  
  66.  
  67.  
  68. /// Pointer the user camera.
  69. private: rendering::UserCameraPtr userCam;
  70. rendering::MovableText *text;
  71. Ogre::SceneNode *TextNode ;
  72. rendering::VisualPtr world_visual;
  73. rendering::ScenePtr scene;
  74. /// All the event connections.
  75. private: std::vector<event::ConnectionPtr> connections;
  76. };
  77.  
  78.  
  79. GZ_REGISTER_SYSTEM_PLUGIN(SystemGUI);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top