robotology / idyntree

Multibody Dynamics Library designed for Free Floating Robots
BSD 3-Clause "New" or "Revised" License
155 stars 65 forks source link

Visualize solid shapes and attach frames to model frames #1163

Closed S-Dafarra closed 3 months ago

S-Dafarra commented 3 months ago

This PR

cc @dariosortino

S-Dafarra commented 3 months ago
  • Improves the transparency visualization of the models

In order to do this, I had to play with the material flags. In particular, I had to use geomNode->setMaterialFlag(irr::video::EMF_COLOR_MATERIAL, false); to specify irrlicht to use the material color instead of the texture color (that we don't set) and geomNode->setMaterialFlag(irr::video::EMF_BLEND_OPERATION, true); to trigger the blending operation, necessary when visualing transparencies. Finally I had to use the irr::video::EMT_TRANSPARENT_VERTEX_ALPHA; material type. I noticed that this can make objects appear transparent even when they are not, so this is used only when the alpha component is different from 1.0. irrlicht still seem to have some issue in computing the correct transparency in case of multiple objects are overlapping, but I think it is a good trade-off