diff --git a/visualization/src/pcl_visualizer.cpp b/visualization/src/pcl_visualizer.cpp index 781fde07fed..0dcd7a72736 100644 --- a/visualization/src/pcl_visualizer.cpp +++ b/visualization/src/pcl_visualizer.cpp @@ -95,7 +95,10 @@ #include #include #include + +#if VTK_MAJOR_VERSION > 5 #include +#endif #include #include @@ -3520,6 +3523,9 @@ pcl::visualization::PCLVisualizer::addTextureMesh (const pcl::TextureMesh &mesh, texture_units, mesh.tex_materials.size ()); // Load textures std::size_t last_tex_id = std::min (static_cast (mesh.tex_materials.size ()), texture_units); + #if VTK_MAJOR_VERSION <= 5 + int tu = vtkProperty::VTK_TEXTURE_UNIT_0; + #endif std::size_t tex_id = 0; while (tex_id < last_tex_id) { @@ -3551,12 +3557,25 @@ pcl::visualization::PCLVisualizer::addTextureMesh (const pcl::TextureMesh &mesh, for (std::size_t tc = 0; tc < mesh.tex_coordinates[t].size (); ++tc) coordinates->InsertNextTuple2 (-1.0, -1.0); + #if VTK_MAJOR_VERSION > 5 mapper->MapDataArrayToMultiTextureAttribute(mesh.tex_materials[tex_id].tex_name.c_str (), this_coordinates_name.c_str (), vtkDataObject::FIELD_ASSOCIATION_POINTS); + #else + mapper->MapDataArrayToMultiTextureAttribute(tu, + this_coordinates_name.c_str (), + vtkDataObject::FIELD_ASSOCIATION_POINTS); + #endif polydata->GetPointData ()->AddArray (coordinates); + #if VTK_MAJOR_VERSION > 5 actor->GetProperty ()->SetTexture (mesh.tex_materials[tex_id].tex_name.c_str (), texture); + #else + actor->GetProperty ()->SetTexture (tu, texture); + #endif ++tex_id; + #if VTK_MAJOR_VERSION <= 5 + ++tu; + #endif } } // end of multi texturing else