Exemplo n.º 1
0
    def sil_ItemAdd(self, item):
        global g_bNewMeshAdded, g_newMaskAdded
        global g_meshNames
        if g_bNewMeshAdded == True:
            myItem = modo.Item(item)
            if myItem.type == "mesh":

                g_meshNames.append(myItem.name)

        if g_newMaskAdded == True:
            myItem = modo.Item(item)

            if myItem.type == "mask":
                g_matGroupsAdded.append(myItem.name)
Exemplo n.º 2
0
def getLatestItemCreated(name):
    i = 1
    item = None
    while True:
        try:
            if i == 1:
                item = modo.Item(name)
            else:
                item = modo.Item('%s%s' % (name, getIteratorTemplate(i)))
            i += 1
        except:
            break

    return item
Exemplo n.º 3
0
            def getPosition(self):
                '''
                A vertex's final position is an evaluation of its weights.  Each weight caries a position, a bias, and a joint
                the bias is multiplied against the position, and then offset by the joint.

                If a vert sits right on top of a bone and is 100% influenced by that bone, its position is 0,0,0
                If it's 100% weighted to a bone but is not on top of the bone, its position will be its distance from that bone.

                If smooth skinning comes in to play, each joint adds to the final position of the bone, and the bias
                is simply the skinning value from 0 to 1, giving each joint more sway in the final position.
                '''
                x, y, z = 0, 0, 0
                scene = modo.Scene()
                for weight in self.weights:

                    Jx, Jy, Jz = weight.joint.position

                    # We need to rotate the weight.pos vector around the bone's rotation matrix.
                    wMtx = modo.mathutils.Matrix4(position=weight.pos)

                    mObj = modo.Item(weight.joint.name)
                    jMtx = modo.mathutils.Matrix4(
                        mObj.channel('worldMatrix').get())

                    # fMtx = wMtx.__mul__(jMtx)
                    fMtx = wMtx.__mul__(jMtx.asRotateMatrix())
                    fVec = fMtx.position
                    x += (Jx + fVec[0]) * weight.bias
                    y += (Jy + fVec[1]) * weight.bias
                    z += (Jz + fVec[2]) * weight.bias

                return [x, y, z]
Exemplo n.º 4
0
def select_item_materials(self, items):
    sel = []
    for item in items:
        for matname in get_material_list_from_item(self,item):
            mat = modo.Item(matname + ' (Material)')
            sel.append(mat)

    self.scn.select(sel+items)
def freeze_replicator(self, type, update_arr=True, first_index=0):
    if type == t.itemType['REPLICATOR']:

        message = "Freeze Replicator"
        message = get_progression_message(self, message)
        increment_progress_bar(self, self.progress)
        dialog.transform_log(message)

        frozenItem_arr = []

        selection = self.scn.selected
        for i in xrange(0, len(selection)):
            selection[i].select(replace=True)
            originalName = self.scn.selected[0].name

            lx.eval('replicator.freeze')

            item = modo.Item(originalName)
            children = item.children()

            self.scn.select(children)

            lx.eval('item.setType.mesh')
            lx.eval('layer.mergeMeshes true')

            trimed_selection = selection[i:]
            #print trimed_selection
            helper.replace_replicator_source(self, trimed_selection)

            frozenItem = modo.Item(self.scn.selected[0].name)
            frozenItem.setParent()

            self.scn.select(item)

            lx.eval('!!item.delete')

            frozenItem.name = originalName

            frozenItem_arr.append(frozenItem)

            if not self.exportFile_sw:
                self.userSelection[first_index + i] = frozenItem
            elif update_arr:
                self.proceededMesh[first_index + i] = frozenItem

        self.scn.select(frozenItem_arr)
Exemplo n.º 6
0
def safe_removeItems(items, children = False):
    for i in items:
        # make sure item exists before trying to delete it
        # (lest ye crash)
        try:
            modo.Item(i.id)
        except:
            continue

        modo.Scene().removeItems(i, children)
Exemplo n.º 7
0
def get_shaderTree_pos(item):
    '''Get position of item in shader tree and the parent
	:returns: parentItem, number
	:rtype: tuple
	:param item: modo item
	:type item: modo.Item'''

    # imageFolders are special. They are not part of the shader tree so we need to
    # get it assosiating imageMap item
    if item.type == 'imageFolder':
        item_id = modo.Item(shaderGraph.RevByIndex(item, 0)).id
    else:
        item_id = item.id

    parent = modo.Item(item_id).parent
    for i in xrange(parent.childCount()):
        item = parent.childAtIndex(i)
        if item_id == item.id:
            return parent, i
Exemplo n.º 8
0
def enable_backdrop(camera):
    """
    Enable the last assigned backdrop for a camera
    """

    camUserVal = UserValue(camera.id, prefix='PlateManager')
    try:
        backdrop = modo.Item(camera.getTags()['LBBD'])
    except LookupError as e:
        print 'No Backdrop found for camera: %s' % camera.id
    else:
        backdrop.itemGraph('shadeLoc').connectInput(camera)
Exemplo n.º 9
0
def set_bakeRegion(imageMap, renderItem):
    '''Set the bake region of renderItem to the UDIM values of an imageMap'''

    videoStill = modo.Item(shaderGraph.FwdByIndex(imageMap, 1))
    udim = videoStill.channel('udim').get()

    bake_right = int(str(udim)[3])
    bake_bottom = int(str(udim)[:3]) - 100
    bake_left = bake_right - 1
    bake_top = bake_bottom + 1

    lx.eval('channel.value %s channel:{%s:bakeU0}' %
            (bake_left, renderItem.id))
    lx.eval('channel.value %s channel:{%s:bakeU1}' %
            (bake_right, renderItem.id))
    lx.eval('channel.value %s channel:{%s:bakeV0}' %
            (bake_bottom, renderItem.id))
    lx.eval('channel.value %s channel:{%s:bakeV1}' % (bake_top, renderItem.id))
Exemplo n.º 10
0
	for i, render_pass in enumerate(render_passes):
		masks_on = range(i * 3, (i + 1) * 3)
		for n, mask in enumerate(masks):
			if n not in masks_on:
				render_pass.setValue(mask.channel('enable'), False)

	#Set up black background
	env = scene.addItem('envMaterial', 'mmTmpEnv')
	env.select()
	lx.eval('texture.parent shaderFolder008 -1')
	env.deselect()
	env.channel('type').set('constant')
	env.channel('zenColor').set((0, 0, 0))
	added_items.append(env)

	render = modo.Item('polyRender006')
	user_gi = render.channel('globEnable').get()
	render.channel('globEnable').set(False)
	added_items.append(pass_group)  #Added this last to fix crashes when deleting items

	if anim:
		parameters = (
            render.channel('first').get(),
			render.channel('last').get(),
			render.channel('step').get(),
			added_items[-1].id
        )
        #User may cancel this opperation
		try:  
			lx.eval('render.animationDialog {} {} {} sequence {}'.format(*parameters))
		except:
Exemplo n.º 11
0
        init_dialog("input", path, 'fbx')

        try:  # mesh to process dialog
            lx.eval('dialog.open')
        except:  # if cancel button pressed
            init_dialog('cancel', path)
        else:  # process selected mesh
            files = lx.evalN('dialog.result ?')

            for f in files:
                filename = os.path.splitext(os.path.basename(f))[0]
                if filename in group_locator_name:  # the filename have a groupLocator selected with the same name
                    lx.eval('!!scene.open "{}" import'.format(f))
                    print_log('Importing {}'.format(filename))

                    imported_scene_root = modo.Item(filename + '_2')
                    imported_items = get_child_of_type(imported_scene_root,
                                                       'mesh')
                    source_items = get_child_of_type(
                        group_locator_dict[filename], 'mesh')

                    for imported_item in imported_items:
                        matching_source_item = get_matching_item(
                            source_items, imported_item, skipped_item_dict)
                        if matching_source_item is not None:

                            matching_list = [
                                matching_source_item, imported_item
                            ]

                            scn.select(matching_list)