[vtkusers] How to rotate and transform object imported using vtkOBJImporter class?

vinmean iamdpak at gmail.com
Fri Aug 4 21:52:55 EDT 2017


I am new to vtk. I am using it along with pcl (point cloud library). I have
been trying to import an .obj file along with texture information. I was
able to do that using the below code. But I want to rotate and transform
this object that I imported. How do I do it in vtk? I know to rotate and
transform an mesh in pcl. Should I convert this object into pcl data type
(pcl::TextureMesh) ? If so how do I do it? 


#include <pcl/common/common.h>
#include <pcl/io/obj_io.h>
#include <pcl/io/vtk_lib_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/common/transforms.h>
#include <vtkOBJImporter.h>
#include <vtkRenderWindow.h>
#include <vtkCamera.h>
#include <vtkNew.h>
#include "vtksys/SystemTools.hxx"
#include <vtkOBJImporterInternals.h>

int main(int argc, char** argv)
{
          vtkNew<vtkOBJImporter> importer;
          std::string filenameOBJ("mesh.obj");
          std::string filenameMTL("mesh.mtl");
          std::string texfile1;
          std::string texture_path1 =
vtksys::SystemTools::GetFilenamePath("mesh_material0000_map_Kd.png");

          importer->SetFileName(filenameOBJ.data());
          importer->SetFileNameMTL(filenameMTL.data());
          importer->SetTexturePath(texture_path1.data());

          boost::shared_ptr<pcl::visualization::PCLVisualizer>
result_view(new pcl::visualization::PCLVisualizer("Viewer"));

          importer->SetRenderWindow(result_view->getRenderWindow());
          importer->Update();

          vtkSmartPointer<vtkRenderer> renderer
=result_view->getRenderWindow()->GetRenderers()->GetFirstRenderer();
          renderer->ResetCamera();

          result_view->spin();

        return 0;
} 



--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-rotate-and-transform-object-imported-using-vtkOBJImporter-class-tp5744300.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list