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

add enable lighitng property in polygon_array_display #686

Merged
merged 1 commit into from
Sep 8, 2018
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
19 changes: 17 additions & 2 deletions jsk_rviz_plugins/src/polygon_array_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ namespace jsk_rviz_plugins
"show normal", true,
"show normal direction",
this, SLOT(updateShowNormal()));
enable_lighting_property_ = new rviz::BoolProperty(
"enable lighting", true,
"enable lighting",
this, SLOT(updateEnableLighting()));
normal_length_property_ = new rviz::FloatProperty(
"normal length", 0.1,
"normal length",
Expand Down Expand Up @@ -125,8 +129,10 @@ namespace jsk_rviz_plugins
Ogre::MaterialPtr material
= Ogre::MaterialManager::getSingleton().create(ss.str(), "rviz");
material->setReceiveShadows(false);
material->getTechnique(0)->setLightingEnabled(true);
material->getTechnique(0)->setLightingEnabled(enable_lighting_);
material->getTechnique(0)->setAmbient(0.5, 0.5, 0.5);

//material->setCullingMode(Ogre::CULL_NONE);
materials_.push_back(material);
}
}
Expand Down Expand Up @@ -299,6 +305,7 @@ namespace jsk_rviz_plugins
void PolygonArrayDisplay::processPolygonMaterial(const size_t i)
{
Ogre::ColourValue color = getColor(i);
materials_[i]->getTechnique(0)->setLightingEnabled(enable_lighting_);
materials_[i]->getTechnique(0)->setAmbient(color * 0.5);
materials_[i]->getTechnique(0)->setDiffuse(color);
if (color.a < 0.9998) {
Expand All @@ -310,7 +317,7 @@ namespace jsk_rviz_plugins
materials_[i]->getTechnique(0)->setSceneBlending(Ogre::SBT_REPLACE);
materials_[i]->getTechnique(0)->setDepthWriteEnabled(true);
}

materials_[i]->getTechnique(0)->setAmbient(color * 0.5);
materials_[i]->getTechnique(0)->setDiffuse(color);
}
Expand All @@ -330,6 +337,7 @@ namespace jsk_rviz_plugins
{
Ogre::SceneNode* scene_node = scene_nodes_[i * 2];
Ogre::ManualObject* manual_object = manual_objects_[i * 2];
Ogre::ColourValue color = getColor(i);
scene_node->setPosition(position);
scene_node->setOrientation(orientation);
manual_object->clear();
Expand All @@ -354,10 +362,12 @@ namespace jsk_rviz_plugins
for (size_t j = 0; j < num_vertices; j++) {
Eigen::Vector3f v = triangle->getVertex(j);
manual_object->position(v[0], v[1], v[2]);
manual_object->colour(color.r, color.g, color.b, color.a);
}
for (int j = num_vertices - 1; j >= 0; j--) {
Eigen::Vector3f v = triangle->getVertex(j);
manual_object->position(v[0], v[1], v[2]);
manual_object->colour(color.r, color.g, color.b, color.a);
}
}
manual_object->end();
Expand Down Expand Up @@ -500,6 +510,11 @@ namespace jsk_rviz_plugins
}
}

void PolygonArrayDisplay::updateEnableLighting()
{
enable_lighting_ = enable_lighting_property_->getBool();
}

void PolygonArrayDisplay::updateNormalLength()
{
normal_length_ = normal_length_property_->getFloat();
Expand Down
3 changes: 3 additions & 0 deletions jsk_rviz_plugins/src/polygon_array_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ namespace jsk_rviz_plugins
// rviz::BoolProperty* auto_coloring_property_;
rviz::EnumProperty* coloring_property_;
rviz::BoolProperty* show_normal_property_;
rviz::BoolProperty* enable_lighting_property_;
rviz::FloatProperty* normal_length_property_;
bool only_border_;
bool enable_lighting_;
std::string coloring_method_;
bool show_normal_;
double normal_length_;
Expand All @@ -103,6 +105,7 @@ namespace jsk_rviz_plugins
void updateColoring();
void updateOnlyBorder();
void updateShowNormal();
void updateEnableLighting();
void updateNormalLength();
private:

Expand Down