Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply colour to all visuals of the line class #827

Merged
merged 1 commit into from
Nov 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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