glitch3d 0.2.2.2 → 0.2.2.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/afx_face.jpeg +0 -0
- data/fixtures/textures/afx_logo.jpg +0 -0
- data/fixtures/textures/kawai.jpg +0 -0
- data/fixtures/textures/vapor.jpg +0 -0
- data/lib/glitch3d/bpy/helpers.py +54 -7
- data/lib/glitch3d/bpy/rendering.py +24 -14
- data/lib/glitch3d/strategies/duplication.rb +17 -7
- data/lib/glitch3d/strategies/find_and_replace.rb +5 -0
- data/lib/glitch3d/version.rb +1 -1
- metadata +6 -3
- data/lib/glitch3d/bpy/animation_recording.py +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4f2f6d21ae96e8105a1c6da16f6e1fb2838f1d9
|
4
|
+
data.tar.gz: d9860cd506ad2b7c87ea43f3da5527a0282402c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d980c45b765663cd5aa61736b6f79b82b9d75993efec48806e668e800077ab41ec513a4b99ee2b6be7d3a4d21b6df0d6c33bc803992995e24e4b23084e685c7c
|
7
|
+
data.tar.gz: 1db6e37de5e965a3ea6ff0526c4bdfb0be99d1c7782f39668c8c9ea876985ff02ded591c2ec76f5cf3378e0d76e7cbc0065c376b914c1e47e70546331abef6e8
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/glitch3d/bpy/helpers.py
CHANGED
@@ -12,6 +12,7 @@ import sys
|
|
12
12
|
import logging
|
13
13
|
import string
|
14
14
|
import colorsys
|
15
|
+
import numpy
|
15
16
|
|
16
17
|
REFLECTOR_SCALE = random.uniform(4, 6)
|
17
18
|
REFLECTOR_STRENGTH = random.uniform(8, 12)
|
@@ -63,7 +64,7 @@ def shoot(animate, camera, model_object, filepath):
|
|
63
64
|
bpy.ops.render.render(write_still=True)
|
64
65
|
|
65
66
|
def output_name(index, model_path):
|
66
|
-
return './renders/' + os.path.splitext(model_path)[0].split('/')[-1] + '_' + str(index) + '_' + str(datetime.date.today()) + '.png'
|
67
|
+
return './renders/' + os.path.splitext(model_path)[0].split('/')[-1] + '_' + str(index) + '_' + str(datetime.date.today()) + '_' + str(mode) + '.png'
|
67
68
|
|
68
69
|
def rotate(model_object, index):
|
69
70
|
model_object.rotation_euler[2] = math.radians(index * (360.0 / shots_number))
|
@@ -81,6 +82,9 @@ def rand_rotation():
|
|
81
82
|
def rand_rotation_value():
|
82
83
|
return round(random.uniform(0, 1), 10)
|
83
84
|
|
85
|
+
def rand_rotation():
|
86
|
+
return (random.uniform(0, 20), random.uniform(0, 20), random.uniform(0, 20))
|
87
|
+
|
84
88
|
def rand_location_value():
|
85
89
|
return round(random.uniform(-4, 4), 10)
|
86
90
|
|
@@ -140,10 +144,11 @@ def random_texture():
|
|
140
144
|
|
141
145
|
def assign_texture_to_material(material, texture):
|
142
146
|
assert material.use_nodes == True
|
143
|
-
bsdf_node = material.node_tree.nodes['Diffuse BSDF']
|
144
147
|
texture_node = material.node_tree.nodes.new('ShaderNodeTexImage')
|
148
|
+
emission_node = material.node_tree.nodes.new('ShaderNodeEmission')
|
149
|
+
material.node_tree.links.new(texture_node.outputs['Color'], emission_node.inputs['Color'])
|
145
150
|
texture_node.image = texture
|
146
|
-
material
|
151
|
+
assign_node_to_output(material, emission_node)
|
147
152
|
|
148
153
|
def assign_node_to_output(material, new_node):
|
149
154
|
assert material.use_nodes == True
|
@@ -196,6 +201,7 @@ def make_object_gradient_fabulous(obj, color1, color2):
|
|
196
201
|
assign_material(obj, material)
|
197
202
|
mixer_node = material.node_tree.nodes.new('ShaderNodeMixRGB')
|
198
203
|
gradient_node = material.node_tree.nodes.new('ShaderNodeTexGradient')
|
204
|
+
gradient_node.gradient_type = 'SPHERICAL'
|
199
205
|
bsdf_node = material.node_tree.nodes.new('ShaderNodeBsdfDiffuse')
|
200
206
|
material.node_tree.links.new(gradient_node.outputs['Fac'], mixer_node.inputs['Fac'])
|
201
207
|
material.node_tree.links.new(mixer_node.outputs[0], bsdf_node.inputs['Color'])
|
@@ -248,6 +254,9 @@ def shuffle(obj):
|
|
248
254
|
obj.scale = rand_scale_vector()
|
249
255
|
obj.rotation_euler = rand_rotation()
|
250
256
|
|
257
|
+
def series(length):
|
258
|
+
return list(map(lambda x: (0, x, math.cos(x)), numpy.arange(0.0, length, 0.1)))
|
259
|
+
|
251
260
|
def randomize_reflectors_colors():
|
252
261
|
reflector1.data.materials[-1].node_tree.nodes['Emission'].inputs[0].default_value = rand_color()
|
253
262
|
reflector2.data.materials[-1].node_tree.nodes['Emission'].inputs[0].default_value = rand_color()
|
@@ -301,7 +310,7 @@ def build_object_line(obj, size, z_index, y_index, radius):
|
|
301
310
|
new_obj.location = ((last_object_group(obj).location.x + 2 * radius), y_index, z_index)
|
302
311
|
|
303
312
|
# Displace vertex by random offset
|
304
|
-
def
|
313
|
+
def displace_vector(vector):
|
305
314
|
return mathutils.Vector((vector.x + random.uniform(-DISPLACEMENT_AMPLITUDE, DISPLACEMENT_AMPLITUDE), vector.y + random.uniform(-DISPLACEMENT_AMPLITUDE, DISPLACEMENT_AMPLITUDE), vector.z + random.uniform(-DISPLACEMENT_AMPLITUDE, DISPLACEMENT_AMPLITUDE)))
|
306
315
|
|
307
316
|
# Replace vertex coordinate everywhere
|
@@ -314,6 +323,12 @@ def glitch(object):
|
|
314
323
|
for vertex in object.data.vertices:
|
315
324
|
vertex.co = find_and_replace(vertex.co)
|
316
325
|
|
326
|
+
def displace(object):
|
327
|
+
bpy.ops.object.mode_set(mode='OBJECT')
|
328
|
+
assert object.type == 'MESH'
|
329
|
+
for vertex in object.data.vertices:
|
330
|
+
vertex.co = displace_vector(vertex.co)
|
331
|
+
|
317
332
|
def subdivide(object, cuts):
|
318
333
|
if context.scene.objects.active != object:
|
319
334
|
context.scene.objects.active = object
|
@@ -322,6 +337,13 @@ def subdivide(object, cuts):
|
|
322
337
|
for index in range(0, cuts):
|
323
338
|
bpy.ops.mesh.subdivide(cuts)
|
324
339
|
|
340
|
+
def clone(obj):
|
341
|
+
new_obj = obj.copy()
|
342
|
+
new_obj.data = obj.data.copy()
|
343
|
+
new_obj.animation_data_clear()
|
344
|
+
context.scene.objects.link(new_obj)
|
345
|
+
return new_obj
|
346
|
+
|
325
347
|
def add_ocean(spatial_size, resolution):
|
326
348
|
bpy.ops.mesh.primitive_cube_add(location=(0, 0, -1),radius=1)
|
327
349
|
ocean = last_added_object('CUBE')
|
@@ -333,7 +355,11 @@ def add_ocean(spatial_size, resolution):
|
|
333
355
|
make_object_glossy(ocean, rand_color())
|
334
356
|
make_object_gradient_fabulous(ocean, rand_color(), rand_color())
|
335
357
|
mix_nodes(ocean.data.materials[0], ocean.data.materials[0].node_tree.nodes['Diffuse BSDF'], ocean.data.materials[0].node_tree.nodes['Glossy BSDF'])
|
336
|
-
|
358
|
+
shadow = clone(ocean)
|
359
|
+
shadow.location.x += 3
|
360
|
+
wireframize(shadow)
|
361
|
+
shadow.name = 'ocean'
|
362
|
+
ocean.name = 'ocean'
|
337
363
|
return ocean
|
338
364
|
|
339
365
|
# Delete current objects
|
@@ -377,12 +403,15 @@ def build_pyramid(width=random.uniform(1,3), length=random.uniform(1,3), height=
|
|
377
403
|
def dance_routine():
|
378
404
|
camera_object.location.x = INITIAL_CAMERA_LOCATION[0] + round(random.uniform(-2, 2), 10)
|
379
405
|
camera_object.location.y = INITIAL_CAMERA_LOCATION[1] + round(random.uniform(-2, 2), 10)
|
380
|
-
look_at(camera_object, model_object)
|
381
406
|
randomize_reflectors_colors()
|
382
407
|
OCEAN.modifiers['Ocean'].time += 1
|
383
408
|
OCEAN.modifiers['Ocean'].random_seed = round(random.uniform(0, 100))
|
384
409
|
make_object_glossy(OCEAN, rand_color())
|
385
410
|
OCEAN.modifiers['Ocean'].choppiness += 0.3
|
411
|
+
rotate(model_object, index)
|
412
|
+
for l in bpy.data.groups['Lines'].objects:
|
413
|
+
rotation = rand_rotation()
|
414
|
+
l.rotation_euler = rotation
|
386
415
|
for prop in props:
|
387
416
|
prop.location = rand_location()
|
388
417
|
prop.rotation_euler = rand_rotation()
|
@@ -392,4 +421,22 @@ def dance_routine():
|
|
392
421
|
obj.rotation_euler.z += math.radians(round(random.uniform(0, 90)))
|
393
422
|
for display in bpy.data.groups['Displays'].objects:
|
394
423
|
display.location = rand_location()
|
395
|
-
|
424
|
+
rotate(display, index)
|
425
|
+
|
426
|
+
def create_line(name, point_list, thickness = 0.002, location = (0, -10, 0)):
|
427
|
+
# setup basic line data
|
428
|
+
line_data = bpy.data.curves.new(name=name,type='CURVE')
|
429
|
+
line_data.dimensions = '3D'
|
430
|
+
line_data.fill_mode = 'FULL'
|
431
|
+
line_data.bevel_depth = thickness
|
432
|
+
# define points that make the line
|
433
|
+
polyline = line_data.splines.new('POLY')
|
434
|
+
polyline.points.add(len(point_list)-1)
|
435
|
+
for idx in range(len(point_list)):
|
436
|
+
polyline.points[idx].co = (point_list[idx])+(1.0,)
|
437
|
+
# create an object that uses the linedata
|
438
|
+
line = bpy.data.objects.new('LineOne', line_data)
|
439
|
+
bpy.context.scene.objects.link(line)
|
440
|
+
line.location = location
|
441
|
+
make_object_emitter(line, 0.8)
|
442
|
+
return line
|
@@ -22,11 +22,12 @@ shots_number = int(args.shots_number)
|
|
22
22
|
FIXTURES_FOLDER_PATH = path + '/../fixtures/'
|
23
23
|
|
24
24
|
DEBUG = False
|
25
|
-
FISHEYE =
|
25
|
+
FISHEYE = True
|
26
26
|
COLORS = rand_color_palette(5)
|
27
|
-
INITIAL_CAMERA_LOCATION = (
|
27
|
+
INITIAL_CAMERA_LOCATION = (4, 4, 1)
|
28
28
|
ANIMATE = False
|
29
29
|
|
30
|
+
# DEBUG = True
|
30
31
|
if DEBUG:
|
31
32
|
shots_number = 2
|
32
33
|
import os
|
@@ -46,8 +47,8 @@ for primitive in PRIMITIVES:
|
|
46
47
|
bpy.data.groups.new(primitive.lower().title())
|
47
48
|
|
48
49
|
# Render settings
|
49
|
-
context.scene.render.resolution_x =
|
50
|
-
context.scene.render.resolution_y =
|
50
|
+
context.scene.render.resolution_x = 2000
|
51
|
+
context.scene.render.resolution_y = 2000
|
51
52
|
context.scene.render.engine = 'CYCLES'
|
52
53
|
context.scene.render.resolution_percentage = 25
|
53
54
|
# uncomment if GPU
|
@@ -63,7 +64,9 @@ if mode == 'high':
|
|
63
64
|
context.scene.render.resolution_percentage = 100
|
64
65
|
|
65
66
|
# Add background to world
|
66
|
-
|
67
|
+
|
68
|
+
# This shit doesnt work in v 2.76
|
69
|
+
# bpy.data.worlds.remove(bpy.data.worlds[0])
|
67
70
|
world = bpy.data.worlds.new('A Brave New World')
|
68
71
|
world.use_nodes = True
|
69
72
|
world_node_tree = world.node_tree
|
@@ -107,15 +110,15 @@ camera_object.location = INITIAL_CAMERA_LOCATION
|
|
107
110
|
if FISHEYE:
|
108
111
|
camera_object.data.type = 'PANO'
|
109
112
|
camera_object.data.cycles.panorama_type = 'FISHEYE_EQUISOLID'
|
110
|
-
camera_object.data.cycles.fisheye_lens =
|
111
|
-
camera_object.data.cycles.fisheye_fov = 2.
|
112
|
-
camera_object.data.sensor_width =
|
113
|
-
camera_object.data.sensor_height =
|
113
|
+
camera_object.data.cycles.fisheye_lens = 12
|
114
|
+
camera_object.data.cycles.fisheye_fov = 2.5
|
115
|
+
camera_object.data.sensor_width = 20
|
116
|
+
camera_object.data.sensor_height = 20
|
114
117
|
|
115
118
|
# Add reflectors
|
116
119
|
bpy.ops.mesh.primitive_plane_add(location=(0,8 + REFLECTOR_LOCATION_PADDING, 0))
|
117
120
|
bpy.ops.mesh.primitive_plane_add(location=(8 + REFLECTOR_LOCATION_PADDING,0,0))
|
118
|
-
bpy.ops.mesh.primitive_plane_add(location=(0, 0,
|
121
|
+
bpy.ops.mesh.primitive_plane_add(location=(0, 0, 20))
|
119
122
|
bpy.ops.mesh.primitive_plane_add(location=(0, 0, -2))
|
120
123
|
|
121
124
|
reflector1 = bpy.data.objects['Plane']
|
@@ -167,13 +170,20 @@ look_at(camera_object, model_object)
|
|
167
170
|
|
168
171
|
# Make floor
|
169
172
|
floor = bpy.data.objects['Plane.003']
|
173
|
+
bpy.data.groups['Plane'].objects.link(floor)
|
170
174
|
floor.scale = (20,20,20)
|
171
|
-
texture_object(floor)
|
172
175
|
subdivide(floor, 8)
|
173
|
-
|
176
|
+
displace(floor)
|
177
|
+
texture_object(floor)
|
174
178
|
|
175
179
|
OCEAN = add_ocean(10, 20)
|
176
180
|
|
181
|
+
# Create lines
|
182
|
+
bpy.data.groups.new('Lines')
|
183
|
+
for i in range(0, 20):
|
184
|
+
new_line = create_line('line' + str(uuid.uuid1()), series(30))
|
185
|
+
new_line.location.z += i / 6
|
186
|
+
|
177
187
|
for index in range(1, len(WORDS)):
|
178
188
|
new_object = spawn_text()
|
179
189
|
props.append(new_object)
|
@@ -191,8 +201,8 @@ for plane in bpy.data.groups['Plane'].objects:
|
|
191
201
|
for obj in WIREFRAMES:
|
192
202
|
wireframize(obj)
|
193
203
|
|
194
|
-
|
195
|
-
|
204
|
+
look_at(camera_object, model_object)
|
205
|
+
model_object.location.z += 2
|
196
206
|
|
197
207
|
# ------
|
198
208
|
# Shoot
|
@@ -2,21 +2,31 @@
|
|
2
2
|
module Glitch3d
|
3
3
|
module Duplication
|
4
4
|
def alter_vertices(vertices_objects_array)
|
5
|
-
iteration_number = 2
|
6
|
-
res = []
|
7
|
-
iteration_number.times do |_|
|
8
|
-
|
9
|
-
end
|
10
|
-
res
|
5
|
+
# iteration_number = 2
|
6
|
+
# res = []
|
7
|
+
# iteration_number.times do |_|
|
8
|
+
# res = copy_random_element(vertices_objects_array, iteration_number, CHUNK_SIZE)
|
9
|
+
# end
|
10
|
+
# res
|
11
|
+
shuffle_vertices(vertices_objects_array)
|
11
12
|
end
|
12
13
|
|
13
14
|
def alter_faces(faces_objects_array, vertex_objects_array)
|
14
15
|
faces_objects_array
|
15
16
|
end
|
16
17
|
|
18
|
+
def shuffle_vertices(array)
|
19
|
+
2.times do
|
20
|
+
rand_index1 = rand(0..array.size - 1)
|
21
|
+
rand_index2 = rand(0..array.size - 1)
|
22
|
+
array[rand_index1], array[rand_index2] = array[rand_index2], array[rand_index1]
|
23
|
+
end
|
24
|
+
array
|
25
|
+
end
|
26
|
+
|
17
27
|
def copy_random_element(collection, iteration_number, chunk_size)
|
18
28
|
new_array = collection
|
19
|
-
iteration_number.times do
|
29
|
+
iteration_number.times do
|
20
30
|
rand1 = rand(0..collection.size - 1)
|
21
31
|
rand2 = rand(0..collection.size - 1)
|
22
32
|
new_array[rand1..rand1 + chunk_size] = new_array[rand2..rand2 + chunk_size]
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Glitch3d
|
3
3
|
module FindAndReplace
|
4
|
+
# Find and replace for vertices
|
4
5
|
def alter_vertices(vertices_objects_array)
|
5
6
|
@target = rand(9).to_s
|
6
7
|
@replacement = rand(9).to_s
|
@@ -10,7 +11,11 @@ module Glitch3d
|
|
10
11
|
vertices_objects_array
|
11
12
|
end
|
12
13
|
|
14
|
+
# Assign some faces to different vertices
|
13
15
|
def alter_faces(faces_objects_array, vertices_objects_array)
|
16
|
+
faces_objects_array.sample(3) do |face|
|
17
|
+
face.v1 = rand(0..vertices_objects_array.size - 1)
|
18
|
+
end
|
14
19
|
faces_objects_array
|
15
20
|
end
|
16
21
|
|
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.2.
|
4
|
+
version: 0.2.2.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-09-
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,14 +95,17 @@ files:
|
|
95
95
|
- fixtures/mars.obj
|
96
96
|
- fixtures/mecha.obj
|
97
97
|
- fixtures/skull.obj
|
98
|
+
- fixtures/textures/afx_face.jpeg
|
99
|
+
- fixtures/textures/afx_logo.jpg
|
98
100
|
- fixtures/textures/anime.jpg
|
99
101
|
- fixtures/textures/checkered_texture.jpg
|
100
102
|
- fixtures/textures/grid.jpg
|
101
103
|
- fixtures/textures/kago.jpg
|
104
|
+
- fixtures/textures/kawai.jpg
|
102
105
|
- fixtures/textures/spiral.jpg
|
106
|
+
- fixtures/textures/vapor.jpg
|
103
107
|
- glitch3d.gemspec
|
104
108
|
- lib/glitch3d.rb
|
105
|
-
- lib/glitch3d/bpy/animation_recording.py
|
106
109
|
- lib/glitch3d/bpy/helpers.py
|
107
110
|
- lib/glitch3d/bpy/rendering.py
|
108
111
|
- lib/glitch3d/objects/face.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
context.scene.frame_start = 0
|
2
|
-
context.scene.frame_end = NUMBER_OF_FRAMES
|
3
|
-
bpy.ops.screen.frame_jump(end=False)
|
4
|
-
|
5
|
-
for frame in range(1, NUMBER_OF_FRAMES):
|
6
|
-
bpy.context.scene.frame_set(frame)
|
7
|
-
|
8
|
-
OCEAN.modifiers['Ocean'].time += 1
|
9
|
-
model_object.rotation_euler.z += math.radians(10)
|
10
|
-
|
11
|
-
for ob in context.scene.objects:
|
12
|
-
ob.keyframe_insert(data_path="location", index=-1)
|
13
|
-
|
14
|
-
bpy.ops.screen.frame_jump(end=False)
|