glitch3d 0.2.3.2 → 0.2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 285f80bfd141184bf964f5ca7708bed223d8fe77
4
- data.tar.gz: 97d76d9d5fa444da5f01eed306ee2ed23ee7d67f
3
+ metadata.gz: 246e3f5ad753205a1da7847ad49660d5760bccc2
4
+ data.tar.gz: 059bdda653c3cac77696c54204fa0e8710c23185
5
5
  SHA512:
6
- metadata.gz: 02cbe99d66f1b7f828c733d6f0a7b591afc11b4259b4ca6346a60eb76ec5e13f7f791a788122e6fb418e21e103bdb9a224388c69ef2a75b907d236661233b746
7
- data.tar.gz: 6f33a8578b384790942034d8996fa83f81e4e9ab219269154dbd820c9d9902dbd08ca2d3bb2a07d7275aaa7983285fcd6ce9bdce5fc7e27b544355a0961ab68d
6
+ metadata.gz: 21e27d27c995d89cf1aa4f8b84878622280a2689b43b95b308a9aafb1292d2a611a966dd28b9de4df0b6fb50d406d22fdefb35c536466a6413200232ec582486
7
+ data.tar.gz: 2f395fa7b47217d5bec2e1390fefb8a966811d62c956dba2a88277e2070705be879b8e4ce9e20459083769b1d987f604f318df77007c867d3df6d6ad1385ec06
Binary file
Binary file
@@ -1,33 +1,38 @@
1
1
  ######################
2
2
  ## FLUID SIMULATION ##
3
3
  ######################
4
- context.scene.frame_end = NUMBER_OF_FRAMES
4
+ SCENE.frame_end = NUMBER_OF_FRAMES
5
+
6
+ RADIUS=20
5
7
 
6
8
  # Container
7
- bpy.ops.mesh.primitive_cube_add(location=(0, 0, -0.4),radius=7)
8
- container = bpy.data.objects['Cube']
9
+ bpy.ops.mesh.primitive_cube_add(location=(0, 0, -0.4),radius=RADIUS)
10
+ container = last_added_object('CUBE')
9
11
  container.name = 'Container'
10
12
  container.modifiers.new(name='container', type='FLUID_SIMULATION')
11
13
  container.modifiers['container'].settings.type = 'DOMAIN'
12
- container.modifiers['container'].settings.generate_particles = 0.1
13
- make_object_gradient_fabulous(container, rand_color(), rand_color())
14
- # make_object_glossy(container)
14
+ container.modifiers['container'].settings.generate_particles = 0.06
15
15
  container.modifiers['container'].settings.surface_subdivisions = 100
16
- container.location = (0, 0, 7)
16
+ container.modifiers['container'].settings.viscosity_exponent = 6
17
+ container.modifiers['container'].settings.viscosity_base = 1.0
18
+ container.modifiers['container'].settings.simulation_scale = 1
19
+
20
+ container.location = (0, 0, 0)
17
21
 
18
22
  # Emitter of fluid
19
- bpy.ops.mesh.primitive_uv_sphere_add(location=(0,0,10))
23
+ bpy.ops.mesh.primitive_uv_sphere_add(location=(0,0,((RADIUS/2) - 1)))
20
24
  emitter = bpy.data.objects['Sphere']
25
+ emitter.cycles_visibility.camera = False
21
26
  emitter.name = 'Emitter'
22
27
  emitter.modifiers.new(name='emitter', type='FLUID_SIMULATION')
23
28
  emitter.modifiers['emitter'].settings.type = 'INFLOW'
24
- emitter.modifiers['emitter'].settings.inflow_velocity = mathutils.Vector((0, 0, -1))
29
+ emitter.modifiers['emitter'].settings.inflow_velocity = mathutils.Vector((0, 0.5, -2))
25
30
  emitter.scale = (0.5, 0.5, 0.5)
26
31
 
27
- SUBJECT.modifiers.new(name='obstacle', type='FLUID_SIMULATION')
28
- SUBJECT.modifiers['obstacle'].settings.type = 'OBSTACLE'
29
- SUBJECT.modifiers['obstacle'].settings.volume_initialization = 'BOTH'
30
- SUBJECT.modifiers['obstacle'].settings.partial_slip_factor = 0.15
32
+ # make_object_transparent(container)
33
+ make_object_gradient_fabulous(container, rand_color(), rand_color())
34
+ make_object_fluid_collider(SUBJECT)
35
+ make_object_fluid_collider(OCEAN[0])
31
36
 
32
37
  # Bake animation
33
38
  bpy.ops.fluid.bake({'scene': context.scene, 'active_object': container})
@@ -7,7 +7,12 @@ props.append(m4a1)
7
7
 
8
8
  # Add props
9
9
  rand_primitive = random.choice(PRIMITIVES)
10
- build_composite_object(rand_primitive, 4, 1)
10
+ elements = build_composite_object(rand_primitive, 4, 1)
11
+
12
+ for l1 in elements:
13
+ for l2 in l1:
14
+ for obj in l2:
15
+ WIREFRAMES.append(obj)
11
16
 
12
17
  # Set up virtual displays
13
18
  bpy.ops.mesh.primitive_grid_add(x_subdivisions=100, y_subdivisions=100, location=(0, 6, 2))
@@ -38,9 +43,9 @@ make_object_gradient_fabulous(m4a1, rand_color(), rand_color())
38
43
  # Make floor
39
44
  bpy.ops.mesh.primitive_plane_add(location=(0, 0, -2))
40
45
  floor = last_added_object('PLANE')
41
- bpy.data.groups['Plane'].objects.link(floor)
46
+ bpy.data.groups['Planes'].objects.link(floor)
42
47
  floor.scale = (20,20,20)
43
- subdivide(floor, int(random.uniform(0, 7)))
48
+ subdivide(floor, int(random.uniform(3, 7)))
44
49
  displace(floor)
45
50
  texture_object(floor)
46
51
 
@@ -62,11 +67,8 @@ for index in range(1, len(WORDS)):
62
67
  make_object_glossy(new_object, rand_color(), 0.0)
63
68
  new_object.scale = (text_scale, text_scale, text_scale)
64
69
  new_object.location = rand_location()
65
- # pivot text to make it readable by camera
66
- new_object.rotation_euler.x += math.radians(90)
67
- new_object.rotation_euler.z += math.radians(90)
68
70
 
69
- for plane in bpy.data.groups['Plane'].objects:
71
+ for plane in bpy.data.groups['Planes'].objects:
70
72
  unwrap_model(plane)
71
73
 
72
74
  for obj in WIREFRAMES:
@@ -1,62 +1,54 @@
1
1
  # Game of life inspired scene
2
- w = 40
3
- f = 1
4
- bpy.ops.anim.change_frame( frame = f )
2
+ SIZE = 10
3
+ DURATION=NUMBER_OF_FRAMES
4
+ SCENE.frame_start = 0
5
+ SCENE.frame_end = DURATION
6
+ cubes = build_grid_object('CUBE', SIZE-1, 0.5, 1)
5
7
 
6
- cubes = [[ 0 for i in range(w)] for j in range(w)]
7
- for x in range(w):
8
- for y in range(w):
9
- bpy.ops.mesh.primitive_cube_add( location=(x * 2, y * 2, 0 ))
10
- cubes[x][y] = bpy.context.active_object
11
- cubes[x][y].data.materials.append( mat );
12
- cubes[x][y].scale=(.1,.1,.1)
13
- bpy.ops.anim.keyframe_insert_menu( type='Scaling')
14
-
15
- cells = [[ 0 for i in range(w)] for j in range(w)]
16
- nextGen = [[ 0 for i in range(w)] for j in range(w)]
8
+ cells = [[ 0 for i in range(SIZE)] for j in range(SIZE)]
9
+ next_generation = [[ 0 for i in range(SIZE)] for j in range(SIZE)]
17
10
 
18
- cells[16][14] = 1
19
- cells[16][15] = 1
20
- cells[15][15] = 1
21
- cells[15][17] = 1
22
- cells[16][16] = 1
23
- cells[17][15] = 1
24
- cells[17][17] = 1
25
- cells[16][17] = 1
11
+ for x in range(SIZE):
12
+ for y in range(SIZE):
13
+ cubes[x][y].scale=(.1,.1,.1)
14
+ cells[x][y] = random.choice(range(2))
15
+ make_object_gradient_fabulous(cubes[x][y], rand_color(), rand_color())
26
16
 
27
- for l in range(50):
28
- f += 5
29
- bpy.ops.anim.change_frame( frame = f )
30
- for x in range(w):
31
- row = ""
32
- for y in range(w):
33
- nb = 0
17
+ def adjust_scale():
18
+ for x in range(SIZE):
19
+ for y in range(SIZE):
20
+ if cells[x][y] == 1 :
21
+ cubes[x][y].scale=(random.uniform(0.4, 0.6), random.uniform(0.4, 0.6), random.uniform(0.4, 0.6))
22
+ else:
23
+ cubes[x][y].scale=(.2,.2,.2)
24
+ for line in cubes:
25
+ add_frame(line)
26
+
27
+ def life(l):
28
+ print("Life in " + str(l))
29
+ for x in range(SIZE):
30
+ for y in range(SIZE):
31
+ neighbors_alive_count = 0
34
32
  for i in range(-1,2):
35
33
  for j in range( -1, 2):
36
- xx = (x + i + w) % w
37
- yy = (y + j + w) % w
38
-
39
- if not( xx == x and yy == y):
40
- nb += cells[xx][yy]
41
-
42
- if ( cells[x][y] == 1 and (nb == 2 or nb == 3)):
43
- nextGen[x][y] = 1
44
- elif ( cells[x][y] == 0 and nb == 3 ):
45
- nextGen[x][y] = 1
46
- else:
47
- nextGen[x][y] = 0
48
-
49
- n = cubes[x][y]
50
- bpy.context.scene.objects.active = n
51
- n.select = True
52
- if cells[x][y] == 1 :
53
- #row += 'X'
54
- cubes[x][y].scale=(1,1,1)
34
+ x_index = (x + i + SIZE) % SIZE
35
+ y_index = (y + j + SIZE) % SIZE
36
+ if not( x_index == x and y_index == y):
37
+ neighbors_alive_count += cells[x_index][y_index]
38
+ if ( cells[x][y] == 1 and (neighbors_alive_count == 2 or neighbors_alive_count == 3)):
39
+ next_generation[x][y] = 1
40
+ elif ( cells[x][y] == 0 and neighbors_alive_count == 3 ):
41
+ next_generation[x][y] = 1
55
42
  else:
56
- #row += '.'
57
- cubes[x][y].scale=(.1,.1,.1)
58
- bpy.ops.anim.keyframe_insert_menu( type='Scaling')
43
+ next_generation[x][y] = 0
44
+ for x in range(SIZE):
45
+ for y in range(SIZE):
46
+ cells[x][y] = next_generation[x][y]
47
+ adjust_scale()
48
+
49
+ print("Synthetic life begin")
50
+ adjust_scale()
51
+ for l in range(DURATION):
52
+ SCENE.frame_set(l)
53
+ life(l)
59
54
 
60
- for x in range( w ):
61
- for y in range(w):
62
- cells[x][y] = nextGen[x][y]
@@ -14,7 +14,7 @@ PRIMITIVES = ['PYRAMID', 'CUBE']
14
14
  props = []
15
15
  YELLOW = (1, 0.7, 0.1, 1)
16
16
  GREY = (0.2, 0.2, 0.2 ,1)
17
- BLUE = (0.1, 0.1, 0.8, 1)
17
+ BLUE = (0.1, 0.1, 0.8, 0.4)
18
18
  PINK = (0.8, 0.2, 0.7, 1.0)
19
19
  WORDS = string.ascii_lowercase
20
20
 
@@ -23,20 +23,16 @@ def pry():
23
23
  sys.exit("Aborting execution")
24
24
 
25
25
  # Helper methods
26
- def look_at(object):
26
+ def look_at(obj):
27
27
  location_camera = CAMERA.matrix_world.to_translation()
28
- location_object = object.matrix_world.to_translation()
28
+ location_object = obj.matrix_world.to_translation()
29
29
  direction = location_object - location_camera
30
30
  rot_quat = direction.to_track_quat('-Z', 'Y')
31
31
  CAMERA.rotation_euler = rot_quat.to_euler()
32
32
 
33
- def empty_materials():
34
- for material in bpy.data.materials.keys():
35
- bpy.data.materials.remove(object.data.materials[material])
36
-
37
33
  def shoot(filepath):
38
34
  print('Camera now at location: ' + camera_location_string(CAMERA) + ' / rotation: ' + camera_rotation_string(CAMERA))
39
- bpy.context.scene.render.filepath = filepath
35
+ SCENE.render.filepath = filepath
40
36
  if animate:
41
37
  return bpy.ops.render.render(animation=animate, write_still=True)
42
38
  bpy.ops.render.render(write_still=True)
@@ -82,7 +78,7 @@ def rand_scale_vector():
82
78
  def unwrap_model(obj):
83
79
  if obj.name.startswith('Camera') or obj.name.startswith('Text') or obj.name.startswith('Cube'):
84
80
  return False
85
- context.scene.objects.active = obj
81
+ SCENE.objects.active = obj
86
82
  bpy.ops.object.mode_set(mode='EDIT')
87
83
  bpy.ops.uv.unwrap()
88
84
  bpy.ops.object.mode_set(mode='OBJECT')
@@ -93,8 +89,8 @@ def camera_rotation_string(camera):
93
89
  def camera_location_string(camera):
94
90
  return str(int(camera.location.x)) + ' ' + str(int(camera.location.y)) + ' ' + str(int(camera.location.z))
95
91
 
96
- def assign_material(SUBJECT, material):
97
- SUBJECT.data.materials.append(material)
92
+ def assign_material(obj, material):
93
+ obj.data.materials.append(material)
98
94
 
99
95
  # Returns a new Cycles material with default DiffuseBsdf node linked to output
100
96
  def create_cycles_material():
@@ -152,13 +148,19 @@ def make_texture_object_transparent(obj, color = (1,1,1,0.5), intensity = 0.25):
152
148
  add.inputs[0].default_value = intensity
153
149
  trans.inputs[0].default_value = color
154
150
 
151
+ def make_object_transparent(obj):
152
+ material = bpy.data.materials.new('Transparent Material - ' + str(uuid.uuid1()))
153
+ material.use_nodes = True
154
+ trans = material.node_tree.nodes.new('ShaderNodeBsdfTransparent')
155
+ trans.inputs[0].default_value = rand_color()
156
+ assign_node_to_output(material, trans)
157
+ assign_material(obj, material)
158
+
155
159
  def make_object_emitter(obj, emission_strength):
156
160
  emissive_material = bpy.data.materials.new('Emissive Material #' + str(uuid.uuid1()))
157
161
  emissive_material.use_nodes = True
158
162
  emission_node = emissive_material.node_tree.nodes.new('ShaderNodeEmission')
159
- # Set color
160
163
  emission_node.inputs[0].default_value = rand_color()
161
- # Set strength
162
164
  emission_node.inputs[1].default_value = emission_strength
163
165
  assign_node_to_output(emissive_material, emission_node)
164
166
  assign_material(obj, emissive_material)
@@ -194,7 +196,7 @@ def texture_object(obj):
194
196
  def duplicate_object(obj):
195
197
  new_object = obj.copy()
196
198
  new_object.data = obj.data.copy()
197
- context.scene.objects.link(new_object)
199
+ SCENE.objects.link(new_object)
198
200
  return new_object
199
201
 
200
202
  def random_text():
@@ -207,7 +209,7 @@ def create_mesh(name, verts, faces, location):
207
209
  mesh_data.update()
208
210
  obj = bpy.data.objects.new(name, mesh_data)
209
211
  obj.location = location
210
- context.scene.objects.link(obj)
212
+ SCENE.objects.link(obj)
211
213
  return obj
212
214
 
213
215
  def spawn_text():
@@ -216,11 +218,11 @@ def spawn_text():
216
218
  new_curve.extrude = 0.11
217
219
  new_text = bpy.data.objects.new("Text - " + identifier, new_curve)
218
220
  new_text.data.body = random_text()
219
- context.scene.objects.link(new_text)
221
+ SCENE.objects.link(new_text)
220
222
  return new_text
221
223
 
222
224
  def wireframize(obj):
223
- context.scene.objects.active = obj
225
+ SCENE.objects.active = obj
224
226
  bpy.ops.object.modifier_add(type='WIREFRAME')
225
227
  obj.modifiers['Wireframe'].thickness = WIREFRAME_THICKNESS
226
228
  make_object_emitter(obj, 2)
@@ -234,13 +236,14 @@ def series(length):
234
236
  return list(map(lambda x: (0, x, math.cos(x)), pitched_array(0.0, length, 0.1)))
235
237
 
236
238
  def randomize_reflectors_colors():
237
- for r in bpy.data.groups['Plane'].objects:
239
+ for r in bpy.data.groups['Reflectors'].objects:
238
240
  r.data.materials[-1].node_tree.nodes['Emission'].inputs[0].default_value = rand_color()
239
241
 
240
242
  def add_object(obj, x, y, z, radius):
241
243
  infer_primitive(obj, location=(x, y, z), radius=radius)
242
244
  WIREFRAMES.append(last_added_object(obj))
243
245
  group_add(obj, last_added_object(obj))
246
+ return last_added_object(obj)
244
247
 
245
248
  def infer_primitive(obj, **kwargs):
246
249
  if obj == 'CUBE':
@@ -268,22 +271,28 @@ def last_object_group(group_name):
268
271
  return bpy.data.groups[group_name.lower().title()].objects[-1]
269
272
 
270
273
  def build_composite_object(obj, size, radius):
271
- build_grid_object(obj, size, -size, radius)
274
+ res = []
275
+ res.append(build_grid_object(obj, size, -size, radius))
272
276
  for z in range(0, size):
273
- build_grid_object(obj, size, last_object_group(obj).location.z + 2 * radius, radius)
277
+ res.append(build_grid_object(obj, size, last_object_group(obj).location.z + 2 * radius, radius))
278
+ return res
274
279
 
275
280
  def build_grid_object(obj, size, z_index, radius):
276
- build_object_line(obj, size, z_index, -size, radius)
281
+ res = []
282
+ res.append(build_object_line(obj, size, z_index, -size, radius))
277
283
  for y in range(0, size):
278
- build_object_line(obj, size, z_index, last_object_group(obj).location.y + 2 * radius, radius)
284
+ res.append(build_object_line(obj, size, z_index, last_object_group(obj).location.y + 2 * radius, radius))
285
+ return res
279
286
 
280
287
  def build_object_line(obj, size, z_index, y_index, radius):
281
- add_object(obj, -size, y_index, z_index, radius)
288
+ res = []
289
+ res.append(add_object(obj, -size, y_index, z_index, radius))
282
290
  for x in range(0, size):
283
291
  new_obj = duplicate_object(last_object_group(obj))
284
- WIREFRAMES.append(new_obj)
285
292
  group_add(obj, new_obj)
293
+ res.append(new_obj)
286
294
  new_obj.location = ((last_object_group(obj).location.x + 2 * radius), y_index, z_index)
295
+ return res
287
296
 
288
297
  # Displace vertex by random offset
289
298
  def displace_vector(vector):
@@ -309,9 +318,9 @@ def displace(object):
309
318
  vertex.co = displace_vector(vertex.co)
310
319
 
311
320
  def subdivide(object, cuts):
312
- if context.scene.objects.active != object:
313
- context.scene.objects.active = object
314
- assert context.scene.objects.active == object
321
+ if SCENE.objects.active != object:
322
+ SCENE.objects.active = object
323
+ assert SCENE.objects.active == object
315
324
  bpy.ops.object.mode_set(mode='EDIT')
316
325
  for index in range(0, cuts):
317
326
  bpy.ops.mesh.subdivide(cuts)
@@ -320,7 +329,7 @@ def clone(obj):
320
329
  new_obj = obj.copy()
321
330
  new_obj.data = obj.data.copy()
322
331
  new_obj.animation_data_clear()
323
- context.scene.objects.link(new_obj)
332
+ SCENE.objects.link(new_obj)
324
333
  return new_obj
325
334
 
326
335
  def add_ocean(spatial_size, resolution, depth = 100, scale=(4,4,4)):
@@ -342,9 +351,9 @@ def add_ocean(spatial_size, resolution, depth = 100, scale=(4,4,4)):
342
351
  return [ocean, shadow]
343
352
 
344
353
  # Delete current objects
345
- def flush_all_objects():
346
- for index, obj in enumerate(bpy.data.objects):
347
- bpy.data.objects.remove(obj)
354
+ def flush_objects(objs = bpy.data.objects):
355
+ for obj in objs:
356
+ bpy.data.objects.remove(obj, do_unlink=True)
348
357
 
349
358
  # Rotate hue to generate palette
350
359
  def adjacent_colors(r, g, b, number):
@@ -453,19 +462,16 @@ def animation_routine(frame):
453
462
  display.rotation_euler.x += math.radians(2)
454
463
 
455
464
  def create_line(name, point_list, thickness = 0.002, location = (0, -10, 0)):
456
- # setup basic line data
457
465
  line_data = bpy.data.curves.new(name=name,type='CURVE')
458
466
  line_data.dimensions = '3D'
459
467
  line_data.fill_mode = 'FULL'
460
468
  line_data.bevel_depth = thickness
461
- # define points that make the line
462
469
  polyline = line_data.splines.new('POLY')
463
470
  polyline.points.add(len(point_list)-1)
464
471
  for idx in range(len(point_list)):
465
472
  polyline.points[idx].co = (point_list[idx])+(1.0,)
466
- # create an object that uses the linedata
467
473
  line = bpy.data.objects.new('line' + str(uuid.uuid1()), line_data)
468
- bpy.context.scene.objects.link(line)
474
+ SCENE.objects.link(line)
469
475
  line.location = location
470
476
  make_object_emitter(line, 0.8)
471
477
  return line
@@ -491,3 +497,15 @@ def make_world_volumetric(world, scatter_intensity = SCATTER_INTENSITY, absorpti
491
497
  scatter_node.inputs['Density'].default_value = SCATTER_INTENSITY
492
498
  absorption_node.inputs['Density'].default_value = ABSORPTION_INTENSITY
493
499
  bg_node.inputs[0].default_value = rand_color()
500
+
501
+ def make_object_fluid_collider(obj):
502
+ obj.modifiers.new(name='obstacle', type='FLUID_SIMULATION')
503
+ obj.modifiers['obstacle'].settings.type = 'OBSTACLE'
504
+ obj.modifiers['obstacle'].settings.volume_initialization = 'BOTH'
505
+ obj.modifiers['obstacle'].settings.partial_slip_factor = 0.15
506
+
507
+ def add_frame(collection = bpy.data.objects):
508
+ for obj in collection:
509
+ obj.keyframe_insert(data_path="rotation_euler", index=-1)
510
+ obj.keyframe_insert(data_path="location", index=-1)
511
+ obj.keyframe_insert(data_path="scale", index=-1)
@@ -1,7 +1,7 @@
1
1
  def let_there_be_light(scene):
2
- add_spotlight((0, 0, 12), 14000, math.radians(60))
3
- spot1 = add_spotlight((0, 8, 4), 8000, math.radians(60))
4
- spot2 = add_spotlight((0, -8, 4), 8000, math.radians(60))
2
+ add_spotlight((0, 0, 12), 15000, math.radians(70))
3
+ spot1 = add_spotlight((0, 8, 4), 9000, math.radians(70))
4
+ spot2 = add_spotlight((0, -8, 4), 9000, math.radians(70))
5
5
  spot1.rotation_euler.x -= math.radians(90)
6
6
  spot2.rotation_euler.x += math.radians(90)
7
7
 
@@ -13,10 +13,10 @@ def let_there_be_light(scene):
13
13
  reflector2 = bpy.data.objects['Plane.001']
14
14
  reflector3 = bpy.data.objects['Plane.002']
15
15
 
16
- bpy.data.groups.new('Plane')
17
- bpy.data.groups['Plane'].objects.link(reflector1)
18
- bpy.data.groups['Plane'].objects.link(reflector2)
19
- bpy.data.groups['Plane'].objects.link(reflector3)
16
+ for r in [reflector1, reflector2, reflector3]:
17
+ r.cycles_visibility.camera = False
18
+ bpy.data.groups['Planes'].objects.link(r)
19
+ bpy.data.groups['Reflectors'].objects.link(r)
20
20
 
21
21
  reflector2.rotation_euler.x += math.radians(90)
22
22
  reflector1.rotation_euler.x += math.radians(90)
@@ -1,8 +1,6 @@
1
1
  # Rendering script
2
2
  # Run by calling the blender executable with -b -P <script_name>
3
3
  # Use `pry()` to pry into the script
4
- # DISCLAIMER: all of this could be done in a much more intelligent way (with more Python knowledge)
5
- # This is just what works for now for the needs of my current project
6
4
 
7
5
  import argparse
8
6
 
@@ -49,8 +47,10 @@ exec(open(os.path.join(path + '/glitch3d/bpy', 'lighting.py')).read())
49
47
  WIREFRAMES = []
50
48
  VORONOIED = []
51
49
  OCEAN = []
52
- bpy.data.groups.new('Lines')
53
- bpy.data.groups.new('Displays')
50
+
51
+ for s in ['Lines', 'Displays', 'Reflectors', 'Planes']:
52
+ bpy.data.groups.new(s)
53
+
54
54
  LINES = bpy.data.groups['Lines'].objects
55
55
  for primitive in PRIMITIVES:
56
56
  bpy.data.groups.new(primitive.lower().title())
@@ -64,16 +64,17 @@ TEXTURE_FOLDER_PATH = FIXTURES_FOLDER_PATH + 'textures/'
64
64
  # Scene
65
65
  context = bpy.context
66
66
  new_scene = bpy.data.scenes.new("Automated Render Scene")
67
- bpy.ops.scene.delete() # Delete old scene
68
- context.screen.scene = new_scene # selects the new scene as the current one
67
+ bpy.ops.scene.delete()
68
+ context.screen.scene = new_scene
69
+ SCENE = new_scene
69
70
 
70
- flush_all_objects()
71
+ flush_objects()
71
72
 
72
73
  camera_data = bpy.data.cameras['Camera']
73
74
  bpy.data.objects.new('Camera', object_data=camera_data)
74
75
  CAMERA = bpy.data.objects['Camera']
75
76
  new_scene.objects.link(CAMERA)
76
- context.scene.camera = CAMERA
77
+ SCENE.camera = CAMERA
77
78
  CAMERA.location = INITIAL_CAMERA_LOCATION
78
79
 
79
80
  if FISHEYE:
@@ -84,7 +85,7 @@ if FISHEYE:
84
85
  CAMERA.data.sensor_width = 20
85
86
  CAMERA.data.sensor_height = 20
86
87
 
87
- render_settings(context.scene, animate, mode)
88
+ render_settings(animate, mode)
88
89
 
89
90
  # Load model
90
91
  model_path = os.path.join(file)
@@ -94,32 +95,29 @@ SUBJECT.select = True
94
95
  bpy.ops.object.origin_set(type="ORIGIN_CENTER_OF_MASS")
95
96
  SUBJECT.location = ORIGIN
96
97
  make_object_glossy(SUBJECT, YELLOW, 0.01)
97
-
98
- let_there_be_light(context.scene)
98
+ look_at(SUBJECT)
99
+ let_there_be_light(SCENE)
99
100
 
100
101
  if debug == False:
101
- # exec(open(os.path.join(path + '/glitch3d/bpy/canvas', 'dreamatorium.py')).read())
102
+ exec(open(os.path.join(path + '/glitch3d/bpy/canvas', 'lyfe.py')).read())
103
+ exec(open(os.path.join(path + '/glitch3d/bpy/canvas', 'dreamatorium.py')).read())
102
104
  exec(open(os.path.join(path + '/glitch3d/bpy/canvas', 'aether.py')).read())
103
105
 
104
- print('Rendering images with resolution: ' + str(context.scene.render.resolution_x) + ' x ' + str(context.scene.render.resolution_y))
106
+ print('Rendering images with resolution: ' + str(SCENE.render.resolution_x) + ' x ' + str(SCENE.render.resolution_y))
105
107
 
106
- for plane in bpy.data.groups['Plane'].objects:
108
+ for plane in bpy.data.groups['Planes'].objects:
107
109
  unwrap_model(plane)
108
110
 
109
111
  if animate:
110
112
  print('ANIMATION RENDERING BEGIN')
111
- context.scene.frame_start = 0
112
- context.scene.frame_end = NUMBER_OF_FRAMES
113
- bpy.ops.screen.frame_jump(end=False)
113
+ SCENE.frame_start = 0
114
+ SCENE.frame_end = NUMBER_OF_FRAMES
114
115
  CAMERA_PATH = camera_path(0.008)
115
116
 
116
117
  for frame in range(0, NUMBER_OF_FRAMES):
117
- bpy.context.scene.frame_set(frame)
118
+ SCENE.frame_set(frame)
118
119
  animation_routine(frame - 1)
119
- for obj in context.scene.objects:
120
- obj.keyframe_insert(data_path="rotation_euler", index=-1)
121
- obj.keyframe_insert(data_path="location", index=-1)
122
- bpy.ops.screen.frame_jump(end=False)
120
+ add_frame()
123
121
  shoot(output_name(model_path))
124
122
 
125
123
  else:
@@ -127,8 +125,8 @@ if debug == False:
127
125
  for index in range(0, int(shots_number)):
128
126
  print("-------------------------- " + str(index) + " --------------------------")
129
127
  still_routine(index)
128
+ SCENE.frame_set(int(SCENE.frame_end/(index+1)))
130
129
  look_at(SUBJECT)
131
- bpy.context.scene.frame_set(int(context.scene.frame_end/(index+1)))
132
130
  shoot(output_name(model_path, index))
133
131
 
134
132
 
@@ -1,26 +1,26 @@
1
- def render_settings(scene, animate, mode):
2
- scene.render.resolution_x = 2000
3
- scene.render.resolution_y = 2000
4
- scene.render.engine = 'CYCLES'
5
- scene.render.resolution_percentage = 25
1
+ def render_settings(animate, mode):
2
+ SCENE.render.resolution_x = 2000
3
+ SCENE.render.resolution_y = 2000
4
+ SCENE.render.engine = 'CYCLES'
5
+ SCENE.render.resolution_percentage = 25
6
6
 
7
- # bpy.scene.cycles.device = 'GPU'
8
- scene.render.image_settings.compression = 0
9
- scene.cycles.samples = 25
10
- scene.cycles.max_bounces = 1
11
- scene.cycles.min_bounces = 1
12
- scene.cycles.caustics_reflective = False
13
- scene.cycles.caustics_refractive = False
14
- scene.render.tile_x = 32
15
- scene.render.tile_y = 32
16
- scene.render.image_settings.color_mode ='RGBA'
7
+ # bpy.SCENE.cycles.device = 'GPU'
8
+ SCENE.render.image_settings.compression = 0
9
+ SCENE.cycles.samples = 25
10
+ SCENE.cycles.max_bounces = 1
11
+ SCENE.cycles.min_bounces = 1
12
+ SCENE.cycles.caustics_reflective = False
13
+ SCENE.cycles.caustics_refractive = False
14
+ SCENE.render.tile_x = 32
15
+ SCENE.render.tile_y = 32
16
+ SCENE.render.image_settings.color_mode ='RGBA'
17
17
 
18
18
  if animate:
19
- scene.render.image_settings.file_format='H264'
19
+ SCENE.render.image_settings.file_format='AVI_RAW'
20
20
  else:
21
- scene.render.image_settings.file_format='PNG'
21
+ SCENE.render.image_settings.file_format='PNG'
22
22
 
23
23
  if mode == 'high':
24
- scene.render.image_settings.compression = 90
25
- scene.cycles.samples = 400
26
- scene.render.resolution_percentage = 100
24
+ SCENE.render.image_settings.compression = 90
25
+ SCENE.cycles.samples = 400
26
+ SCENE.render.resolution_percentage = 100
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Glitch3d
3
- VERSION = '0.2.3.2'
3
+ VERSION = '0.2.3.3'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glitch3d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3.2
4
+ version: 0.2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - pskl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-23 00:00:00.000000000 Z
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,8 +106,10 @@ files:
106
106
  - fixtures/textures/kago.jpg
107
107
  - fixtures/textures/kawai.jpg
108
108
  - fixtures/textures/rug.jpg
109
+ - fixtures/textures/slavs.jpg
109
110
  - fixtures/textures/spiral.jpg
110
111
  - fixtures/textures/vapor.jpg
112
+ - fixtures/textures/woman.jpg
111
113
  - glitch3d.gemspec
112
114
  - image.py
113
115
  - lib/glitch3d.rb