glitch3d 0.2.2.5 → 0.2.2.6
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/COPYING +4 -0
- data/README.md +10 -7
- data/lib/glitch3d/bpy/helpers.py +25 -22
- data/lib/glitch3d/bpy/main.py +15 -33
- data/lib/glitch3d/version.rb +1 -1
- data/lib/glitch3d.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7868c484686bc50595abbf027cc494d1219f8469
|
4
|
+
data.tar.gz: 3cedc59d39b7eeb4667fa786e45621089e2897c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1b3e77e1adb9f7bbbf34e84703f00c736a9f2a945ba8b1405f7bff630d16e5f680c330bc15f6f4e62f75499d42cdf150380640eb3e52848099ab4bbb1d721e5
|
7
|
+
data.tar.gz: 96304f191ac1b70089237ff4beb99d1fde0a904ef64003f5335e6fb41efba0fc1e54a012c8742e81720f3d64688df1c2ebc978a23d7b25cc5dd8cbb4aabff5ee
|
data/COPYING
ADDED
data/README.md
CHANGED
@@ -30,10 +30,13 @@ Or install it yourself as:
|
|
30
30
|
|
31
31
|
- `glitch3d file.obj`
|
32
32
|
|
33
|
+
will
|
33
34
|
Options:
|
34
|
-
- `mode` : (localized|default|none)
|
35
|
-
- `shots-number` : integer representing the number of - images desired
|
36
|
-
- `quality` : (high|low)
|
35
|
+
- `mode` : (localized|default|none) => glitching strategy
|
36
|
+
- `shots-number` : integer representing the number of - images desired (with animate: false)
|
37
|
+
- `quality` : (high: 2000 x 2000|low 200 x 200) default: low => size of the render
|
38
|
+
- `animate` : (true) default: false => Render .avi file
|
39
|
+
- `frame_numbers` : (default: 200) => number of frames
|
37
40
|
|
38
41
|
## Development
|
39
42
|
|
@@ -48,7 +51,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/pskl/g
|
|
48
51
|
|
49
52
|
## License
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
54
|
+
Copyright © 217 PSKL <hello@pascal.cc>
|
55
|
+
This work is free. You can redistribute it and/or modify it under the
|
56
|
+
terms of the Do What The Fuck You Want To Public License, Version 2,
|
57
|
+
as published by Sam Hocevar. See the COPYING file for more details.
|
data/lib/glitch3d/bpy/helpers.py
CHANGED
@@ -9,7 +9,7 @@ DISPLACEMENT_AMPLITUDE = random.uniform(0.02, 0.1)
|
|
9
9
|
REPLACE_TARGET = str(random.uniform(0, 9))
|
10
10
|
REPLACEMENT = str(random.uniform(0, 9))
|
11
11
|
ORIGIN = (0,0,2)
|
12
|
-
NUMBER_OF_FRAMES =
|
12
|
+
NUMBER_OF_FRAMES = 200
|
13
13
|
SCATTER_INTENSITY = 0.015
|
14
14
|
ABSORPTION_INTENSITY = 0.25
|
15
15
|
DISPLAY_SCALE = (2, 2, 2)
|
@@ -39,15 +39,11 @@ def empty_materials():
|
|
39
39
|
for material in bpy.data.materials.keys():
|
40
40
|
bpy.data.materials.remove(object.data.materials[material])
|
41
41
|
|
42
|
-
def shoot(
|
43
|
-
directory = os.path.dirname('./renders')
|
44
|
-
if not os.path.exists(directory):
|
45
|
-
os.makedirs(directory)
|
46
|
-
look_at(model_object)
|
42
|
+
def shoot(filepath):
|
47
43
|
print('Camera now at location: ' + camera_location_string(CAMERA) + ' / rotation: ' + camera_rotation_string(CAMERA))
|
48
44
|
bpy.context.scene.render.filepath = filepath
|
49
45
|
if animate:
|
50
|
-
return bpy.ops.render.render(animation=animate)
|
46
|
+
return bpy.ops.render.render(animation=animate, write_still=True)
|
51
47
|
bpy.ops.render.render(write_still=True)
|
52
48
|
|
53
49
|
def output_name(index, model_path):
|
@@ -56,8 +52,8 @@ def output_name(index, model_path):
|
|
56
52
|
else:
|
57
53
|
return './renders/' + os.path.splitext(model_path)[0].split('/')[-1] + '_' + str(index) + '_' + str(datetime.date.today()) + '_' + str(mode) + '.png'
|
58
54
|
|
59
|
-
def rotate(
|
60
|
-
|
55
|
+
def rotate(SUBJECT, index):
|
56
|
+
SUBJECT.rotation_euler[2] = math.radians(index * (360.0 / shots_number))
|
61
57
|
|
62
58
|
# RGB 0 -> 1
|
63
59
|
def rand_color_value():
|
@@ -102,8 +98,8 @@ def camera_rotation_string(camera):
|
|
102
98
|
def camera_location_string(camera):
|
103
99
|
return str(int(camera.location.x)) + ' ' + str(int(camera.location.y)) + ' ' + str(int(camera.location.z))
|
104
100
|
|
105
|
-
def assign_material(
|
106
|
-
|
101
|
+
def assign_material(SUBJECT, material):
|
102
|
+
SUBJECT.data.materials.append(material)
|
107
103
|
|
108
104
|
# Returns a new Cycles material with default DiffuseBsdf node linked to output
|
109
105
|
def create_cycles_material():
|
@@ -241,7 +237,7 @@ def shuffle(obj):
|
|
241
237
|
obj.rotation_euler = rand_rotation()
|
242
238
|
|
243
239
|
def series(length):
|
244
|
-
return list(map(lambda x: (0, x, math.cos(x)),
|
240
|
+
return list(map(lambda x: (0, x, math.cos(x)), pitched_array(0.0, length, 0.1)))
|
245
241
|
|
246
242
|
def randomize_reflectors_colors():
|
247
243
|
for r in bpy.data.groups['Plane'].objects:
|
@@ -300,14 +296,17 @@ def displace_vector(vector):
|
|
300
296
|
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)))
|
301
297
|
|
302
298
|
# Replace vertex coordinate everywhere
|
303
|
-
def find_and_replace(vector, target
|
299
|
+
def find_and_replace(vector, target, replacement):
|
304
300
|
return mathutils.Vector((float(str(vector.x).replace(target, replacement)), float(str(vector.y).replace(target, replacement)), float(str(vector.z).replace(target, replacement))))
|
305
301
|
|
306
302
|
def glitch(object):
|
307
303
|
bpy.ops.object.mode_set(mode='OBJECT')
|
308
304
|
assert object.type == 'MESH'
|
305
|
+
ints = list(range(10))
|
306
|
+
target = str(ints.pop(int(random.uniform(0, len(ints) - 1))))
|
307
|
+
replacement = str(ints.pop(int(random.uniform(0, len(ints)))))
|
309
308
|
for vertex in object.data.vertices:
|
310
|
-
vertex.co = find_and_replace(vertex.co)
|
309
|
+
vertex.co = find_and_replace(vertex.co, target, replacement)
|
311
310
|
|
312
311
|
def displace(object):
|
313
312
|
bpy.ops.object.mode_set(mode='OBJECT')
|
@@ -391,27 +390,30 @@ def move_ocean(ocean):
|
|
391
390
|
ocean.modifiers['Ocean'].random_seed = round(random.uniform(0, 100))
|
392
391
|
ocean.modifers['Ocean'].choppiness += 0.3
|
393
392
|
|
394
|
-
def camera_path(pitch):
|
393
|
+
def camera_path(pitch = 0.0001):
|
395
394
|
res = []
|
396
395
|
initial_z = INITIAL_CAMERA_LOCATION[2]
|
397
396
|
initial_x = INITIAL_CAMERA_LOCATION[0]
|
398
|
-
for y in
|
397
|
+
for y in pitched_array(initial_x, -initial_x, pitch):
|
399
398
|
res.append((initial_x, y, initial_z))
|
400
|
-
for x in
|
399
|
+
for x in pitched_array(initial_x, -initial_x, pitch):
|
401
400
|
res.append((x,-initial_x, initial_z))
|
402
|
-
for y in
|
401
|
+
for y in pitched_array(-initial_x, initial_x, pitch):
|
403
402
|
res.append((-initial_x, y, initial_z))
|
404
|
-
for x in
|
403
|
+
for x in pitched_array(-initial_x, initial_x, pitch):
|
405
404
|
res.append((x, initial_x, initial_z))
|
406
405
|
return res
|
407
406
|
|
407
|
+
def pitched_array(min, max, pitch):
|
408
|
+
return list(map(lambda x: (min + pitch * x), range(int((max - min) / pitch))))
|
409
|
+
|
408
410
|
def still_routine():
|
409
411
|
CAMERA.location.x = INITIAL_CAMERA_LOCATION[0] + round(random.uniform(-2, 2), 10)
|
410
412
|
CAMERA.location.y = INITIAL_CAMERA_LOCATION[1] + round(random.uniform(-2, 2), 10)
|
411
413
|
randomize_reflectors_colors()
|
412
414
|
map(move_ocean, OCEAN)
|
413
415
|
map(make_object_glossy, OCEAN)
|
414
|
-
rotate(
|
416
|
+
rotate(SUBJECT, index)
|
415
417
|
for l in bpy.data.groups['Lines'].objects:
|
416
418
|
rotation = rand_rotation()
|
417
419
|
l.rotation_euler = rotation
|
@@ -428,11 +430,12 @@ def still_routine():
|
|
428
430
|
def animation_routine(frame):
|
429
431
|
assert len(camera_path) >= NUMBER_OF_FRAMES
|
430
432
|
CAMERA.location = camera_path[frame]
|
433
|
+
look_at(SUBJECT)
|
431
434
|
randomize_reflectors_colors()
|
432
435
|
map(move_ocean, OCEAN)
|
433
436
|
map(make_object_glossy, OCEAN)
|
434
|
-
glitch(
|
435
|
-
|
437
|
+
glitch(SUBJECT)
|
438
|
+
SUBJECT.rotation_euler.z += math.radians(4)
|
436
439
|
for l in bpy.data.groups['Lines'].objects:
|
437
440
|
l.rotation_euler.x += math.radians(5)
|
438
441
|
l.rotation_euler.z += math.radians(5)
|
data/lib/glitch3d/bpy/main.py
CHANGED
@@ -28,39 +28,20 @@ path = str(args.path)
|
|
28
28
|
animate = (args.animate == 'True')
|
29
29
|
shots_number = int(args.shots_number)
|
30
30
|
|
31
|
-
import os
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
import mathutils
|
38
|
-
import random
|
39
|
-
import uuid
|
40
|
-
import sys
|
41
|
-
import logging
|
42
|
-
import string
|
43
|
-
import colorsys
|
44
|
-
import numpy
|
45
|
-
import code
|
46
|
-
|
47
|
-
# DEBUG = True
|
48
|
-
if DEBUG:
|
49
|
-
shots_number = 2
|
50
|
-
import os
|
51
|
-
mode = 'low'
|
52
|
-
animate = False
|
53
|
-
file = "/Users/pascal/dev/glitch3d/fixtures/skull.obj"
|
54
|
-
path = "/Users/pascal/dev/glitch3d/lib/"
|
31
|
+
import os, bpy, datetime, bmesh, random, math, mathutils, random, uuid, sys, logging, string, colorsys, code
|
32
|
+
|
33
|
+
# Create directory for renders
|
34
|
+
directory = os.path.dirname('./renders')
|
35
|
+
if not os.path.exists(directory):
|
36
|
+
os.makedirs(directory)
|
55
37
|
|
56
38
|
exec(open(os.path.join(path + '/glitch3d/bpy', 'helpers.py')).read())
|
57
39
|
exec(open(os.path.join(path + '/glitch3d/bpy', 'render_settings.py')).read())
|
58
40
|
exec(open(os.path.join(path + '/glitch3d/bpy', 'lighting.py')).read())
|
59
41
|
|
60
|
-
DEBUG = False
|
61
42
|
FISHEYE = True
|
62
43
|
COLORS = rand_color_palette(5)
|
63
|
-
INITIAL_CAMERA_LOCATION = (
|
44
|
+
INITIAL_CAMERA_LOCATION = (3, 3, 1)
|
64
45
|
FIXTURES_FOLDER_PATH = path + '/../fixtures/'
|
65
46
|
TEXTURE_FOLDER_PATH = FIXTURES_FOLDER_PATH + 'textures/'
|
66
47
|
|
@@ -96,12 +77,12 @@ for primitive in PRIMITIVES:
|
|
96
77
|
# Load model
|
97
78
|
model_path = os.path.join(file)
|
98
79
|
bpy.ops.import_scene.obj(filepath = model_path, use_edges=True)
|
99
|
-
|
100
|
-
|
80
|
+
SUBJECT = bpy.data.objects['glitch3d']
|
81
|
+
SUBJECT.select = True
|
101
82
|
bpy.ops.object.origin_set(type="ORIGIN_CENTER_OF_MASS")
|
102
|
-
|
103
|
-
make_object_glossy(
|
104
|
-
voronoize(
|
83
|
+
SUBJECT.location = ORIGIN
|
84
|
+
make_object_glossy(SUBJECT, YELLOW, 0.1)
|
85
|
+
voronoize(SUBJECT)
|
105
86
|
|
106
87
|
let_there_be_light(context.scene)
|
107
88
|
|
@@ -122,14 +103,15 @@ if animate:
|
|
122
103
|
for ob in context.scene.objects:
|
123
104
|
ob.keyframe_insert(data_path="location", index=-1)
|
124
105
|
bpy.ops.screen.frame_jump(end=False)
|
125
|
-
shoot(
|
106
|
+
shoot(output_name(index, model_path))
|
126
107
|
|
127
108
|
else:
|
128
109
|
print('STILL RENDERING BEGIN')
|
129
110
|
for index in range(0, int(shots_number)):
|
130
111
|
print("-------------------------- " + str(index) + " --------------------------")
|
131
112
|
still_routine()
|
132
|
-
|
113
|
+
look_at(SUBJECT)
|
114
|
+
shoot(output_name(index, model_path))
|
133
115
|
|
134
116
|
|
135
117
|
print('FINISHED ¯\_(ツ)_/¯')
|
data/lib/glitch3d/version.rb
CHANGED
data/lib/glitch3d.rb
CHANGED
@@ -137,9 +137,10 @@ module Glitch3d
|
|
137
137
|
boundaries = Vertex.boundaries(content_hash[:vertices])
|
138
138
|
File.open(target_file, 'w') do |f|
|
139
139
|
f.puts '# Data corrupted with glitch3D script'
|
140
|
+
f.puts model_name
|
140
141
|
f.puts '# Boundaries: ' + boundaries.to_s
|
141
142
|
f.puts ''
|
142
|
-
f.puts "g
|
143
|
+
f.puts "g glitch3d"
|
143
144
|
f.puts ''
|
144
145
|
f.puts content_hash[:vertices].map(&:to_s)
|
145
146
|
f.puts ''
|
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.6
|
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-
|
11
|
+
date: 2017-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- ".rspec"
|
80
80
|
- ".travis.yml"
|
81
81
|
- CODE_OF_CONDUCT.md
|
82
|
+
- COPYING
|
82
83
|
- Gemfile
|
83
84
|
- LICENSE.txt
|
84
85
|
- README.md
|