glitch3d 0.2.2.1 → 0.2.2.2
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/kago.jpg +0 -0
- data/fixtures/textures/spiral.jpg +0 -0
- data/lib/glitch3d/bpy/animation_recording.py +6 -4
- data/lib/glitch3d/bpy/helpers.py +51 -9
- data/lib/glitch3d/bpy/rendering.py +42 -25
- data/lib/glitch3d/version.rb +1 -1
- metadata +4 -3
- data/lib/glitch3d/bpy/uv_glitch.py +0 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 601218ffff3ed8224664f46004c6904e595e1828
         | 
| 4 | 
            +
              data.tar.gz: 6af29a322182537cf3276e1167e0f4baed417860
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a1a93d53edc0792de77cec65d854788ceb501bc9af3b690a888c526310111b2c53807cda5c2fbf5967994e0cbad30bdd38e840c94f8f37c91d78ff2d5dc53727
         | 
| 7 | 
            +
              data.tar.gz: d595211c09ce7ad96715cbee6d438d007deda6178686306a3b39ee82c8ad8ac03927c1abc782c13b71cf4571671af8e96df2bbbbd5847550bea8f13af7292a53
         | 
| Binary file | 
| Binary file | 
| @@ -1,11 +1,13 @@ | |
| 1 | 
            -
            scene =  | 
| 2 | 
            -
            scene. | 
| 3 | 
            -
            scene.frame_end   = NUMBER_OF_FRAMES
         | 
| 1 | 
            +
            context.scene.frame_start = 0
         | 
| 2 | 
            +
            context.scene.frame_end   = NUMBER_OF_FRAMES
         | 
| 4 3 | 
             
            bpy.ops.screen.frame_jump(end=False)
         | 
| 5 4 |  | 
| 6 5 | 
             
            for frame in range(1, NUMBER_OF_FRAMES):
         | 
| 7 6 | 
             
                bpy.context.scene.frame_set(frame)
         | 
| 8 | 
            -
             | 
| 7 | 
            +
             | 
| 8 | 
            +
                OCEAN.modifiers['Ocean'].time += 1
         | 
| 9 | 
            +
                model_object.rotation_euler.z += math.radians(10)
         | 
| 10 | 
            +
             | 
| 9 11 | 
             
                for ob in context.scene.objects:
         | 
| 10 12 | 
             
                    ob.keyframe_insert(data_path="location", index=-1)
         | 
| 11 13 |  | 
    
        data/lib/glitch3d/bpy/helpers.py
    CHANGED
    
    | @@ -50,13 +50,16 @@ def empty_materials(): | |
| 50 50 | 
             
                for material in bpy.data.materials.keys():
         | 
| 51 51 | 
             
                    bpy.data.materials.remove(object.data.materials[material])
         | 
| 52 52 |  | 
| 53 | 
            -
            def shoot(camera, model_object, filepath):
         | 
| 53 | 
            +
            def shoot(animate, camera, model_object, filepath):
         | 
| 54 54 | 
             
                directory = os.path.dirname('./renders')
         | 
| 55 55 | 
             
                if not os.path.exists(directory):
         | 
| 56 56 | 
             
                  os.makedirs(directory)
         | 
| 57 57 | 
             
                look_at(camera, model_object)
         | 
| 58 58 | 
             
                print('Camera now at location: ' + camera_location_string(camera) + ' / rotation: ' + camera_rotation_string(camera))
         | 
| 59 59 | 
             
                bpy.context.scene.render.filepath = filepath
         | 
| 60 | 
            +
                if animate:
         | 
| 61 | 
            +
                    bpy.context.scene.render.filepath = './renders/animation-' + str(uuid.uuid1()) + '/'
         | 
| 62 | 
            +
                    return bpy.ops.render.render(animation=animate)
         | 
| 60 63 | 
             
                bpy.ops.render.render(write_still=True)
         | 
| 61 64 |  | 
| 62 65 | 
             
            def output_name(index, model_path):
         | 
| @@ -122,11 +125,6 @@ def camera_location_string(camera): | |
| 122 125 | 
             
            def assign_material(model_object, material):
         | 
| 123 126 | 
             
                model_object.data.materials.append(material)
         | 
| 124 127 |  | 
| 125 | 
            -
            def assign_node_to_output(material, new_node):
         | 
| 126 | 
            -
                assert material.use_nodes == True
         | 
| 127 | 
            -
                output_node = material.node_tree.nodes['Material Output']
         | 
| 128 | 
            -
                material.node_tree.links.new(new_node.outputs[0], output_node.inputs['Surface'])
         | 
| 129 | 
            -
             | 
| 130 128 | 
             
            # Returns a new Cycles material with default DiffuseBsdf node linked to output
         | 
| 131 129 | 
             
            def create_cycles_material():
         | 
| 132 130 | 
             
                material = bpy.data.materials.new('Object Material - ' + str(uuid.uuid1()))
         | 
| @@ -147,6 +145,17 @@ def assign_texture_to_material(material, texture): | |
| 147 145 | 
             
                texture_node.image = texture
         | 
| 148 146 | 
             
                material.node_tree.links.new(texture_node.outputs['Color'], bsdf_node.inputs['Color'])
         | 
| 149 147 |  | 
| 148 | 
            +
            def assign_node_to_output(material, new_node):
         | 
| 149 | 
            +
                assert material.use_nodes == True
         | 
| 150 | 
            +
                output_node = material.node_tree.nodes['Material Output']
         | 
| 151 | 
            +
                material.node_tree.links.new(new_node.outputs[0], output_node.inputs['Surface'])
         | 
| 152 | 
            +
             | 
| 153 | 
            +
            def mix_nodes(material, node1, node2):
         | 
| 154 | 
            +
                mix = material.node_tree.nodes.new('ShaderNodeMixShader')
         | 
| 155 | 
            +
                material.node_tree.links.new(mix.inputs[1], node1.outputs[0])
         | 
| 156 | 
            +
                material.node_tree.links.new(mix.inputs[2], node2.outputs[0])
         | 
| 157 | 
            +
                assign_node_to_output(material, mix)
         | 
| 158 | 
            +
             | 
| 150 159 | 
             
            def make_object_glossy(obj, color):
         | 
| 151 160 | 
             
                material = bpy.data.materials.new('Glossy Material - ' + str(uuid.uuid1()))
         | 
| 152 161 | 
             
                material.use_nodes = True
         | 
| @@ -181,6 +190,19 @@ def make_object_emitter(obj, emission_strength): | |
| 181 190 | 
             
                assign_material(obj, emissive_material)
         | 
| 182 191 | 
             
                return emission_node
         | 
| 183 192 |  | 
| 193 | 
            +
            def make_object_gradient_fabulous(obj, color1, color2):
         | 
| 194 | 
            +
                material = bpy.data.materials.new('Fabulous #' + str(uuid.uuid1()))
         | 
| 195 | 
            +
                material.use_nodes = True
         | 
| 196 | 
            +
                assign_material(obj, material)
         | 
| 197 | 
            +
                mixer_node = material.node_tree.nodes.new('ShaderNodeMixRGB')
         | 
| 198 | 
            +
                gradient_node = material.node_tree.nodes.new('ShaderNodeTexGradient')
         | 
| 199 | 
            +
                bsdf_node = material.node_tree.nodes.new('ShaderNodeBsdfDiffuse')
         | 
| 200 | 
            +
                material.node_tree.links.new(gradient_node.outputs['Fac'], mixer_node.inputs['Fac'])
         | 
| 201 | 
            +
                material.node_tree.links.new(mixer_node.outputs[0], bsdf_node.inputs['Color'])
         | 
| 202 | 
            +
                assign_node_to_output(material, bsdf_node)
         | 
| 203 | 
            +
                mixer_node.inputs['Color1'].default_value = color1
         | 
| 204 | 
            +
                mixer_node.inputs['Color2'].default_value = color2
         | 
| 205 | 
            +
             | 
| 184 206 | 
             
            def texture_object(obj):
         | 
| 185 207 | 
             
                new_material = create_cycles_material()
         | 
| 186 208 | 
             
                assign_texture_to_material(new_material, random_texture())
         | 
| @@ -309,6 +331,8 @@ def add_ocean(spatial_size, resolution): | |
| 309 331 | 
             
                ocean.modifiers["Ocean"].spatial_size = spatial_size
         | 
| 310 332 | 
             
                ocean.modifiers["Ocean"].resolution = resolution
         | 
| 311 333 | 
             
                make_object_glossy(ocean, rand_color())
         | 
| 334 | 
            +
                make_object_gradient_fabulous(ocean, rand_color(), rand_color())
         | 
| 335 | 
            +
                mix_nodes(ocean.data.materials[0], ocean.data.materials[0].node_tree.nodes['Diffuse BSDF'], ocean.data.materials[0].node_tree.nodes['Glossy BSDF'])
         | 
| 312 336 | 
             
                ocean.name = 'Ocean'
         | 
| 313 337 | 
             
                return ocean
         | 
| 314 338 |  | 
| @@ -335,7 +359,7 @@ def adjacent_colors(r, g, b, number): | |
| 335 359 | 
             
            def rand_color_palette(number):
         | 
| 336 360 | 
             
                return adjacent_colors(rand_color_value(), rand_color_value(), rand_color_value(), number)
         | 
| 337 361 |  | 
| 338 | 
            -
            def build_pyramid(width=1 | 
| 362 | 
            +
            def build_pyramid(width=random.uniform(1,3), length=random.uniform(1,3), height=random.uniform(1,3), location=ORIGIN):
         | 
| 339 363 | 
             
                verts=[]
         | 
| 340 364 | 
             
                faces=[]
         | 
| 341 365 | 
             
                verts.append([-(width/2),(length/2),0.0])
         | 
| @@ -348,6 +372,24 @@ def build_pyramid(width=1.0, length=1.0, height=1.0, location=ORIGIN): | |
| 348 372 | 
             
                faces.append([1,2,4])
         | 
| 349 373 | 
             
                faces.append([2,3,4])
         | 
| 350 374 | 
             
                faces.append([3,0,4])
         | 
| 351 | 
            -
                 | 
| 352 | 
            -
             | 
| 375 | 
            +
                return create_mesh('Pyramid ' + str(uuid.uuid1()), verts, faces, location)
         | 
| 376 | 
            +
             | 
| 377 | 
            +
            def dance_routine():
         | 
| 378 | 
            +
                camera_object.location.x = INITIAL_CAMERA_LOCATION[0] + round(random.uniform(-2, 2), 10)
         | 
| 379 | 
            +
                camera_object.location.y = INITIAL_CAMERA_LOCATION[1] + round(random.uniform(-2, 2), 10)
         | 
| 380 | 
            +
                look_at(camera_object, model_object)
         | 
| 381 | 
            +
                randomize_reflectors_colors()
         | 
| 382 | 
            +
                OCEAN.modifiers['Ocean'].time += 1
         | 
| 383 | 
            +
                OCEAN.modifiers['Ocean'].random_seed = round(random.uniform(0, 100))
         | 
| 384 | 
            +
                make_object_glossy(OCEAN, rand_color())
         | 
| 385 | 
            +
                OCEAN.modifiers['Ocean'].choppiness += 0.3
         | 
| 386 | 
            +
                for prop in props:
         | 
| 387 | 
            +
                    prop.location = rand_location()
         | 
| 388 | 
            +
                    prop.rotation_euler = rand_rotation()
         | 
| 389 | 
            +
                for obj in WIREFRAMES:
         | 
| 390 | 
            +
                    rotate(obj, index)
         | 
| 391 | 
            +
                    obj.location.z += round(random.uniform(-1, 1), 10)
         | 
| 392 | 
            +
                    obj.rotation_euler.z += math.radians(round(random.uniform(0, 90)))
         | 
| 393 | 
            +
                for display in bpy.data.groups['Displays'].objects:
         | 
| 394 | 
            +
                    display.location = rand_location()
         | 
| 353 395 |  | 
| @@ -11,7 +11,6 @@ | |
| 11 11 | 
             
            # Use `debug()` to pry into the script
         | 
| 12 12 | 
             
            import os
         | 
| 13 13 | 
             
            exec(open(os.path.join(os.path.dirname(__file__), 'helpers.py')).read())
         | 
| 14 | 
            -
            exec(open(os.path.join(os.path.dirname(__file__), 'animation_recording.py')).read())
         | 
| 15 14 |  | 
| 16 15 | 
             
            # Arguments parsing
         | 
| 17 16 | 
             
            args = get_args()
         | 
| @@ -26,6 +25,7 @@ DEBUG = False | |
| 26 25 | 
             
            FISHEYE = False
         | 
| 27 26 | 
             
            COLORS = rand_color_palette(5)
         | 
| 28 27 | 
             
            INITIAL_CAMERA_LOCATION = (8, 8, 1)
         | 
| 28 | 
            +
            ANIMATE = False
         | 
| 29 29 |  | 
| 30 30 | 
             
            if DEBUG:
         | 
| 31 31 | 
             
                shots_number = 2
         | 
| @@ -63,6 +63,7 @@ if mode == 'high': | |
| 63 63 | 
             
                context.scene.render.resolution_percentage = 100
         | 
| 64 64 |  | 
| 65 65 | 
             
            # Add background to world
         | 
| 66 | 
            +
            bpy.data.worlds.remove(bpy.data.worlds[0])
         | 
| 66 67 | 
             
            world = bpy.data.worlds.new('A Brave New World')
         | 
| 67 68 | 
             
            world.use_nodes = True
         | 
| 68 69 | 
             
            world_node_tree = world.node_tree
         | 
| @@ -81,7 +82,8 @@ model_object = bpy.data.objects[0] | |
| 81 82 | 
             
            bpy.ops.import_scene.obj(filepath = os.path.join(FIXTURES_FOLDER_PATH + 'm4a1.obj'), use_edges=True)
         | 
| 82 83 | 
             
            m4a1 = bpy.data.objects['m4a1']
         | 
| 83 84 | 
             
            m4a1.location = rand_location()
         | 
| 84 | 
            -
            m4a1.scale = (0. | 
| 85 | 
            +
            m4a1.scale = (0.5, 0.5, 0.5)
         | 
| 86 | 
            +
            props.append(m4a1)
         | 
| 85 87 |  | 
| 86 88 | 
             
            # Use center of mass to center object
         | 
| 87 89 | 
             
            model_object.select = True
         | 
| @@ -134,9 +136,9 @@ make_object_reflector(reflector2) | |
| 134 136 | 
             
            make_object_reflector(reflector3)
         | 
| 135 137 |  | 
| 136 138 | 
             
            # Set up virtual displays
         | 
| 137 | 
            -
            bpy.ops.mesh.primitive_grid_add(x_subdivisions=100, y_subdivisions=100, location=(0,  | 
| 139 | 
            +
            bpy.ops.mesh.primitive_grid_add(x_subdivisions=100, y_subdivisions=100, location=(0, 6, 2))
         | 
| 138 140 | 
             
            display1 = bpy.data.objects['Grid']
         | 
| 139 | 
            -
            bpy.ops.mesh.primitive_grid_add(x_subdivisions=100, y_subdivisions=100, location=( | 
| 141 | 
            +
            bpy.ops.mesh.primitive_grid_add(x_subdivisions=100, y_subdivisions=100, location=(6, 0, 2))
         | 
| 140 142 | 
             
            display2 = bpy.data.objects['Grid.001']
         | 
| 141 143 |  | 
| 142 144 | 
             
            bpy.data.groups.new('Displays')
         | 
| @@ -144,13 +146,21 @@ bpy.data.groups['Displays'].objects.link(display1) | |
| 144 146 | 
             
            bpy.data.groups['Displays'].objects.link(display2)
         | 
| 145 147 |  | 
| 146 148 | 
             
            display1.rotation_euler.x += math.radians(90)
         | 
| 149 | 
            +
            display1.rotation_euler.z -= math.radians(90)
         | 
| 147 150 | 
             
            display2.rotation_euler.x += math.radians(90)
         | 
| 151 | 
            +
            display2.rotation_euler.y += math.radians(90)
         | 
| 152 | 
            +
            display2.rotation_euler.z += math.radians(120)
         | 
| 148 153 |  | 
| 149 | 
            -
            for display in [ | 
| 154 | 
            +
            for display in bpy.data.groups['Displays'].objects:
         | 
| 155 | 
            +
                display.rotation_euler.x += math.radians(90)
         | 
| 156 | 
            +
                display.scale = (3,3,3)
         | 
| 150 157 | 
             
                texture_object(display)
         | 
| 151 158 | 
             
                unwrap_model(display)
         | 
| 152 159 | 
             
                glitch(display)
         | 
| 153 160 |  | 
| 161 | 
            +
            glitch(m4a1)
         | 
| 162 | 
            +
            make_object_gradient_fabulous(m4a1, rand_color(), rand_color())
         | 
| 163 | 
            +
             | 
| 154 164 | 
             
            # Adjust camera
         | 
| 155 165 | 
             
            context.scene.camera = camera_object
         | 
| 156 166 | 
             
            look_at(camera_object, model_object)
         | 
| @@ -181,29 +191,36 @@ for plane in bpy.data.groups['Plane'].objects: | |
| 181 191 | 
             
            for obj in WIREFRAMES:
         | 
| 182 192 | 
             
                wireframize(obj)
         | 
| 183 193 |  | 
| 194 | 
            +
            if ANIMATE == True:
         | 
| 195 | 
            +
                exec(open(os.path.join(os.path.dirname(__file__), 'animation_recording.py')).read())
         | 
| 196 | 
            +
             | 
| 184 197 | 
             
            # ------
         | 
| 185 198 | 
             
            # Shoot
         | 
| 186 199 | 
             
            # ------
         | 
| 187 200 | 
             
            print('Rendering images with resolution: ' + str(context.scene.render.resolution_x) + ' x ' + str(context.scene.render.resolution_y))
         | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
                 | 
| 191 | 
            -
                 | 
| 192 | 
            -
                 | 
| 193 | 
            -
                 | 
| 194 | 
            -
             | 
| 195 | 
            -
                 | 
| 196 | 
            -
             | 
| 197 | 
            -
             | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
                     | 
| 201 | 
            -
             | 
| 202 | 
            -
             | 
| 203 | 
            -
             | 
| 204 | 
            -
             | 
| 205 | 
            -
             | 
| 206 | 
            -
                 | 
| 207 | 
            -
                 | 
| 201 | 
            +
             | 
| 202 | 
            +
            if ANIMATE:
         | 
| 203 | 
            +
                print('ANIMATION RENDERING BEGIN')
         | 
| 204 | 
            +
                context.scene.frame_start = 0
         | 
| 205 | 
            +
                context.scene.frame_end   = NUMBER_OF_FRAMES
         | 
| 206 | 
            +
                bpy.ops.screen.frame_jump(end=False)
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                for frame in range(1, NUMBER_OF_FRAMES):
         | 
| 209 | 
            +
                    bpy.context.scene.frame_set(frame)
         | 
| 210 | 
            +
             | 
| 211 | 
            +
                    dance_routine()
         | 
| 212 | 
            +
             | 
| 213 | 
            +
                    for ob in context.scene.objects:
         | 
| 214 | 
            +
                        ob.keyframe_insert(data_path="location", index=-1)
         | 
| 215 | 
            +
             | 
| 216 | 
            +
                bpy.ops.screen.frame_jump(end=False)
         | 
| 217 | 
            +
                shoot(True, camera_object, model_object, output_name(index, model_path))
         | 
| 218 | 
            +
            else:
         | 
| 219 | 
            +
                print('STILL RENDERING BEGIN')
         | 
| 220 | 
            +
                for index in range(0, int(shots_number)):
         | 
| 221 | 
            +
                    print("-------------------------- " + str(index) + " --------------------------")
         | 
| 222 | 
            +
                    shoot(False, camera_object, model_object, output_name(index, model_path))
         | 
| 223 | 
            +
                    dance_routine()
         | 
| 224 | 
            +
             | 
| 208 225 |  | 
| 209 226 | 
             
            print('FINISHED ¯\_(ツ)_/¯')
         | 
    
        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.2
         | 
| 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-24 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -98,12 +98,13 @@ files: | |
| 98 98 | 
             
            - fixtures/textures/anime.jpg
         | 
| 99 99 | 
             
            - fixtures/textures/checkered_texture.jpg
         | 
| 100 100 | 
             
            - fixtures/textures/grid.jpg
         | 
| 101 | 
            +
            - fixtures/textures/kago.jpg
         | 
| 102 | 
            +
            - fixtures/textures/spiral.jpg
         | 
| 101 103 | 
             
            - glitch3d.gemspec
         | 
| 102 104 | 
             
            - lib/glitch3d.rb
         | 
| 103 105 | 
             
            - lib/glitch3d/bpy/animation_recording.py
         | 
| 104 106 | 
             
            - lib/glitch3d/bpy/helpers.py
         | 
| 105 107 | 
             
            - lib/glitch3d/bpy/rendering.py
         | 
| 106 | 
            -
            - lib/glitch3d/bpy/uv_glitch.py
         | 
| 107 108 | 
             
            - lib/glitch3d/objects/face.rb
         | 
| 108 109 | 
             
            - lib/glitch3d/objects/vertex.rb
         | 
| 109 110 | 
             
            - lib/glitch3d/strategies/default.rb
         | 
| @@ -1 +0,0 @@ | |
| 1 | 
            -
            # Glitch UV map
         |