Skip to content

Commit

Permalink
apply colour to all visuals of the line class, closes #820.
Browse files Browse the repository at this point in the history
  • Loading branch information
stonier committed Nov 20, 2014
1 parent 3f96102 commit 5916821
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/rviz/ogre_helpers/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions src/rviz/ogre_helpers/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5916821

Please sign in to comment.