3DCoat Python API
The 3DCoat Python API documentation.
Loading...
Searching...
No Matches
uv_random_rotation.py

Randomly rotate the UV islands and pack them.

Randomly rotate the UV islands and pack them

1# In this example we rotate all islands randomly and then pack them.
2import coat
3
4# go to the uv-room to set the context
6
7current_uv_set = coat.uv.currentUvSet()
8n_islands = coat.uv.islandsCount(current_uv_set)
9# run through all islands
10for i in range(n_islands):
11 island_mesh = coat.uv.islandToMesh(current_uv_set,i)
12 # rotate the island randomly
13 center = island_mesh.getBounds().GetCenter()
14 island_mesh.transform(coat.mat4.RotationAt(center, coat.vec3.AxisZ, coat.math.Rand(0,360)))
15 # update the island
16 coat.uv.meshToIsland(island_mesh, current_uv_set, i)
17coat.uv.pack(current_uv_set, False, True)
18
mat4 RotationAt(vec2 Orig, float Angle)
Definition coat.py:574
float Rand(float Lo, float Hi)
Definition coat.py:1217
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
meshToIsland(Mesh mesh, int uv_set, int island_index)
use the mesh (that was previously got by islandToMesh) to replace the island in the current uv-set
Definition coat.py:4024
pack(int uv_set, bool rotate, bool shuffle)
pack the islands in the current uv-set
Definition coat.py:4030
int currentUvSet()
get the current uv-set index
Definition coat.py:3966
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