Hello, I am using the vtki for texture mapping and I also want to use the vtk.camera object with vtki. I have some questions:
Here is my code for texture mapping and the change of the camera position:
texture = vtki.load_texture(img_path)
obj = vtki.read(stl_path)
obj.texture_map_to_plane(inplace=True)
Mapper = vtk.vtkPolyDataMapper()
Mapper.SetInputData(obj)
Actor = vtk.vtkActor()
Actor.SetMapper(Mapper)
renderer = vtk.vtkRenderer()
renderer.AddActor(Actor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
// The camera position code
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
renWin.Render()
iren.Start()
Can you upload the stl and texture? This would help me in debugging why the texture isn't plotting.
As for the camera and plotting code, you can use vtki to streamline the plotting:
import vtki
texture = vtki.load_texture(img_path)
obj = vtki.read(stl_path)
obj.texture_map_to_plane(inplace=True)
# create a plotter object to handle visualization
plotter = vtki.Plotter()
plotter.add_mesh(obj)
# grab the camera object
camera = plotter.camera # vtkRenderingOpenGL2Python.vtkOpenGLCamera object
# your camera code follows
plotter.show()
FYI: this is a cross post from https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/7
My problem is solved. Thanks.