Pyvista: Camera object with vtki.texture_map_to_plane

Created on 9 Mar 2019  路  3Comments  路  Source: pyvista/pyvista

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:

  1. Is it possible to use vtki as regular vtk.polydata for texture mapping? I tried but it is showing a white board. My final goal is to capture the textured image from different camera position and focal length.
  2. Is there a more convenient way to build relation between the vtk and vtki package? I try extract the data from vtki object but it seems difficult.

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()

question

All 3 comments

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()

My problem is solved. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

deyanimay picture deyanimay  路  5Comments

zhaofenqiang picture zhaofenqiang  路  5Comments

tinebryder picture tinebryder  路  4Comments

banesullivan picture banesullivan  路  4Comments

tkoyama010 picture tkoyama010  路  3Comments