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(Orig=vec2, Angle=float)
Definition coat.py:612
float Rand(Lo=float, Hi=float)
Definition coat.py:1280
toRoom(name=str)
switch to the room
Definition coat.py:3251
Mesh islandToMesh(uv_set=int, island_index=int)
get the mesh that contains the island, xy of each point is the UV coordinate.
Definition coat.py:3991
meshToIsland(mesh=Mesh, uv_set=int, island_index=int)
use the mesh (that was previously got by islandToMesh) to replace the island in the current uv-set
Definition coat.py:4038
int islandsCount(uv_set=int)
get the islands count over the current uv-set
Definition coat.py:3985
int currentUvSet()
get the current uv-set index
Definition coat.py:3980
pack(uv_set=int, rotate=bool, shuffle=bool)
pack the islands in the current uv-set
Definition coat.py:4044