Calculate the square thash for the UV islands.
1
2import coat
3
4
7
9print("UV sets count: " + str(n_sets) + "\n")
10
11
12for s in range(n_sets):
13
15 print("Islands count: " + str(n_islands) + "\n")
16
17 for i in range(n_islands):
18
20
22 square_2D = 0
23 square_3D = 0
24 min_2d_to_3D = 1000000
25 max_2d_to_3D = 0
26
27 nfaces = island_mesh.facesCount()
28 print ("Island #" + str(i) + ": Faces count: " + str(nfaces) + " / " + str(island_3D.facesCount()))
29 for f in range(nfaces):
30
31 sq_2D = island_mesh.getFaceSquare(f)
32
33 sq_3D = island_3D.getFaceSquare(f)
34 if(sq_2D == 0 ): print ("Face #" + str(f) + ": 2D square = 0")
35 if(sq_3D == 0 ): print ("Face #" + str(f) + ": 3D square = 0")
36 square_2D += sq_2D
37 square_3D += sq_3D
38 _2d_to_3D = sq_2D / sq_3D
39 if _2d_to_3D < min_2d_to_3D:
40 min_2d_to_3D = _2d_to_3D
41 if _2d_to_3D > max_2d_to_3D:
42 max_2d_to_3D = _2d_to_3D
43 print ("Square 2D: " + str(square_2D))
44 print ("Square 3D: " + str(square_3D))
45 if square_3D > 0 and square_2D > 0:
46 _2D_to_3D = square_2D / square_3D
47 min_2d_to_3D /= _2D_to_3D
48 max_2d_to_3D /= _2D_to_3D
49 print ("Square trash: " + str(min_2d_to_3D) + " - " + str(max_2d_to_3D))
50 else:
51 print ("The island is empty")
52
53 print("\nBorders between islands:\n")
54
55 for i in range(n_islands):
56 for j in range(i+1,n_islands):
57
59 if len(edges) > 0 :
60 print ("Islands #" + str(i) + " and #" + str(j) + " have " + str(int(len(edges)/2)) + " common edges")
61
62 chunks = [edges[i:i+2] for i in range(0, len(edges), 2)]
63
64 while True:
65 merged = False
66 for k in range(len(chunks)):
67 for p in range(len(chunks)):
68
69 if k != p and chunks[k][-1] == chunks[p][0]:
70 chunks[k].extend(chunks[p][1:])
71 del chunks[p]
72 merged = True
73 break
74 if merged:
75 break
76 if not merged:
77 break
78 print(" Chunks: " + str(chunks))
79
str currentRoom()
get the current room name
Definition coat.py:3274
toRoom(str name, bool Force=False)
switch to the room
Definition coat.py:3284
int islandsCount(int uv_set)
get the islands count over the current uv-set
Definition coat.py:3971
list getBorderBetweenIslands(int uv_set1, int island_index1, int uv_set2, int island_index2)
get the border between two islands
Definition coat.py:4003
Mesh islandToMeshInSpace(int uv_set, int island_index)
get the mesh that contains the island, each point is the coordinate in space (not the uv coordinate!...
Definition coat.py:3983
int uvSetsCount()
get the UV-sets count.
Definition coat.py:3954
Mesh islandToMesh(int uv_set, int island_index)
get the mesh that contains the island, xy of each point is the UV coordinate.
Definition coat.py:3977