CloudViewer: fixed dark textures

This commit is contained in:
matlabbe
2016-11-21 19:10:30 -05:00
parent 3d5699ef4a
commit 639896b309
+3 -15
View File
@@ -52,7 +52,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vtkGlyph3D.h> #include <vtkGlyph3D.h>
#include <vtkGlyph3DMapper.h> #include <vtkGlyph3DMapper.h>
#include <vtkLookupTable.h> #include <vtkLookupTable.h>
#if PCL_VERSION_COMPARE(<, 1, 7, 2)
#include <vtkTextureUnitManager.h> #include <vtkTextureUnitManager.h>
#include <vtkJPEGReader.h> #include <vtkJPEGReader.h>
#include <vtkBMPReader.h> #include <vtkBMPReader.h>
@@ -60,7 +59,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vtkPNGReader.h> #include <vtkPNGReader.h>
#include <vtkTIFFReader.h> #include <vtkTIFFReader.h>
#include <vtkOpenGLRenderWindow.h> #include <vtkOpenGLRenderWindow.h>
#endif
#ifdef RTABMAP_OCTOMAP #ifdef RTABMAP_OCTOMAP
#include <rtabmap/core/OctoMap.h> #include <rtabmap/core/OctoMap.h>
@@ -792,7 +790,6 @@ void CloudViewer::removeOctomap()
#endif #endif
} }
#if PCL_VERSION_COMPARE(<, 1, 7, 2)
// Copied from PCL 1.8 // Copied from PCL 1.8
int textureFromTexMaterial (const pcl::TexMaterial& tex_mat, int textureFromTexMaterial (const pcl::TexMaterial& tex_mat,
vtkTexture* vtk_tex) vtkTexture* vtk_tex)
@@ -913,20 +910,13 @@ int textureFromTexMaterial (const pcl::TexMaterial& tex_mat,
return (0); return (0);
} }
#endif
bool CloudViewer::addTextureMesh ( bool CloudViewer::addTextureMesh (
const pcl::TextureMesh &mesh, const pcl::TextureMesh &mesh,
const std::string &id, const std::string &id,
int viewport) int viewport)
{ {
#if PCL_VERSION_COMPARE(>=, 1, 7, 2) // Copied from PCL 1.8, modified to ignore vertex color
if(!_visualizer->addTextureMesh(mesh, id, viewport))
{
return false;
}
#else
// Copied from PCL 1.8
pcl::visualization::CloudActorMap::iterator am_it = _visualizer->getCloudActorMap()->find (id); pcl::visualization::CloudActorMap::iterator am_it = _visualizer->getCloudActorMap()->find (id);
if (am_it != _visualizer->getCloudActorMap()->end ()) if (am_it != _visualizer->getCloudActorMap()->end ())
@@ -982,8 +972,8 @@ bool CloudViewer::addTextureMesh (
vtkSmartPointer<vtkUnsignedCharArray> colors = vtkSmartPointer<vtkUnsignedCharArray>::New (); vtkSmartPointer<vtkUnsignedCharArray> colors = vtkSmartPointer<vtkUnsignedCharArray>::New ();
bool has_color = false; bool has_color = false;
vtkSmartPointer<vtkMatrix4x4> transformation = vtkSmartPointer<vtkMatrix4x4>::New (); vtkSmartPointer<vtkMatrix4x4> transformation = vtkSmartPointer<vtkMatrix4x4>::New ();
if ((pcl::getFieldIndex(mesh.cloud, "rgba") != -1) || if (0)//(pcl::getFieldIndex(mesh.cloud, "rgba") != -1) ||
(pcl::getFieldIndex(mesh.cloud, "rgb") != -1)) //(pcl::getFieldIndex(mesh.cloud, "rgb") != -1))
{ {
pcl::PointCloud<pcl::PointXYZRGB> cloud; pcl::PointCloud<pcl::PointXYZRGB> cloud;
pcl::fromPCLPointCloud2(mesh.cloud, cloud); pcl::fromPCLPointCloud2(mesh.cloud, cloud);
@@ -1160,8 +1150,6 @@ bool CloudViewer::addTextureMesh (
// Save the viewpoint transformation matrix to the global actor map // Save the viewpoint transformation matrix to the global actor map
(*_visualizer->getCloudActorMap())[id].viewpoint_transformation_ = transformation; (*_visualizer->getCloudActorMap())[id].viewpoint_transformation_ = transformation;
#endif
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
return true; return true;