You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
COLLADA mesh's material is not visualized correctly #751
when a collada file is used as marker, it's not visualized correctly. Always the color
of the model is rendered as white. However if we use texture mapping in a collada file, rviz
can visualize it correctly.
On the other hand, if that file is used as robot_description, RobotModel can visualize it correctly.
This is a very nice bug report, you made a whole package for us to reproduce the bug. Sadly I don't have time to work on it now either. It certainly looks like a bug in rviz since it displays correctly in other contexts, and the content of your visualization_msgs/Marker message looks correct.
The mesh marker is explicitly using the color from the marker message and overriding the mesh colors. I am not sure why but it seemed like it was done intentionally.
Here is a diff you can try. It worked for me for the test case you have. it will use the message color value if mesh_use_embedded_materials == false otherwise it will use the mesh materials.
diff --git a/src/rviz/default_plugin/markers/mesh_resource_marker.cpp b/src/rviz/default_plugin/markers/mesh_resource_marker.cpp
index 616f0f4..b15a488 100644
--- a/src/rviz/default_plugin/markers/mesh_resource_marker.cpp+++ b/src/rviz/default_plugin/markers/mesh_resource_marker.cpp@@ -87,8 +87,6 @@ void MeshResourceMarker::onNewMessage(const MarkerConstPtr& old_message, const M
{
ROS_ASSERT(new_message->type == visualization_msgs::Marker::MESH_RESOURCE);
- bool need_color = false;-
scene_node_->setVisible(false);
if( !entity_ ||
@@ -120,7 +118,6 @@ void MeshResourceMarker::onNewMessage(const MarkerConstPtr& old_message, const M
std::string id = ss.str();
entity_ = context_->getSceneManager()->createEntity(id, new_message->mesh_resource);
scene_node_->attachObject(entity_);
- need_color = true;
// create a default material for any sub-entities which don't have their own.
ss << "Material";
@@ -172,28 +169,20 @@ void MeshResourceMarker::onNewMessage(const MarkerConstPtr& old_message, const M
handler_->addTrackedObject( entity_ );
}
- if( need_color ||- old_message->color.r != new_message->color.r ||- old_message->color.g != new_message->color.g ||- old_message->color.b != new_message->color.b ||- old_message->color.a != new_message->color.a )+ // if not using embedded materials and the color changed+ if (new_message->mesh_use_embedded_materials == false+ && (!old_message+ || old_message->mesh_use_embedded_materials == true+ || old_message->color.r != new_message->color.r+ || old_message->color.g != new_message->color.g+ || old_message->color.b != new_message->color.b+ || old_message->color.a != new_message->color.a))
{
float r = new_message->color.r;
float g = new_message->color.g;
float b = new_message->color.b;
float a = new_message->color.a;
- // Old way was to ignore the color and alpha when using embedded- // materials, which meant you could leave them unset, which means- // 0. Since we now USE the color and alpha values, leaving them- // all 0 will mean the object will be invisible. Therefore detect- // the situation where RGBA are all 0 and treat that the same as- // all 1 (full white).- if( new_message->mesh_use_embedded_materials && r == 0 && g == 0 && b == 0 && a == 0 )- {- r = 1; g = 1; b = 1; a = 1;- }-
Ogre::SceneBlendType blending;
bool depth_write;
Thanks for drafting a patch @brindza! Can you open a pull request for the patch? That way you'll get attribution for the commit.
I'll review this and test it myself as soon as possible, but it looks ok to me. I'll try to dig a bit and understand the existing logic to see if there was a good reason for this behavior.
The reason for that code is to enable the nice feature of being able to use the original textures but also tint them with a color, or set the alpha value.
It works for a bunch of situations, and I would like it to work in this one as well.
I just looked at the patch casually, but it seems to just disable the feature.
The current implementation just overrides the ambient and diffuse color properties of all passes with whatever is in the color message (or 1,1,1,1 if it is 0,0,0,0). I would expect it to work as intended for any for materials that don't specify those color properties.
It fails here because the material just uses the color properties which are being overwritten by the color value in the message. To get the intended tinting behavior it should probably be inserting a new pass into all the materials to do the tinting, not change the materials color properties directly.
@garaemon Would it be possible to add the texture mapped version to your example repo?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/751#issuecomment-41594247
.
Activity
wjwwood commentedon Apr 24, 2014
Thanks for the report, I don't have time to look into this issue right now, maybe one of the other developers has some spare cycles? @dgossow @hersh
If, in the mean time, you find a solution, please let us know.
hersh commentedon Apr 24, 2014
This is a very nice bug report, you made a whole package for us to reproduce the bug. Sadly I don't have time to work on it now either. It certainly looks like a bug in rviz since it displays correctly in other contexts, and the content of your visualization_msgs/Marker message looks correct.
jbrindza commentedon Apr 24, 2014
The mesh marker is explicitly using the color from the marker message and overriding the mesh colors. I am not sure why but it seemed like it was done intentionally.
Here is a diff you can try. It worked for me for the test case you have. it will use the message color value if
mesh_use_embedded_materials == falseotherwise it will use the mesh materials.garaemon commentedon Apr 25, 2014
that patch works on my environment too.
wjwwood commentedon Apr 25, 2014
Thanks for drafting a patch @brindza! Can you open a pull request for the patch? That way you'll get attribution for the commit.
I'll review this and test it myself as soon as possible, but it looks ok to me. I'll try to dig a bit and understand the existing logic to see if there was a good reason for this behavior.
hersh commentedon Apr 25, 2014
The reason for that code is to enable the nice feature of being able to use the original textures but also tint them with a color, or set the alpha value.
It works for a bunch of situations, and I would like it to work in this one as well.
I just looked at the patch casually, but it seems to just disable the feature.
jbrindza commentedon Apr 27, 2014
The current implementation just overrides the ambient and diffuse color properties of all passes with whatever is in the color message (or 1,1,1,1 if it is 0,0,0,0). I would expect it to work as intended for any for materials that don't specify those color properties.
It fails here because the material just uses the color properties which are being overwritten by the color value in the message. To get the intended tinting behavior it should probably be inserting a new pass into all the materials to do the tinting, not change the materials color properties directly.
@garaemon Would it be possible to add the texture mapped version to your example repo?
garaemon commentedon Apr 28, 2014
@brindza I've added a texture sample.
https://github.com/garaemon/rviz_collada_marker
(rviz with the @brindza patch)
wjwwood commentedon Apr 28, 2014
@garaemon what is the expected behavior of your modified package? Should the PR2 base be tinted with another color?
garaemon commentedon Apr 29, 2014
I assume that pr2 base should be visualized with texture mapping
2014年4月29日火曜日、William [email protected]さんは書きました:
from iPhone
wjwwood commentedon May 1, 2014
Closed by #752
Computed inertia with ignition-math (ros-visualization#751)