1
$\begingroup$

iam looking for a way to - like the title says - i want to put the same video on each face, but with different time delay.

In other words, i want to create a kind of videowall.

i found THIS:

#----------------------------------------------------------
# File multi_material.py
#----------------------------------------------------------
import bpy

def run(origin):
    # Create three materials
    red = bpy.data.materials.new('Red')
    red.diffuse_color = (1,0,0)
    blue = bpy.data.materials.new('Blue')
    blue.diffuse_color = (0,0,1)
    yellow = bpy.data.materials.new('Yellow')
    yellow.diffuse_color = (1,1,0)

    # Create mesh and assign materials
    bpy.ops.mesh.primitive_uv_sphere_add(
        segments = 16,
        ring_count = 8, 
        location=origin)
    ob = bpy.context.object
    ob.name = 'MultiMatSphere'
    me = ob.data
    me.materials.append(red)
    me.materials.append(blue)
    me.materials.append(yellow)

    # Assign materials to faces
    for f in me.faces:
        f.material_index = f.index % 3

    # Set left half of sphere smooth, right half flat shading
    for f in me.faces:
        f.use_smooth = (f.center[0] < 0)

if __name__ == "__main__":
    run((0,0,0))

But it didn't really work out for me, it creates a red sphere and sends

Traceback (most recent call last): File "\Text", line 36, in File "\Text", line 28, in run AttributeError: 'Mesh' object has no attribute 'faces' Error: Python script fail, look in the console for now...

to the console. Also i didn't know how i could add the delay in there.

Hope you can help me out with this! :)

$\endgroup$
1
$\begingroup$

On your object you need to create a material for each of the faces you'll be using as screens. Make it so the color of the material is set to image texture and is using the image sequence (or video).

Enable Auto Refresh.

enter image description here

Select the first face and assign a material to it. Select the next face, create a copy of the material and Assign the face to it (more info on this link). Repeat that for each of the faces, So that all of them have a different material, but all of them use the same image sequence.

enter image description here

Then modify your materials so that each one of them has a different start frame.

enter image description here

Frames will give you control on the source's duration (in frames): How many frames do you want to use?

Start Frame is the frame in the scene at which the video clip will start playing.

Offset allows you to select the first frame of the video source.

enter image description here

enter image description here

Is any of this is scriptable? Most likely one of the many smart users of this site can figure out how to automate this...

$\endgroup$
  • $\begingroup$ You are quite right @Cegaton! Thanks for your comment. I went back and discovered I was pressing the wrong Plus button! The secret I found is to watch the Layout panel. If a new Material channel doesn't appear there, it doesn't exist! Little wonder I was getting everything cross linked! lol. I've deleted my answer. It's a workaround that has got me there for 18 months, but still incorrect. Thanks once again. $\endgroup$ – Edgel3D Aug 21 '16 at 9:28
1
$\begingroup$

Each face will need a separate material and each of those materials will need its own texture.

The multiple textures can all refer to the same video asset, but will have different values for either Start or Offset (I can't remember which) near the bottom of the Texture/Image properties.

By request: here is a set of python code which can construct the needed materials. In practice, python is a waste unless you are doing a lot more than 6 materials.

import bpy

def get_movie(movie_fname):

    for img in bpy.data.images:
        if img.filepath == movie_fname:
            return img

    return bpy.data.images.load(movie_fname, check_existing=True)


def mission1(obj, n_materials=6):

    movie_fname = "/var/tmp/blender/meow-gun.mp4"

    img = get_movie(movie_fname)

    textures = []

    for i in range(n_materials):
        tex = bpy.data.textures.new("movie", 'IMAGE')
        #tex.type = 'IMAGE'
        tex.image = img

        tex.image_user.frame_start = i*300
        tex.image_user.use_cyclic=True
        tex.image_user.frame_duration = img.frame_duration

        textures.append(tex)

    materials = []
    for i in range(n_materials):
        mat = bpy.data.materials.new("movie")
        if i>=len(mat.texture_slots) or mat.texture_slots[i] is None:
            tslot = mat.texture_slots.add()
        else:
            tslot = mat.texture_slots[i]
        tslot.texture = textures[i]

        #many other material customizations can go here
        mat.emit = 1
        tslot.texture_coords = 'UV'

        materials.append(mat)

    for i in range(n_materials):
        if i<len(obj.data.materials):
            obj.data.materials[i] = materials[i]
        else:
            obj.data.materials.append(materials[i])

    for j in range(len(obj.data.polygons)):
        obj.data.polygons[j].material_index = j%len(obj.data.materials)

obj = bpy.context.active_object
obj = bpy.data.objects["Cube"]
mission1(obj)
$\endgroup$
  • $\begingroup$ this sounds like really hard work. isn't it possible to script that? $\endgroup$ – froggyman Aug 20 '16 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.