glitch3d 0.1.2 → 0.1.4
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/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/glitch3d/bpy/helpers.py +36 -14
- data/lib/glitch3d/bpy/rendering.py +10 -20
- data/lib/glitch3d/version.rb +1 -1
- data/lib/glitch3d.rb +3 -1
- metadata +2 -6
- data/fixtures/textures/clouds.jpg +0 -0
- data/fixtures/textures/flowers.jpg +0 -0
- data/fixtures/textures/flowers1.jpg +0 -0
- data/fixtures/textures/granite.jpg +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eab3428beb9ab872707d266ddb1bdc9ffdc69bbb
|
4
|
+
data.tar.gz: b1af5a621c4cfb76a523ede94837d9c82fff1eb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dec0a64750aaa887a880293acdd19b44efde3b4dd15b8622a0da150aa981238f6495b1d983e10094c043c91b87bb6124587c7e3ff19075a89bdd09d5b927f60
|
7
|
+
data.tar.gz: 10c084a6f15c0e80daced25c590d1df1c93432f6e71e603b0596bfe50b12dd48e245352fad13f5d0a9e702bf5032b143aeebcf8586e74790b3868072c4400d55
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -43,7 +43,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
43
43
|
|
44
44
|
## Contributing
|
45
45
|
|
46
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pskl/glitch3d. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
47
47
|
|
48
48
|
|
49
49
|
## License
|
data/lib/glitch3d/bpy/helpers.py
CHANGED
@@ -9,6 +9,7 @@ import mathutils
|
|
9
9
|
import random
|
10
10
|
import uuid
|
11
11
|
import sys
|
12
|
+
import logging
|
12
13
|
|
13
14
|
REFLECTOR_SCALE = 5
|
14
15
|
REFLECTOR_STRENGTH = 12
|
@@ -17,6 +18,7 @@ PROPS_NUMBER = 100
|
|
17
18
|
SHADERS = ['ShaderNodeBsdfGlossy', 'ShaderNodeBsdfDiffuse', 'ShaderNodeBsdfVelvet', 'ShaderNodeEmission']
|
18
19
|
props = []
|
19
20
|
YELLOW = (1,0.7,0.1,1)
|
21
|
+
WORDS = ['POWER', 'MONEY', 'SEX', 'BLOOD', 'DOLLARS', 'PSKL', 'SKYNET', 'LOVE']
|
20
22
|
|
21
23
|
def debug():
|
22
24
|
code.interact(local=dict(globals(), **locals()))
|
@@ -59,7 +61,7 @@ def rand_rotation_value():
|
|
59
61
|
return round(random.uniform(0, 1), 10)
|
60
62
|
|
61
63
|
def rand_location_value():
|
62
|
-
return round(random.uniform(-
|
64
|
+
return round(random.uniform(-4, 4), 10)
|
63
65
|
|
64
66
|
def rand_color_vector():
|
65
67
|
return (rand_color_value(), rand_color_value(), rand_color_value(), 1)
|
@@ -72,7 +74,7 @@ def rand_scale_vector():
|
|
72
74
|
return(scale, scale, scale)
|
73
75
|
|
74
76
|
def unwrap_model(obj):
|
75
|
-
if obj == camera_object:
|
77
|
+
if obj == camera_object or obj.name.startswith('Text'):
|
76
78
|
return False
|
77
79
|
context.scene.objects.active = obj
|
78
80
|
bpy.ops.object.mode_set(mode='EDIT')
|
@@ -80,17 +82,18 @@ def unwrap_model(obj):
|
|
80
82
|
bpy.ops.object.mode_set(mode='OBJECT')
|
81
83
|
|
82
84
|
def get_args():
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
85
|
+
parser = argparse.ArgumentParser()
|
86
|
+
# get all script args
|
87
|
+
_, all_arguments = parser.parse_known_args()
|
88
|
+
double_dash_index = all_arguments.index('--')
|
89
|
+
script_args = all_arguments[double_dash_index + 1: ]
|
90
|
+
# add parser rules
|
91
|
+
parser.add_argument('-f', '--file', help="obj file to render")
|
92
|
+
parser.add_argument('-n', '--shots-number', help="number of shots desired")
|
93
|
+
parser.add_argument('-m', '--mode', help="quality mode: low | high")
|
94
|
+
parser.add_argument('-p', '--path', help="root path of assets")
|
95
|
+
parsed_script_args, _ = parser.parse_known_args(script_args)
|
96
|
+
return parsed_script_args
|
94
97
|
|
95
98
|
def camera_rotation_string(camera):
|
96
99
|
return str(int(camera.rotation_euler.x)) + ' ' + str(int(camera.rotation_euler.y)) + ' ' + str(int(camera.rotation_euler.z))
|
@@ -113,8 +116,10 @@ def create_cycles_material():
|
|
113
116
|
return material
|
114
117
|
|
115
118
|
def random_texture():
|
116
|
-
texture_folder_path = os.path.dirname(__file__).replace('lib/glitch3d/bpy', 'fixtures/textures/')
|
117
119
|
texture_path = texture_folder_path + random.choice(os.listdir(texture_folder_path))
|
120
|
+
logging.info('---------')
|
121
|
+
logging.info(texture_folder_path)
|
122
|
+
logging.info('---------')
|
118
123
|
return bpy.data.images.load(texture_path)
|
119
124
|
|
120
125
|
def assign_texture_to_material(material, texture):
|
@@ -157,3 +162,20 @@ def duplicate_object(obj):
|
|
157
162
|
new_object.data = obj.data.copy()
|
158
163
|
context.scene.objects.link(new_object)
|
159
164
|
return new_object
|
165
|
+
|
166
|
+
def random_text():
|
167
|
+
return random.choice(WORDS)
|
168
|
+
|
169
|
+
def spawn_text():
|
170
|
+
identifier = str(uuid.uuid1())
|
171
|
+
new_curve = bpy.data.curves.new(type="FONT",name="Curve - " + identifier)
|
172
|
+
new_curve.extrude = 0.15
|
173
|
+
new_text = bpy.data.objects.new("Text - " + identifier, new_curve)
|
174
|
+
new_text.data.body = random_text()
|
175
|
+
bpy.context.scene.objects.link(new_text)
|
176
|
+
return new_text
|
177
|
+
|
178
|
+
def shuffle(obj):
|
179
|
+
obj.location = rand_location()
|
180
|
+
obj.scale = rand_scale_vector()
|
181
|
+
obj.rotation_euler = rand_rotation()
|
@@ -19,6 +19,7 @@ mode = args.mode
|
|
19
19
|
shots_number = int(args.shots_number)
|
20
20
|
|
21
21
|
context = bpy.context
|
22
|
+
texture_folder_path = str(args.path) + '/../fixtures/textures/'
|
22
23
|
|
23
24
|
# Scene
|
24
25
|
new_scene = bpy.data.scenes.new("Automated Render Scene")
|
@@ -38,18 +39,14 @@ context.scene.render.image_settings.file_format='PNG'
|
|
38
39
|
|
39
40
|
if mode == 'high':
|
40
41
|
context.scene.render.image_settings.compression = 90
|
41
|
-
context.scene.cycles.samples =
|
42
|
+
context.scene.cycles.samples = 400
|
42
43
|
context.scene.render.resolution_percentage = 100
|
43
44
|
|
44
45
|
# Add background to world
|
45
|
-
texture_path = os.path.expanduser('fixtures/textures/checkered_texture.jpg')
|
46
46
|
world = bpy.data.worlds[0]
|
47
47
|
world.use_nodes = True
|
48
48
|
world_node_tree = world.node_tree
|
49
|
-
|
50
|
-
texture_node = world_node_tree.nodes.new('ShaderNodeTexImage')
|
51
|
-
world_node_tree.links.new(texture_node.outputs['Color'], output_node.inputs['Color'])
|
52
|
-
texture_node.image = bpy.data.images.load(texture_path)
|
49
|
+
world_node_tree.nodes['Background'].inputs[0].default_value = rand_color_vector()
|
53
50
|
|
54
51
|
# Delete current objects
|
55
52
|
for index, obj in enumerate(bpy.data.objects):
|
@@ -128,26 +125,19 @@ for index in range(1, int(PROPS_NUMBER)):
|
|
128
125
|
new_object.location = rand_location()
|
129
126
|
texture_object(new_object)
|
130
127
|
|
131
|
-
for index in range(1, int(PROPS_NUMBER)):
|
132
|
-
new_object = duplicate_object(torus)
|
133
|
-
props.append(new_object)
|
134
|
-
new_object.location = rand_location()
|
135
|
-
texture_object(new_object)
|
136
|
-
|
137
|
-
for index in range(1, int(PROPS_NUMBER)):
|
138
|
-
new_object = duplicate_object(cone)
|
139
|
-
props.append(new_object)
|
140
|
-
new_object.location = rand_location()
|
141
|
-
texture_object(new_object)
|
142
|
-
|
143
128
|
# Import guns
|
144
129
|
for index in range(1, 5):
|
145
130
|
new_object = duplicate_object(m4a1)
|
146
131
|
props.append(new_object)
|
132
|
+
shuffle(new_object)
|
133
|
+
texture_object(new_object)
|
134
|
+
|
135
|
+
for index in range(1, len(WORDS)):
|
136
|
+
new_object = spawn_text()
|
137
|
+
props.append(new_object)
|
138
|
+
new_object.scale = (0.75, 0.75, 0.75)
|
147
139
|
new_object.location = rand_location()
|
148
|
-
new_object.scale = rand_scale_vector()
|
149
140
|
new_object.rotation_euler = rand_rotation()
|
150
|
-
texture_object(new_object)
|
151
141
|
|
152
142
|
for model in bpy.data.objects:
|
153
143
|
unwrap_model(model)
|
data/lib/glitch3d/version.rb
CHANGED
data/lib/glitch3d.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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pskl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,10 +92,6 @@ files:
|
|
92
92
|
- fixtures/male_head.obj
|
93
93
|
- fixtures/skull.obj
|
94
94
|
- fixtures/textures/checkered_texture.jpg
|
95
|
-
- fixtures/textures/clouds.jpg
|
96
|
-
- fixtures/textures/flowers.jpg
|
97
|
-
- fixtures/textures/flowers1.jpg
|
98
|
-
- fixtures/textures/granite.jpg
|
99
95
|
- glitch3d.gemspec
|
100
96
|
- lib/glitch3d.rb
|
101
97
|
- lib/glitch3d/bpy/helpers.py
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|