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> 51 std::string mesh_name;
55 mesh_name =
"rviz_cone.mesh";
59 mesh_name =
"rviz_cube.mesh";
63 mesh_name =
"rviz_cylinder.mesh";
67 mesh_name =
"rviz_sphere.mesh";
74 return scene_manager->createEntity(name, mesh_name);
77 Shape::Shape(
Type type, Ogre::SceneManager* scene_manager, Ogre::SceneNode* parent_node )
81 static uint32_t count = 0;
83 ss <<
"Shape" << count++;
101 material_->getTechnique(0)->setLightingEnabled(
true);
102 material_->getTechnique(0)->setAmbient( 0.5, 0.5, 0.5 );
107 #if (OGRE_VERSION_MAJOR <= 1 && OGRE_VERSION_MINOR <= 4) 109 entity_->setNormaliseNormals(
true);
122 Ogre::MaterialManager::getSingleton().remove(
material_->getName());
127 material_->getTechnique(0)->setAmbient( c * 0.5 );
128 material_->getTechnique(0)->setDiffuse( c );
132 material_->getTechnique(0)->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
133 material_->getTechnique(0)->setDepthWriteEnabled(
false );
137 material_->getTechnique(0)->setSceneBlending( Ogre::SBT_REPLACE );
138 material_->getTechnique(0)->setDepthWriteEnabled(
true );
144 setColor(Ogre::ColourValue(r, g, b, a));
180 entity_->getUserObjectBindings().setUserAny( data );
182 ROS_ERROR(
"Shape not yet fully constructed. Cannot set user data. Did you add triangles to the mesh already?");
virtual void setOrientation(const Ogre::Quaternion &orientation)
Set the orientation of the object.
virtual const Ogre::Vector3 & getPosition()
Get the local position of this object.
Ogre::SceneNode * offset_node_
static Ogre::Entity * createEntity(const std::string &name, Type shape_type, Ogre::SceneManager *scene_manager)
virtual const Ogre::Quaternion & getOrientation()
Get the local orientation of this object.
void setUserData(const Ogre::Any &data)
Sets user data on all ogre objects we own.
std::string material_name_
Ogre::MaterialPtr material_
Shape(Type shape_type, Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node=NULL)
Constructor.
virtual void setColor(float r, float g, float b, float a)
Set the color of the object. Values are in the range [0, 1].
Base class for visible objects, providing a minimal generic interface.
Ogre::SceneNode * scene_node_
virtual void setPosition(const Ogre::Vector3 &position)
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.
virtual void setScale(const Ogre::Vector3 &scale)
Set the scale of the object. Always relative to the identity orientation of the object.