35 #include <OgreSceneManager.h> 36 #include <OgreSubEntity.h> 37 #include <OgreMaterialManager.h> 38 #include <OgreTextureManager.h> 39 #include <OgreTechnique.h> 40 #include <OgreAnimation.h> 45 namespace fs = boost::filesystem;
53 m_sceneManager(args.sceneManager)
58 Ogre::Vector3 scale(1,1,1);
83 m_sceneNode->setScale(scalingFactor, scalingFactor, scalingFactor);
104 const float headDiameter = 0.4;
106 const float cylinderHeight = totalHeight - headDiameter;
177 Ogre::Vector3 bottomLeft(0, -w, 0), bottomRight(0, 0, 0), topLeft(0, -w, h), topRight(0, 0, h);
178 Ogre::Vector3 rear(w, 0, 0);
211 ROS_INFO_STREAM(
"RosPackagePathResourceLoadingListener loading resource: " << absolutePath.string());
221 ROS_ERROR(
"In RosPackagePathResourceLoadingListener: %s", e.what());
222 return Ogre::DataStreamPtr();
243 std::string meshResource =
"package://" ROS_PACKAGE_NAME "/media/animated_walking_man.mesh";
246 fs::path model_path(meshResource);
247 fs::path parent_path(model_path.parent_path());
250 *oldListener = Ogre::ResourceGroupManager::getSingleton().getLoadingListener();
252 Ogre::ResourceGroupManager::getSingleton().setLoadingListener(newListener);
253 Ogre::ResourceGroupManager::getSingleton().setLoadingListener(oldListener);
259 static size_t count = 0;
260 std::stringstream ss;
261 ss <<
"mesh_person_visual" << count++;
262 std::string
id = ss.str();
272 Ogre::MaterialPtr default_material = Ogre::MaterialManager::getSingleton().create( ss.str(),
"rviz" );
273 default_material->setReceiveShadows(
false);
274 default_material->getTechnique(0)->setLightingEnabled(
true);
275 default_material->getTechnique(0)->setAmbient( 0.5, 0.5, 0.5 );
277 entity_->setMaterial( default_material );
280 Ogre::Quaternion quat1; quat1.FromAngleAxis(Ogre::Degree(90), Ogre::Vector3(0,1,0));
281 Ogre::Quaternion quat2; quat2.FromAngleAxis(Ogre::Degree(90), Ogre::Vector3(0,0,1));
284 double scaleFactor = 0.243 * 1.75;
285 m_childSceneNode->setScale(Ogre::Vector3(scaleFactor, scaleFactor, scaleFactor));
295 std::set<Ogre::MaterialPtr>::iterator it;
298 Ogre::MaterialPtr material = *it;
299 if (!material.isNull())
302 Ogre::MaterialManager::getSingleton().remove(material->getName());
314 Ogre::SceneBlendType blending;
319 blending = Ogre::SBT_TRANSPARENT_ALPHA;
324 blending = Ogre::SBT_REPLACE;
328 std::set<Ogre::MaterialPtr>::iterator it;
331 Ogre::Technique* technique = (*it)->getTechnique( 0 );
333 technique->setAmbient( c.r*0.5, c.g*0.5, c.b*0.5 );
334 technique->setDiffuse( c.r, c.g, c.b, c.a );
335 technique->setSceneBlending( blending );
336 technique->setDepthWriteEnabled( depth_write );
337 technique->setLightingEnabled(
true );
347 Ogre::AnimationStateSet *animationStates =
entity_->getAllAnimationStates();
348 if(animationStates !=
NULL)
350 Ogre::AnimationStateIterator animationsIterator = animationStates->getAnimationStateIterator();
351 while (animationsIterator.hasMoreElements())
353 Ogre::AnimationState *animationState = animationsIterator.getNext();
354 if(animationState->getAnimationName() == nameOfAnimationState || nameOfAnimationState.empty()) {
355 animationState->setLoop(
true);
356 animationState->setEnabled(
true);
363 ROS_WARN_STREAM_ONCE(
"Person mesh animation state " << nameOfAnimationState <<
" does not exist in mesh!");
void addPoint(const Ogre::Vector3 &point)
rviz::Shape * m_headShape
virtual double getHeight()
Ogre::SceneNode * getParentSceneNode()
Ogre::AnimationState * m_animationState
virtual Ogre::DataStreamPtr resourceLoading(const Ogre::String &name, const Ogre::String &group, Ogre::Resource *resource)
Ogre::ColourValue m_color
void setWalkingSpeed(float walkingSpeed)
virtual ~MeshPersonVisual()
virtual void resourceStreamOpened(const Ogre::String &name, const Ogre::String &group, Ogre::Resource *resource, Ogre::DataStreamPtr &dataStream)
virtual void setColor(const Ogre::ColourValue &c)
Ogre::SceneManager * m_sceneManager
virtual void setLineWidth(double lineWidth)
void setPosition(const Ogre::Vector3 &position)
virtual void setPosition(const Ogre::Vector3 &position)
virtual void setColor(float r, float g, float b, float a)
virtual void setColor(float r, float g, float b, float a)
Ogre::SceneNode * m_childSceneNode
Ogre::SceneNode * m_sceneNode
virtual Ogre::ColourValue & getColor()
virtual ~BoundingBoxPersonVisual()
void setOrientation(const Ogre::Quaternion &orientation)
Ogre::SceneManager * sceneManager
const Ogre::Vector3 & getPosition() const
boost::shared_array< uint8_t > data
virtual void setPosition(const Ogre::Vector3 &position)
rviz::BillboardLine * m_wireframe
virtual bool resourceCollision(Ogre::Resource *resource, Ogre::ResourceManager *resourceManager)
virtual Ogre::ColourValue & getColor()
virtual ~CylinderPersonVisual()
PersonVisual(const PersonVisualDefaultArgs &args)
BoundingBoxPersonVisual(const PersonVisualDefaultArgs &args, double height=1.75, double width=0.6, double scalingFactor=1.0)
std::set< Ogre::MaterialPtr > materials_
void setNumLines(uint32_t num)
void setMaxPointsPerLine(uint32_t max)
MemoryResource get(const std::string &url)
virtual void update(float deltaTime)
TFSIMD_FORCE_INLINE const tfScalar & w() const
virtual double getHeight()
#define ROS_INFO_STREAM(args)
virtual void setScalingFactor(double scalingFactor)
rviz::Shape * m_bodyShape
virtual void setColor(const Ogre::ColourValue &c)
#define ROS_WARN_STREAM_ONCE(args)
virtual void setColor(const Ogre::ColourValue &c)
Ogre::SceneNode * parentNode
Ogre::SceneNode * m_parentSceneNode
void setAnimationState(const std::string &nameOfAnimationState)
void setVisible(bool visible)
resource_retriever::MemoryResource _lastResource
virtual void update(float deltaTime)
RosPackagePathResourceLoadingListener(const fs::path &parentPath)
const fs::path & _parentPath
virtual Ogre::ColourValue & getColor()
virtual void generateWireframe()
virtual void setScale(const Ogre::Vector3 &scale)
CylinderPersonVisual(const PersonVisualDefaultArgs &args)
Base class for all person visualization types.
void setLineWidth(float width)
const Ogre::Quaternion & getOrientation() const
MeshPersonVisual(const PersonVisualDefaultArgs &args)