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 +4 -4
- data/fixtures/textures/slavs.jpg +0 -0
- data/fixtures/textures/woman.jpg +0 -0
- data/lib/glitch3d/bpy/canvas/aether.py +18 -13
- data/lib/glitch3d/bpy/canvas/dreamatorium.py +9 -7
- data/lib/glitch3d/bpy/canvas/lyfe.py +46 -54
- data/lib/glitch3d/bpy/helpers.py +53 -35
- data/lib/glitch3d/bpy/lighting.py +7 -7
- data/lib/glitch3d/bpy/main.py +21 -23
- data/lib/glitch3d/bpy/render_settings.py +20 -20
- data/lib/glitch3d/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 246e3f5ad753205a1da7847ad49660d5760bccc2
|
4
|
+
data.tar.gz: 059bdda653c3cac77696c54204fa0e8710c23185
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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=
|
8
|
-
container =
|
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.
|
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.
|
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,
|
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, -
|
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
|
-
|
28
|
-
|
29
|
-
SUBJECT
|
30
|
-
|
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['
|
46
|
+
bpy.data.groups['Planes'].objects.link(floor)
|
42
47
|
floor.scale = (20,20,20)
|
43
|
-
subdivide(floor, int(random.uniform(
|
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['
|
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
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
7
|
-
for
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
cells[
|
22
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
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]
|
data/lib/glitch3d/bpy/helpers.py
CHANGED
@@ -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,
|
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(
|
26
|
+
def look_at(obj):
|
27
27
|
location_camera = CAMERA.matrix_world.to_translation()
|
28
|
-
location_object =
|
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
|
-
|
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
|
-
|
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(
|
97
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
221
|
+
SCENE.objects.link(new_text)
|
220
222
|
return new_text
|
221
223
|
|
222
224
|
def wireframize(obj):
|
223
|
-
|
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['
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
313
|
-
|
314
|
-
assert
|
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
|
-
|
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
|
346
|
-
for
|
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
|
-
|
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),
|
3
|
-
spot1 = add_spotlight((0, 8, 4),
|
4
|
-
spot2 = add_spotlight((0, -8, 4),
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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)
|
data/lib/glitch3d/bpy/main.py
CHANGED
@@ -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
|
-
|
53
|
-
|
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()
|
68
|
-
context.screen.scene = new_scene
|
67
|
+
bpy.ops.scene.delete()
|
68
|
+
context.screen.scene = new_scene
|
69
|
+
SCENE = new_scene
|
69
70
|
|
70
|
-
|
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
|
-
|
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(
|
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(
|
98
|
+
look_at(SUBJECT)
|
99
|
+
let_there_be_light(SCENE)
|
99
100
|
|
100
101
|
if debug == False:
|
101
|
-
|
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(
|
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['
|
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
|
-
|
112
|
-
|
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
|
-
|
118
|
+
SCENE.frame_set(frame)
|
118
119
|
animation_routine(frame - 1)
|
119
|
-
|
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(
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
+
SCENE.render.image_settings.file_format='AVI_RAW'
|
20
20
|
else:
|
21
|
-
|
21
|
+
SCENE.render.image_settings.file_format='PNG'
|
22
22
|
|
23
23
|
if mode == 'high':
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
SCENE.render.image_settings.compression = 90
|
25
|
+
SCENE.cycles.samples = 400
|
26
|
+
SCENE.render.resolution_percentage = 100
|
data/lib/glitch3d/version.rb
CHANGED
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.
|
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-
|
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
|