hi There,
Im trying to deform a texture using a grid of control points that initially are a uniform grid (texture is not deformed) and one can move control points to deform texture (a map between the rectangle and the new 2d surface)
Seems like a simple thing. However, after I create the surface, the result of PointAt(u,v), 0 <= u,v <= 1 are very different from the control points values (in the form Point4d(x,y ,0,1))
size = [10, 10]
dim = 3
u_degree = 2
v_degree = 2
# creates internal uninitialized arrays for
# control points and knots
self._surf = NurbsSurface.Create(
dim,
False,
u_degree + 1,
v_degree + 1,
size[0],
size[1]
)
u_knot = [0] * (size[0] + u_degree - 1)
v_knot = [0] * (size[1] + v_degree - 1)
for i in range(u_degree):
u_knot[i] = 0
for i in range(u_degree, len(u_knot)):
u_knot[i] = 1.0
for i in range(v_degree):
v_knot[i] = 0
for i in range(v_degree, len(v_knot)):
v_knot[i] = 1.0
# add the knots
for i in range(0, len(self._surf.KnotsU)):
self._surf .KnotsU[i] = u_knot[i]
for j in range(0, len(self._surf.KnotsV)):
self._surf .KnotsV[j] = v_knot[j]
items = gridItem.GetItems()
for row in range(len(items)):
for col in range(len(items[row])):
item = items[row][col]
pos = item.pos()
# log.error('>>>>>>>> ITEM row,col = %r, %r =>> %r, %r', row,col,pos.x(), pos.y())
self._surf.Points[col, row] = Point4d(pos.x(), pos.y(), 0, 1)
Currently my control points vary x,y in range (0,0 to 460, 250)
But PointAt retturns in the range completelly different (75, 35).
I guess is something related to the knots. I have 11 knots.
What I need is the control points to stay in the surface matching teh regular grid initially, and then the grid will be deformed so the surface can map the texture deformation
What is missing?
Thanks!!