diff --git a/src/rviz/ogre_helpers/line.cpp b/src/rviz/ogre_helpers/line.cpp index d27a549de3..ba913c8986 100644 --- a/src/rviz/ogre_helpers/line.cpp +++ b/src/rviz/ogre_helpers/line.cpp @@ -107,11 +107,32 @@ void Line::setScale( const Ogre::Vector3& scale ) scene_node_->setScale( scale ); } +void Line::setColor( const Ogre::ColourValue& c ) +{ + // this is consistent with the behaviour in the Shape class. + + manual_object_material_->getTechnique(0)->setAmbient( c * 0.5 ); + manual_object_material_->getTechnique(0)->setDiffuse( c ); + + if ( c.a < 0.9998 ) + { + manual_object_material_->getTechnique(0)->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA ); + manual_object_material_->getTechnique(0)->setDepthWriteEnabled( false ); + } + else + { + manual_object_material_->getTechnique(0)->setSceneBlending( Ogre::SBT_REPLACE ); + manual_object_material_->getTechnique(0)->setDepthWriteEnabled( true ); + } +} + void Line::setColor( float r, float g, float b, float a ) { - manual_object_material_->getTechnique(0)->getPass(0)->setDiffuse(r,g,b,a); + setColor(Ogre::ColourValue(r, g, b, a)); } +// where are the void Line::setColour(...) convenience methods??? ;) + const Ogre::Vector3& Line::getPosition() { return scene_node_->getPosition(); diff --git a/src/rviz/ogre_helpers/line.h b/src/rviz/ogre_helpers/line.h index 08629fc963..a10eef3b48 100644 --- a/src/rviz/ogre_helpers/line.h +++ b/src/rviz/ogre_helpers/line.h @@ -97,6 +97,13 @@ class Line: public Object */ virtual void setColor( float r, float g, float b, float a ); + /** + * \brief Set the color of the object using ogre colour definitions. + * + * @param c : ogre colour type. + */ + virtual void setColor( const Ogre::ColourValue& c ); + /** * \brief Get the local position of this object * @return The position