1
1
import bpy
2
- import bmesh
3
2
import numpy as np
4
3
import blendtorch .btb as btb
5
4
import supershape as sshape
8
7
9
8
10
9
def create_sshape_mesh (shape , material = None , fake_user = False ):
11
- new_obj = sshape .make_bpy_mesh (shape , name = ' sshape' , coll = False , weld = True )
10
+ new_obj = sshape .make_bpy_mesh (shape , name = " sshape" , coll = False , weld = True )
12
11
new_obj .data .use_fake_user = fake_user
13
12
new_obj .use_fake_user = fake_user
14
13
if material is not None :
@@ -17,17 +16,13 @@ def create_sshape_mesh(shape, material=None, fake_user=False):
17
16
return new_obj
18
17
19
18
20
- def prepare (
21
- n_sshapes ,
22
- sshape_res = (100 , 100 ),
23
- collection = 'Generated' ,
24
- fake_user = False ):
19
+ def prepare (n_sshapes , sshape_res = (100 , 100 ), collection = "Generated" , fake_user = False ):
25
20
coll = SCN .collection .children [collection ]
26
21
27
22
# The following material renders camera-space normals
28
- mat = btb .materials .create_normal_material (' normals' )
23
+ mat = btb .materials .create_normal_material (" normals" )
29
24
30
- plane = bpy .data .objects [' Plane' ]
25
+ plane = bpy .data .objects [" Plane" ]
31
26
plane .active_material = mat
32
27
33
28
sshapes = [
@@ -41,11 +36,11 @@ def prepare(
41
36
SCN .rigidbody_world .collection .objects .link (s )
42
37
# Rigid body settings
43
38
s .rigid_body .enabled = True
44
- s .rigid_body .collision_shape = ' BOX'
39
+ s .rigid_body .collision_shape = " BOX"
45
40
s .rigid_body .friction = 0.7
46
41
s .rigid_body .linear_damping = 0.3
47
42
s .rigid_body .angular_damping = 0.4
48
- s .rigid_body .type = ' ACTIVE'
43
+ s .rigid_body .type = " ACTIVE"
49
44
50
45
return sshapes
51
46
@@ -54,11 +49,10 @@ def update_mesh(mesh, sshape_res=(100, 100)):
54
49
params = np .random .uniform (
55
50
low = [1.00 , 1 , 1 , 6.0 , 6.0 , 6.0 ],
56
51
high = [4.00 , 1 , 1 , 10.0 , 10.0 , 10.0 ],
57
- size = (2 , 6 )
52
+ size = (2 , 6 ),
58
53
)
59
54
scale = np .abs (np .random .normal (0.05 , 0.05 , size = 3 ))
60
55
x , y , z = sshape .supercoords (params , shape = sshape_res )
61
- sshape .update_bpy_mesh (x * scale [0 ], y * scale [1 ], z * scale [2 ], mesh )
62
- mesh .location = np .random .uniform (
63
- low = [- 0.5 , - 0.5 , 1 ], high = [0.5 , 0.5 , 3 ], size = (3 ))
56
+ sshape .update_bpy_mesh (x * scale [0 ], y * scale [1 ], z * scale [2 ], mesh )
57
+ mesh .location = np .random .uniform (low = [- 0.5 , - 0.5 , 1 ], high = [0.5 , 0.5 , 3 ], size = (3 ))
64
58
mesh .rotation_euler = np .random .uniform (low = - np .pi , high = np .pi , size = (3 ))
0 commit comments