[Closed] Problem when mapping a trimesh
This is weird.
I create a trimesh with mapping coordinates. Then I attach copies of it through a loop to an empty trimesh.
As a result, the first copy gets a default planar mapping while all the others are mapped according to my specifications.
Here is a test code:
v_arr = #([0,0,0], [10,0,0], [0,10,0], [10,10,0])
f_arr = #([3,1,2], [2,4,3])
tv_arr = #([0.5,0,0], [1,0.5,0], [0,0.5,0], [0.5,1,0])
tf_arr = #([3,1,2], [2,4,3])
base_mesh = triMesh()
setMesh base_mesh verts:v_arr faces:f_arr
meshop.setMapSupport base_mesh 1 true
for v = 1 to 4 do meshop.setMapVert base_mesh 1 v tv_arr[v]
for f = 1 to 2 do meshop.setMapFace base_mesh 1 f tf_arr[f]
final_mesh = triMesh()
for i = 0 to 4 do
(
copy_mesh = copy base_mesh
move copy_mesh [i * 15, 0, 0]
meshop.attach final_mesh copy_mesh
)
em = editable_mesh()
em.mesh = final_mesh
update em
If you add a Unwrap UVW to the result, you can see that all elements are mapped correctly except the first one.
I mean, it should be all or none, right?
Thanks in advance for your help.
I am now facing the same problem, did you ever find a solution to this?
you guys are trying to attach some triMesh to empty (no faces) triMesh. When empty triMesh gets new faces it rebuilds their uv map to default (don’t ask me why…). It does it just for first set of faces.
to solve this behavior you can make final mesh at the beginning with one face, attach all that you need, and delete first face.
but better way is to use the first attaching mesh as final and attach all other meshes to first one.
v_arr = #([0,0,0], [10,0,0], [0,10,0], [10,10,0])
f_arr = #([3,1,2], [2,4,3])
tv_arr = #([0.5,0,0], [1,0.5,0], [0,0.5,0], [0.5,1,0])
tf_arr = #([3,1,2], [2,4,3])
base_mesh = triMesh()
setMesh base_mesh verts:v_arr faces:f_arr
meshop.setMapSupport base_mesh 1 true
for v = 1 to 4 do meshop.setMapVert base_mesh 1 v tv_arr[v]
for f = 1 to 2 do meshop.setMapFace base_mesh 1 f tf_arr[f]
final_mesh = copy base_mesh
for i = 1 to 4 do
(
copy_mesh = copy base_mesh
move copy_mesh [i * 15, 0, 0]
meshop.attach final_mesh copy_mesh
)
em = editable_mesh isselected:on
em.mesh = final_mesh
update em