Cut the current object inte random pieces.
Cut the current object inte random pieces
1import random
2import coat
3from coat import vec3
4from coat import Mesh
5
6
8m = Mesh()
9
10m.fromVolume(v)
11
12
13bb = m.getBounds()
14
15center = bb.GetCenter()
16
17
18if m.facesCount() == 0 :
19 coat.dialog().ok().text(
"Please select any non-trivial surface-based volume.").show()
20else:
21
22 meshes = [m]
23
24 def biggest() :
25 biggest=0
26 mbest=meshes[0]
27 for mesh in meshes:
28 b = mesh.getBounds()
29 if not b.IsEmpty():
30 L = b.GetDiagonal()
31 if (L > biggest) :
32 biggest = L
33 mbest = mesh
34 return mbest
35
36
37 for i in range(16) :
38 m0 = biggest()
39 bb = m0.getBounds()
40 m1 = m0.MakeCopy()
41 nn = vec3.RandNormal()
42 m0.cutByPlane(bb.GetCenter(), nn)
43 m1.cutByPlane(bb.GetCenter(), -nn)
44 meshes.append(m1)
45
46
47 v.clear()
48
49 for ms in meshes :
50
51 bb_center = ms.getBounds().GetCenter()
52 bb_center -= center
53 bb_center *= 0.1
54
56 v.mergeMesh(ms)
SceneElement current()
returns the current sculpt object
Definition coat.py:2683
mat4 Translation(float X, float Y)
Definition coat.py:554