示例#1
0
    def render(self):
        RADIUS = 3
        ######################
        ## SMOKE SIMULATION ##
        ######################
        bpy.ops.mesh.primitive_cube_add(location=(0.0, 0.0, 4.0),
                                        radius=RADIUS)
        container = bpy.context.object
        container.name = 'smoke_container'
        container.modifiers.new(name='container', type='SMOKE')
        container.modifiers['container'].smoke_type = 'DOMAIN'
        container.modifiers[
            'container'].domain_settings.use_high_resolution = True
        container.modifiers['container'].domain_settings.vorticity = 3
        container.modifiers['container'].domain_settings.vorticity = 3
        container.modifiers["container"].domain_settings.alpha = -1.2
        helpers.assign_material(container,
                                bpy.data.materials['Smoke Domain Material'])
        emitter = self.spawn_emitter_smoke(self.ORIGIN)
        self.make_object_smoke_collider(self.SUBJECT)

        emitter.modifiers["emitter"].flow_settings.density = 1
        bpy.context.scene.frame_set(0)
        emitter.location = helpers.rand_location(7, positive=True)
        helpers.add_frame([emitter], ['location'])
        bpy.context.scene.frame_set(self.NUMBER_OF_FRAMES)
        emitter.location = (4, 4, 4)
        helpers.add_frame([emitter], ['location'])
示例#2
0
 def matthew_curve(self, obj, time, scale = 0.2):
   fx, fy, fz = self.rand_curve()
   verts =  [(fx(t), fy(t), fz(t)) for t in helpers.pitched_array(0, time, 0.2)]
   bpy.context.scene.objects.active = obj
   bpy.ops.object.select_all(action='DESELECT')
   for idx, coord in enumerate(verts[0::self.MESH_OCCURENCE]):
     new_obj = helpers.duplicate_object(obj)
     new_obj.select = True
     new_obj.location = coord
     new_obj.scale = (0.02,0.02,0.02) if idx % 2 == 0 else (0.05, 0.05, 0.05)
     new_obj.rotation_euler.z += idx * (2 * math.pi) / len(verts)
     bpy.context.scene.objects.active = new_obj
   bpy.ops.object.join()
   res = bpy.context.object
   res.name = 'fernandez'
   helpers.resize(res)
   helpers.center(res)
   helpers.decimate(res)
   helpers.assign_material(res, helpers.random_material(self.MATERIALS_NAMES))
   support = helpers.create_mesh('fernandez_support', verts, [], (0,0,0),  [[v, v+1] for v in range(0, (len(verts) - 1))])
   helpers.resize(support)
   helpers.center(support)
   helpers.extrude(support)
   helpers.assign_material(support, helpers.random_material(self.MATERIALS_NAMES))
   return res
示例#3
0
    def render(self):
        self.cubes = helpers.build_composite_object('Cube', self.SIZE - 1, 0.5)
        for a in self.cubes:
            for b in a:
                for c in b:
                    c.location += mathutils.Vector(
                        (self.SIZE / 2, self.SIZE / 2, self.SIZE / 2))
        self.cells = [[[0 for i in range(self.SIZE)] for k in range(self.SIZE)]
                      for j in range(self.SIZE)]
        self.next_generation = [[[0 for i in range(self.SIZE)]
                                 for k in range(self.SIZE)]
                                for j in range(self.SIZE)]

        for x in range(self.SIZE):
            for y in range(self.SIZE):
                for z in range(self.SIZE):
                    self.cubes[x][y][z].scale = (.1, .1, .1)
                    self.cells[x][y][z] = numpy.random.choice([0, 1],
                                                              1,
                                                              p=[0.6, 0.4])[0]
                    helpers.assign_material(
                        self.cubes[x][y][z],
                        helpers.random_material(self.MATERIALS_NAMES))

        print("Synthetic life begin")
        self.adjust_scale()
        for l in range(self.NUMBER_OF_FRAMES):
            bpy.context.scene.frame_set(l)
            print("Life in " + str(l))
            self.life(l)
示例#4
0
 def render(self):
     diameter = 4.0
     sz = 2.125 / diameter
     base_object = helpers.infer_primitive(random.choice(self.PRIMITIVES),
                                           location=(100, 100, 100),
                                           radius=sz)
     latitude = 16
     longitude = latitude * 2
     invlatitude = 1.0 / (latitude - 1)
     invlongitude = 1.0 / (longitude - 1)
     iprc = 0.0
     jprc = 0.0
     phi = 0.0
     theta = 0.0
     invfcount = 1.0 / (self.NUMBER_OF_FRAMES - 1)
     # Animate center of the sphere.
     center = Vector((0.0, 0.0, 0.0))
     startcenter = Vector((0.0, -4.0, 0.0))
     stopcenter = Vector((0.0, 4.0, 0.0))
     # Rotate cubes around the surface of the sphere.
     pt = Vector((0.0, 0.0, 0.0))
     rotpt = Vector((0.0, 0.0, 0.0))
     # Change the axis of rotation for the point.
     baseaxis = Vector((0.0, 1.0, 0.0))
     axis = Vector((0.0, 0.0, 0.0))
     # Slerp between two rotations for each cube.
     startrot = Quaternion((0.0, 1.0, 0.0), pi)
     stoprot = Quaternion((1.0, 0.0, 0.0), pi * 1.5)
     currot = Quaternion()
     for i in range(0, latitude, 1):
         iprc = i * invlatitude
         phi = pi * (i + 1) * invlatitude
         rad = 0.01 + sz * abs(sin(phi)) * 0.99
         pt.z = cos(phi) * diameter
         for j in range(0, longitude, 1):
             jprc = j * invlongitude
             theta = TWOPI * j / longitude
             pt.y = center.y + sin(phi) * sin(theta) * diameter
             pt.x = center.x + sin(phi) * cos(theta) * diameter
             current = helpers.duplicate_object(base_object)
             current.location = pt
             current.name = 'Object ({0:0>2d}, {1:0>2d})'.format(i, j)
             current.data.name = 'Mesh ({0:0>2d}, {1:0>2d})'.format(i, j)
             current.rotation_euler = (0.0, phi, theta)
             helpers.assign_material(
                 current, helpers.random_material(self.MATERIALS_NAMES))
             axis = self.vecrotatex(theta, baseaxis)
             currot = startrot
             center = startcenter
             for f in range(0, self.NUMBER_OF_FRAMES, 1):
                 fprc = f / (self.NUMBER_OF_FRAMES - 1)
                 osc = abs(sin(TWOPI * fprc))
                 bpy.context.scene.frame_set(f)
                 center = startcenter.lerp(stopcenter, osc)
                 current.location = helpers.rotate_vector(
                     TWOPI * fprc, axis, pt)
                 current.keyframe_insert(data_path='location')
                 currot = startrot.slerp(stoprot, jprc * fprc)
                 current.rotation_euler = currot.to_euler()
                 current.keyframe_insert(data_path='rotation_euler')
示例#5
0
 def render(self):
     frame = self.spawn_frame(helpers.build_segment(
         (-10, -10, 0),
         helpers.rand_proba(self.FUNCTIONS),
         length=3,
         pitch=1),
                              side=20)
     helpers.assign_material(frame,
                             helpers.random_material(self.MATERIALS_NAMES))
示例#6
0
    def render(self):
        ######################
        ## FLUID SIMULATION ##
        ######################
        self.SCENE.frame_end = self.NUMBER_OF_FRAMES

        RADIUS = 20

        bpy.ops.mesh.primitive_cube_add(location=(0.0, 0.0, 17), radius=RADIUS)
        container = helpers.last_added_object('Cube')
        container.name = 'fluid_container'
        container.modifiers.new(name='container', type='FLUID_SIMULATION')
        container.modifiers.new(name='smooth_container', type='SMOOTH')
        container.modifiers['container'].settings.type = 'DOMAIN'
        container.modifiers['container'].settings.generate_particles = 5
        container.modifiers['container'].settings.surface_subdivisions = 50
        container.modifiers['container'].settings.viscosity_exponent = 6
        container.modifiers['container'].settings.viscosity_base = 1.0
        container.modifiers['container'].settings.resolution = 25
        container.modifiers['container'].settings.simulation_scale = 1
        container.modifiers['container'].settings.simulation_rate = 5
        self.BAKED.append(container)

        self.spawn_emitter_fuild((-2, -2, 10),
                                 mathutils.Vector((-0.5, -0.5, -2)))
        self.spawn_emitter_fuild((2, 2, 10), mathutils.Vector((0.5, 0.5, -2)))

        helpers.assign_material(container,
                                helpers.random_material(self.MATERIALS_NAMES))

        ######################
        ## SMOKE SIMULATION ##
        ######################

        bpy.ops.mesh.primitive_cube_add(location=(0.0, 0.0, 17), radius=RADIUS)
        container = helpers.last_added_object('Cube')
        container.name = 'smoke_container'
        container.modifiers.new(name='container', type='SMOKE')
        container.modifiers['container'].smoke_type = 'DOMAIN'
        container.modifiers[
            'container'].domain_settings.use_high_resolution = True
        container.modifiers['container'].domain_settings.vorticity = 3
        self.BAKED.append(container)

        self.spawn_emitter_smoke(self.ORIGIN)

        # Bake animation
        print(
            "*** Baking commence *** (you might see a bunch of gibberish popping up cause baking is not supposed to be used headlessly"
        )
        bpy.ops.ptcache.free_bake_all()  # free bake cache
        bpy.ops.ptcache.bake_all(bake=True)
        print("*** Baking finished ***")
示例#7
0
  def render(self):
    base_model = self.SUBJECT

    for i in range(0, 10):
      copy = self.load_random_obj()
      copy.scale = helpers.rand_scale_vector(round(random.uniform(0, 1), 10))
      copy.location = helpers.rand_location()
      angles = [-90, 90, 0]
      self.props.append(copy)
      copy.rotation_euler.z += math.radians(random.choice(angles))
      copy.rotation_euler.y += math.radians(random.choice(angles))
      copy.rotation_euler.x += math.radians(random.choice(angles))
      copy.name = 'copy_' + str(i)
      helpers.assign_material(copy, helpers.random_material(self.MATERIALS_NAMES))

    cut_copy = self.duplicate_object(self.SUBJECT)
    self.cut(cut_copy)
示例#8
0
 def add_ocean(self,
               spatial_size,
               resolution,
               depth=100,
               scale=(4, 4, 4),
               wave_scale=0.5):
     bpy.ops.mesh.primitive_cube_add(location=(0, 0, -0.4), radius=1)
     ocean = helpers.last_added_object('Cube')
     ocean.scale = scale
     ocean.modifiers.new(name='Ocean', type='OCEAN')
     ocean.modifiers["Ocean"].spatial_size = spatial_size
     ocean.modifiers["Ocean"].resolution = resolution
     ocean.modifiers["Ocean"].wave_scale = wave_scale
     ocean.modifiers["Ocean"].depth = depth
     helpers.assign_material(ocean, helpers.fetch_material("jello"))
     shadow = helpers.duplicate_object(ocean)
     shadow.location += mathutils.Vector((1, 1, -0.4))
     helpers.wireframize(shadow, random.choice(self.COLORS))
     shadow.name = 'shadow'
     ocean.name = 'ocean'
     return [ocean, shadow]
示例#9
0
 def render(self):
   diameter = 4.0
   sz = 2.125 / diameter
   latitude = 10
   longitude = latitude * 2
   invlatitude = 1.0 / (latitude - 1)
   current_frame = 0
   jprc = 0.0
   phi = 0.0
   theta = 0.0
   pt = Vector((0.0, 0.0, 0.0))
   rotpt = Vector((0.0, 0.0, 0.0))
   center = Vector((0.0, 0.0, 0.0))
   baseaxis = Vector((0.0, 1.0, 0.0))
   axis = Vector((0.0, 0.0, 0.0))
   metaball_type = random.choice(self.TYPES)
   mbdata = bpy.data.metaballs.new('meta_balls')
   mbdata.render_resolution = 0.075
   mbdata.resolution = 0.1
   mbobj = bpy.data.objects.new("meta_bollocks", mbdata)
   bpy.context.scene.objects.link(mbobj)
   helpers.assign_material(mbobj, helpers.random_material(self.MATERIALS_NAMES))
   for i in range(0, latitude, 1):
       phi = pi * (i + 1) * invlatitude
       pt.z = cos(phi) * diameter
       for j in range(0, longitude, 1):
           theta = TWOPI * j / longitude
           pt.y = center.y + sin(phi) * sin(theta) * diameter
           pt.x = center.x + sin(phi) * cos(theta) * diameter
           mbelm = mbdata.elements.new(type=metaball_type)
           mbelm.co = (latitude, longitude, 6)
           mbelm.radius = 0.15 + sz * abs(sin(phi)) * 1.85
           mbelm.stiffness = 1.0
           if i % 7 == j % 3:
               mbelm.use_negative = True
           for f in range(0, self.NUMBER_OF_FRAMES, 1):
               fprc = f / (self.NUMBER_OF_FRAMES - 1)
               bpy.context.scene.frame_set(f)
               mbelm.co = helpers.rotate_vector(TWOPI * fprc, axis, pt)
               mbelm.keyframe_insert(data_path='co')
示例#10
0
    def render(self):
        DURATION=self.NUMBER_OF_FRAMES
        self.SCENE.frame_start = 0
        self.SCENE.frame_end = DURATION
        self.cubes = helpers.build_composite_object('Cube', self.SIZE-1, 0.5)

        self.cells = [[[ 0 for i in range(self.SIZE)] for k in range(self.SIZE)] for j in range(self.SIZE)]
        self.next_generation = [[[ 0 for i in range(self.SIZE)] for k in range(self.SIZE)] for j in range(self.SIZE)]

        for x in range(self.SIZE):
            for y in range(self.SIZE):
                for z in range(self.SIZE):
                    self.cubes[x][y][z].scale=(.1,.1,.1)
                    self.cells[x][y][z] = random.choice(range(2))
                    helpers.assign_material(self.cubes[x][y][z], helpers.random_material(self.MATERIALS_NAMES))

        print("Synthetic life begin")
        self.adjust_scale()
        for l in range(DURATION):
            self.SCENE.frame_set(l)
            print("Life in " + str(l))
            self.life(l)
示例#11
0
    def render(self):
        bpy.ops.import_scene.obj(
            filepath=os.path.join(self.FIXTURES_FOLDER_PATH + 'm4a1.obj'),
            use_edges=True)
        bpy.ops.import_scene.obj(
            filepath=os.path.join(self.FIXTURES_FOLDER_PATH + 'lightning.obj'),
            use_edges=True)
        m4a1 = bpy.data.objects['m4a1']
        logo = bpy.data.objects["0_glitch3d_lightning"]
        logo.name = 'logo'
        logo.location = self.rand_location()
        m4a1.location = self.rand_location()
        m4a1.scale = (0.5, 0.5, 0.5)
        self.props.append(m4a1)
        self.props.append(logo)

        rand_primitive = random.choice(self.PRIMITIVES)
        # elements = helpers.build_composite_object(rand_primitive, 4, 1)

        bpy.ops.mesh.primitive_grid_add(x_subdivisions=100,
                                        y_subdivisions=100,
                                        location=(0, 6, 2))
        display1 = helpers.last_added_object('Grid')
        display1.name = 'display_1'
        bpy.ops.mesh.primitive_grid_add(x_subdivisions=100,
                                        y_subdivisions=100,
                                        location=(6, 0, 2))
        display2 = helpers.last_added_object('Grid')
        display2.name = 'display_2'

        bpy.data.groups['displays'].objects.link(display1)
        bpy.data.groups['displays'].objects.link(display2)

        display1.rotation_euler.x += math.radians(90)
        display1.rotation_euler.z -= math.radians(90)
        display2.rotation_euler.x += math.radians(90)
        display2.rotation_euler.y += math.radians(90)
        display2.rotation_euler.z += math.radians(120)

        for display in bpy.data.groups['displays'].objects:
            display.rotation_euler.x += math.radians(90)
            display.scale = self.DISPLAY_SCALE
            helpers.texture_object(display, self.TEXTURE_FOLDER_PATH)
            helpers.unwrap_model(display)
            helpers.glitch(display)

        for prop in self.props:
            helpers.assign_material(
                prop, helpers.random_material(self.MATERIALS_NAMES))

        bpy.ops.mesh.primitive_plane_add(location=(0, 0, -2))
        floor = self.last_added_object('Plane')
        floor.name = 'floor'
        floor.scale = (20, 20, 20)
        helpers.subdivide(floor, int(random.uniform(1, 5)))
        helpers.displace(floor)

        self.OCEAN = self.add_ocean(10, 20)

        self.LINES = bpy.data.groups['lines']
        for j in range(0, random.choice(range(5, 40))):
            for i in range(0, random.choice(range(5, 10))):
                new_line = self.create_line(
                    'line' + str(uuid.uuid1()),
                    self.series(30, self.rand_proba(self.FUNCTIONS), 0.3),
                    random.choice(self.COLORS), 0.003, (j, -10, 2))
                bpy.data.groups['lines'].objects.link(new_line)
                new_line.location.z += i / 3
                self.props.append(new_line)

        helpers.spawn_text(self.TEXT_FILE_PATH, "PSKL")
        helpers.apply_displacement(bpy.data.objects['ocean'],
                                   self.HEIGHT_MAP_FOLDER_PATH)
        for index in range(1, 5):
            new_object = helpers.spawn_text(self.TEXT_FILE_PATH)
            bpy.data.groups['texts'].objects.link(new_object)
            self.props.append(new_object)
            text_scale = random.uniform(0.75, 3)
            self.assign_material(new_object,
                                 helpers.random_material(self.MATERIALS_NAMES))
            new_object.scale = (text_scale, text_scale, text_scale)
            new_object.location = helpers.rand_location()

        for obj in bpy.data.groups['neons'].objects:
            self.wireframize(obj, random.choice(self.COLORS))
示例#12
0
 def render(self):
   rand_curve = helpers.create_line('rand_curve', helpers.parametric_curve(helpers.rand_proba(self.FUNCTIONS), helpers.rand_proba(self.FUNCTIONS), self.rand_proba(self.FUNCTIONS), 100, 100), random.choice(self.COLORS))
   rand_curve.scale = (2,2,2)
   helpers.glitch(rand_curve)
   art = self.matthew_curve(self.SUBJECT, 50)
   helpers.assign_material(art, helpers.random_material(self.MATERIALS_NAMES))
示例#13
0
 def render(self):
     bpy.ops.mesh.primitive_cube_add(location=(0, 0, 100), radius=1)
     cube = helpers.last_added_object('Cube')
     helpers.assign_material(cube,
                             helpers.random_material(self.MATERIALS_NAMES))
     self.spawn_particles_system(self.SUBJECT, cube)
示例#14
0
文件: waves.py 项目: bdrydyk/glitch3d
 def render(self):
   count = self.COUNT
   # Size of grid.
   extents = 8.0
   # The height of each cube will be animated, so we'll specify the minimum and maximum scale.
   sz = (extents / count)
   base_object = helpers.infer_primitive(random.choice(self.PRIMITIVES), location = (100, 100, 100), radius=sz)
   helpers.assign_material(base_object, helpers.random_material(self.MATERIALS_NAMES))
   minsz = sz * 0.25
   maxsz = sz * extents
   # To convert abstract grid position within loop to real-world coordinate.
   jprc = 0.0
   kprc = 0.0
   countf = 1.0 / (count - 1)
   diffex = extents * 2
   y = 0.0
   x = 0.0
   centerz = 0.0
   centery = 0.0
   centerx = 0.0
   # The maximum possible distance is used to normalize the distance.
   rise = 0.0
   run = 0.0
   normdist = 0.0
   maxdist = sqrt(2 * extents * extents)
   # For generating the wave.
   offset = 0.0
   angle = 0.0
   # Loop through grid y axis.
   for j in range(0, count, 1):
     jprc = j * countf
     y = -extents + jprc * diffex
     # Calculate rise.
     rise = y - centery
     rise *= rise
     # Loop through grid x axis.
     for k in range(0, count, 1):
       kprc = k * countf
       x = -extents + kprc * diffex
       # Calculate run.
       run = x - centerx
       run *= run
       # Find normalized distance using Pythogorean theorem.
       # Remap the normalized distance to a range -PI .. PI
       normdist = sqrt(rise + run) / maxdist
       offset = -TWOPI * normdist + pi
       current = helpers.duplicate_object(base_object)
       current.location = (centerx + x, centery + y, centerz)
       current.name = 'Object ({0:0>2d}, {1:0>2d})'.format(k, j)
       current.data.name = 'Mesh ({0:0>2d}, {1:0>2d})'.format(k, j)
       for f in range(0, self.NUMBER_OF_FRAMES, 1):
         # Convert the keyframe into an angle.
         fprc = f * 1.0 / (self.NUMBER_OF_FRAMES - 1)
         angle = TWOPI * fprc
         # Set the scene to the current frame.
         bpy.context.scene.frame_set(f)
         # Change the scale.
         # sin returns a value in the range -1 .. 1. abs changes the range to 0 .. 1.
         # The values are remapped to the desired scale with min + percent * (max - min).
         current.scale.z = minsz + abs(sin(offset + angle)) * (maxsz - minsz)
         helpers.add_frame([current], ['scale'])
示例#15
0
    def render(self):
        props = []
        bpy.ops.import_scene.obj(
            filepath=os.path.join(self.MODELS_FOLDER_PATH + 'lightning.obj'),
            use_edges=True)
        logo = bpy.context.selected_objects[0]
        logo.location = helpers.rand_location(self.CANVAS_BOUNDARY)
        props.append(logo)

        bpy.ops.mesh.primitive_grid_add(x_subdivisions=100,
                                        y_subdivisions=100,
                                        location=(0, 6, 2))
        display1 = bpy.context.object
        display1.name = 'display_1'
        bpy.ops.mesh.primitive_grid_add(x_subdivisions=100,
                                        y_subdivisions=100,
                                        location=(6, 0, 2))
        display2 = bpy.context.object
        display2.name = 'display_2'

        bpy.data.groups['displays'].objects.link(display1)
        bpy.data.groups['displays'].objects.link(display2)

        display1.rotation_euler.x += math.radians(90)
        display1.rotation_euler.z -= math.radians(90)
        display2.rotation_euler.x += math.radians(90)
        display2.rotation_euler.y += math.radians(90)
        display2.rotation_euler.z += math.radians(120)

        for display in bpy.data.groups['displays'].objects:
            display.rotation_euler.x += math.radians(90)
            display.scale = self.DISPLAY_SCALE
            helpers.texture_object(display, self.TEXTURE_FOLDER_PATH)
            helpers.unwrap_model(display)
            helpers.glitch(display)

        for j in range(0, random.choice(range(5, 40))):
            for i in range(0, random.choice(range(5, 10))):
                new_line = self.create_line(
                    'line' + str(uuid.uuid1()),
                    self.series(30, self.rand_proba(self.FUNCTIONS), 0.3),
                    random.choice(self.COLORS), 0.003, (j, -10, 2))
                bpy.data.groups['lines'].objects.link(new_line)
                new_line.location.z += i / 3
                props.append(new_line)

        ocean = self.add_ocean(10, 20)

        for index in range(1, 5):
            new_object = helpers.spawn_text(self.TEXT_FILE_PATH)
            bpy.data.groups['texts'].objects.link(new_object)
            props.append(new_object)
            helpers.assign_material(
                new_object, helpers.random_material(self.MATERIALS_NAMES))
            text_scale = random.uniform(0.75, 3)
            new_object.scale = (text_scale, text_scale, text_scale)
            new_object.location = helpers.rand_location(self.CANVAS_BOUNDARY)
            props.append(new_object)

        for obj in bpy.data.groups['neons'].objects:
            self.wireframize(obj, random.choice(self.COLORS))

        for f in range(self.NUMBER_OF_FRAMES):
            bpy.context.scene.frame_set(f)
            for prop in props:
                helpers.shuffle(prop, self.CANVAS_BOUNDARY)
                helpers.assign_material(
                    prop, helpers.random_material(self.MATERIALS_NAMES))