33 #include <OgreSceneManager.h> 34 #include <OgreSceneNode.h> 35 #include <OgreVector3.h> 36 #include <OgreQuaternion.h> 37 #include <OgreEntity.h> 38 #include <OgreMaterialManager.h> 39 #include <OgreTextureManager.h> 40 #include <OgreTechnique.h> 50 std::string mesh_name;
54 mesh_name =
"rviz_cone.mesh";
58 mesh_name =
"rviz_cube.mesh";
62 mesh_name =
"rviz_cylinder.mesh";
66 mesh_name =
"rviz_sphere.mesh";
73 return scene_manager->createEntity(name, mesh_name);
76 Shape::Shape(
Type type, Ogre::SceneManager* scene_manager, Ogre::SceneNode* parent_node)
79 static uint32_t count = 0;
81 ss <<
"Shape" << count++;
99 material_->getTechnique(0)->setLightingEnabled(
true);
100 material_->getTechnique(0)->setAmbient(0.5, 0.5, 0.5);
105 #if (OGRE_VERSION_MAJOR <= 1 && OGRE_VERSION_MINOR <= 4) 107 entity_->setNormaliseNormals(
true);
120 Ogre::MaterialManager::getSingleton().remove(
material_->getName());
125 material_->getTechnique(0)->setAmbient(c * 0.5);
126 material_->getTechnique(0)->setDiffuse(c);
130 material_->getTechnique(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
131 material_->getTechnique(0)->setDepthWriteEnabled(
false);
135 material_->getTechnique(0)->setSceneBlending(Ogre::SBT_REPLACE);
136 material_->getTechnique(0)->setDepthWriteEnabled(
true);
142 setColor(Ogre::ColourValue(r, g, b, a));
178 entity_->getUserObjectBindings().setUserAny(data);
180 ROS_ERROR(
"Shape not yet fully constructed. Cannot set user data. Did you add triangles to the mesh " Ogre::SceneNode * offset_node_
static Ogre::Entity * createEntity(const std::string &name, Type shape_type, Ogre::SceneManager *scene_manager)
void setOrientation(const Ogre::Quaternion &orientation) override
Set the orientation of the object.
void setScale(const Ogre::Vector3 &scale) override
Set the scale of the object. Always relative to the identity orientation of the object.
std::string material_name_
Ogre::MaterialPtr material_
void setUserData(const Ogre::Any &data) override
Sets user data on all ogre objects we own.
void setColor(float r, float g, float b, float a) override
Set the color of the object. Values are in the range [0, 1].
Base class for visible objects, providing a minimal generic interface.
const Ogre::Quaternion & getOrientation() override
Get the local orientation of this object.
Shape(Type shape_type, Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node=nullptr)
Constructor.
const Ogre::Vector3 & getPosition() override
Get the local position of this object.
Ogre::SceneNode * scene_node_
void setPosition(const Ogre::Vector3 &position) override
Set the position of this object.
Ogre::SceneManager * scene_manager_
Ogre scene manager this object is part of.
void setOffset(const Ogre::Vector3 &offset)
Set the offset for this shape.