You’ll need to set the plane explicitly when using the vtkTextureMapToPlane
filter - it chooses an arbitrarily best-fitting plane by default which is likely not what you want in this case.
Experiment with the following methods of the vtkTextureMapToPlane
class:
SetOrigin
SetPoint1
SetPoint2
There are some convenience methods in PyVista to make this whole example way easier:
import pyvista as pv
import numpy as np
image_name = 'C:/VTK/Data/normalMapping.png'
points = np.array([[ 0., 0., 0.],
[100., 0., 0.],
[200., 0., 0.],
[300., 0., 0.],
[400., 0., 0.],
[ 0., 100., 10.],
[100., 100., 0.],
[200., 100., 0.],
[300., 100., 0.],
[400., 100., 0.],
[ 0., 200., 0.],
[100., 200., 0.],
[200., 200., 0.],
[300., 200., 0.],
[400., 200., 0.],
[ 0., 300., 10.],
[100., 300., 0.],
[200., 300., 0.],
[300., 300., 0.],
[400., 300., 0.],
[ 0., 400., 0.],
[100., 400., 0.],
[200., 400., 0.],
[300., 400., 0.],
[400., 400., 0.]])
# Make point cloud
poly = pv.PolyData(points)
# Traingulate the surface
surf = poly.delaunay_2d()
# Read the texture
texture = pv.read_texture(image_name)
# Define your mapping plane
origin = surf.bounds[0], surf.bounds[2], surf.bounds[4]
point_u = surf.bounds[1], surf.bounds[2], surf.bounds[4]
point_v = surf.bounds[0], surf.bounds[3], surf.bounds[4]
# Mapp the texture coordinates
mapped = surf.texture_map_to_plane(origin=origin, point_u=point_u, point_v=point_v)
# Display it from the top down
mapped.plot(texture=texture, cpos='xy')
Note that I took a screenshot of your image so it has some white edges