24 #include <boost/enable_shared_from_this.hpp>
25 #include <boost/shared_ptr.hpp>
26 #include <boost/unordered/unordered_map.hpp>
27 #include <boost/thread/recursive_mutex.hpp>
44 class BasicController;
83 GZ_SKYX_ALL = 0x0FFFFFFF,
84 GZ_SKYX_CLOUDS = 0x0000001,
85 GZ_SKYX_MOON = 0x0000002,
97 public: Scene(
const std::string &_name,
98 bool _enableVisualizations =
false,
99 bool _isServer =
false);
102 public:
virtual ~Scene();
106 public:
void Load(sdf::ElementPtr _scene);
115 public:
void PreRender();
119 public: Ogre::SceneManager *GetManager()
const;
123 public: std::string GetName()
const;
135 public:
void SetBackgroundColor(
const common::Color &_color);
146 public:
void CreateGrid(uint32_t _cellCount,
float _cellLength,
152 public: Grid *GetGrid(uint32_t _index)
const;
156 public: uint32_t GetGridCount()
const;
163 public:
CameraPtr CreateCamera(
const std::string &_name,
164 bool _autoRender =
true);
171 public:
DepthCameraPtr CreateDepthCamera(
const std::string &_name,
172 bool _autoRender =
true);
179 public:
GpuLaserPtr CreateGpuLaser(
const std::string &_name,
180 bool _autoRender =
true);
184 public: uint32_t GetCameraCount()
const;
190 public:
CameraPtr GetCamera(uint32_t _index)
const;
195 public:
CameraPtr GetCamera(
const std::string &_name)
const;
202 public:
UserCameraPtr CreateUserCamera(
const std::string &_name);
206 public: uint32_t GetUserCameraCount()
const;
217 public:
void RemoveCamera(
const std::string &_name);
222 public:
LightPtr GetLight(
const std::string &_name)
const;
226 public: uint32_t GetLightCount()
const;
232 public:
LightPtr GetLight(uint32_t _index)
const;
237 public:
VisualPtr GetVisual(
const std::string &_name)
const;
242 public:
VisualPtr GetVisual(uint32_t _id)
const;
247 public:
void SelectVisual(
const std::string &_name,
248 const std::string &_mode);
262 public:
void SnapVisualToNearestBelow(
const std::string &_visualName);
284 public:
VisualPtr GetVisualBelow(
const std::string &_visualName);
291 std::vector<VisualPtr> &_visuals);
298 public:
double GetHeightBelowPoint(
const math::Vector3 &_pt);
305 public:
bool GetFirstContact(
CameraPtr _camera,
310 public:
void PrintSceneGraph();
316 public:
void SetVisible(
const std::string &_name,
bool _visible);
324 const std::string &_name);
333 public:
void SetFog(
const std::string &_type,
335 double _density,
double _start,
double _end);
339 public: uint32_t GetId()
const;
343 public: std::string GetIdString()
const;
347 public:
void SetShadowsEnabled(
bool _value);
351 public:
bool GetShadowsEnabled()
const;
359 public:
void RemoveVisual(
VisualPtr _vis);
363 public:
void SetGrid(
bool _enabled);
367 public:
VisualPtr GetWorldVisual()
const;
372 public: std::string StripSceneName(
const std::string &_name)
const;
376 public: Heightmap *GetHeightmap()
const;
379 public:
void Clear();
382 public:
VisualPtr CloneVisual(
const std::string &_visualName,
388 public:
VisualPtr GetSelectedVisual()
const;
392 public:
void SetWireframe(
bool _show);
396 public:
void SetTransparent(
bool _show);
400 public:
void ShowCOMs(
bool _show);
404 public:
void ShowJoints(
bool _show);
408 public:
void ShowCollisions(
bool _show);
412 public:
void ShowContacts(
bool _show);
416 public:
void ShowClouds(
bool _show);
420 public:
bool GetShowClouds()
const;
427 public:
void SetSkyXMode(
unsigned int _mode);
430 public:
bool GetInitialized()
const;
441 public: uint32_t GetVisualCount()
const;
444 public:
void RemoveProjectors();
447 private:
void SetSky();
450 private:
void InitDeferredShading();
458 private: Ogre::Entity *GetOgreEntityAt(
CameraPtr _camera,
460 bool _ignorSelectionObj);
472 private:
void GetMeshInformation(
const Ogre::Mesh *_mesh,
473 size_t &_vertexCount,
474 Ogre::Vector3* &_vertices,
477 const Ogre::Vector3 &_position,
478 const Ogre::Quaternion &_orient,
479 const Ogre::Vector3 &_scale);
484 private:
void PrintSceneGraphHelper(
const std::string &_prefix,
490 private:
void OnScene(ConstScenePtr &_msg);
494 private:
void OnResponse(ConstResponsePtr &_msg);
498 private:
void OnRequest(ConstRequestPtr &_msg);
502 private:
void OnJointMsg(ConstJointPtr &_msg);
506 private:
bool ProcessSensorMsg(ConstSensorPtr &_msg);
510 private:
bool ProcessJointMsg(ConstJointPtr &_msg);
514 private:
bool ProcessLinkMsg(ConstLinkPtr &_msg);
518 private:
bool ProcessSceneMsg(ConstScenePtr &_msg);
522 private:
bool ProcessModelMsg(
const msgs::Model &_msg);
526 private:
void OnSensorMsg(ConstSensorPtr &_msg);
530 private:
void OnVisualMsg(ConstVisualPtr &_msg);
534 private:
bool ProcessVisualMsg(ConstVisualPtr &_msg);
538 private:
void OnLightMsg(ConstLightPtr &_msg);
542 private:
bool ProcessLightMsg(ConstLightPtr &_msg);
546 private:
void ProcessRequestMsg(ConstRequestPtr &_msg);
550 private:
void OnSelectionMsg(ConstSelectionPtr &_msg);
554 private:
void OnSkyMsg(ConstSkyPtr &_msg);
558 private:
void OnModelMsg(ConstModelPtr &_msg);
562 private:
void OnPoseMsg(ConstPosesStampedPtr &_msg);
566 private:
void OnSkeletonPoseMsg(ConstPoseAnimationPtr &_msg);
571 private:
void CreateCOMVisual(ConstLinkPtr &_msg,
VisualPtr _linkVisual);
576 private:
void CreateCOMVisual(sdf::ElementPtr _elem,
580 private: std::string name;
583 private: sdf::ElementPtr sdf;
586 private: std::vector<CameraPtr> cameras;
589 private: std::vector<UserCameraPtr> userCameras;
592 private: Ogre::SceneManager *manager;
595 private: Ogre::RaySceneQuery *raySceneQuery;
598 private: std::vector<Grid *> grids;
601 private:
static uint32_t idCounter;
604 private: uint32_t id;
607 private: std::string idString;
611 typedef std::list<boost::shared_ptr<msgs::Visual const> > VisualMsgs_L;
614 private: VisualMsgs_L visualMsgs;
618 typedef std::list<boost::shared_ptr<msgs::Light const> > LightMsgs_L;
621 private: LightMsgs_L lightMsgs;
625 typedef std::map<uint32_t, msgs::Pose> PoseMsgs_M;
628 private: PoseMsgs_M poseMsgs;
632 typedef std::list<boost::shared_ptr<msgs::Scene const> > SceneMsgs_L;
635 private: SceneMsgs_L sceneMsgs;
639 typedef std::list<boost::shared_ptr<msgs::Joint const> > JointMsgs_L;
642 private: JointMsgs_L jointMsgs;
646 typedef std::list<boost::shared_ptr<msgs::Link const> > LinkMsgs_L;
649 private: LinkMsgs_L linkMsgs;
653 typedef std::list<boost::shared_ptr<msgs::Model const> > ModelMsgs_L;
655 private: ModelMsgs_L modelMsgs;
659 typedef std::list<boost::shared_ptr<msgs::Sensor const> > SensorMsgs_L;
662 private: SensorMsgs_L sensorMsgs;
666 typedef std::list<boost::shared_ptr<msgs::Request const> > RequestMsgs_L;
668 private: RequestMsgs_L requestMsgs;
672 typedef std::map<uint32_t, VisualPtr> Visual_M;
675 private: Visual_M visuals;
679 typedef std::map<std::string, LightPtr> Light_M;
682 private: Light_M lights;
686 typedef std::list<boost::shared_ptr<msgs::PoseAnimation const> >
689 private: SkeletonPoseMsgs_L skeletonPoseMsgs;
692 private: boost::shared_ptr<msgs::Selection const> selectionMsg;
695 private: boost::mutex *receiveMutex;
698 private: boost::recursive_mutex poseMsgMutex;
749 private: std::vector<event::ConnectionPtr> connections;
762 private: std::string selectionMode;
765 private: msgs::Request *requestMsg;
768 private:
bool enableVisualizations;
771 private: Heightmap *terrain;
774 private: std::map<std::string, Projector *> projectors;
780 private: SkyX::BasicController *skyxController;
783 private:
bool showCOMs;
786 private:
bool showCollisions;
789 private:
bool showJoints;
792 private:
bool transparent;
795 private:
bool wireframe;
798 private:
bool initialized;
809 private: uint32_t contactVisId;
813 typedef boost::unordered_map<std::string,
814 boost::shared_ptr<msgs::Joint const> > JointMsgs_M;
817 private: JointMsgs_M joints;