예제 #1
0
def import_vehicle():
    """Import a vehicle
    """
    pm.newFile(force=True)
    print('importing: {}'.format(vehicle_path))

    print('\nImporting the dae files\n')

    # Import the mesh files

    import_mesh(vehicle_path=vehicle_path)

    print('\nImporting the pc files\n')

    # Import the pc files
    for pc_path in glob.glob(os.path.join(vehicle_path, '*.pc')):
        import_pc(pc_path=pc_path)

    print('\nImporting the jbeam files\n')

    # Import the jbeam files
    grp = pm.group(empty=True, world=True, name='jbeam')

    # Import nodes first
    for jbeam_path in glob.glob(os.path.join(vehicle_path, '*.jbeam')):
        import_jbeam_nodes(root=grp, jbeam_path=jbeam_path)

    # Import beams
    for jbeam_path in glob.glob(os.path.join(vehicle_path, '*.jbeam')):
        import_jbeam_beams(root=grp, jbeam_path=jbeam_path)
예제 #2
0
def importAbc(operation, scInfoFile):

    scInfo = loadScInfo(scInfoFile)

    startFrame = scInfo['startFrame']
    endFrame = scInfo['endFrame']
    timeUnit = scInfo['timeUnit']

    pm.newFile(f=True)
    setFrameRange(startFrame, endFrame, timeUnit)

    cacheInfos = scInfo['cache']
    camList = []
    assetList = []
    bgList = []

    for cache in cacheInfos:
        if cache['nodeType'] == 'cam':
            camList.append(cache)
        elif cache['nodeType'] == 'ref':
            assetList.append(cache)
        elif cache['nodeType'] == 'bg':
            bgList.append(cache)

    print camList
    print assetList

    importCamera(camList)
    importAsset(assetList)
    importBg(bgList)
예제 #3
0
def dae_to_mb(dae_path, mb_path):
    """Convert a dae file to Maya binary

    Args:
        dae_path (str): Path to dae file
    """
    pm.newFile(force=True)
    pm.importFile(dae_path)

    name = os.path.basename(dae_path).split('.')[0]

    pm.select(pm.ls(type='mesh'))

    group = pm.group(world=True, name=name + '_meshGroup')

    for loc in pm.ls(type='locator'):
        pm.delete(loc.getParent())
    pm.saveAs(mb_path)
예제 #4
0
def import_mesh(vehicle_path):
    """Import mesh. cache it to a mb file if one doesn't exists.

    Args:
        dae_path (str): Path to dae file
    """

    pm.newFile(force=True)

    mb_paths = []

    for dae_path in glob.glob(os.path.join(vehicle_path, '*.dae')):
        # import_mesh(dae_path=dae_path)

        ext = dae_path.split('.')[-1]
        mb_path = dae_path.replace('.' + ext, '.mb')
        if not os.path.exists(mb_path):
            dae_to_mb(dae_path=dae_path, mb_path=mb_path)

        mb_paths.append(mb_path)

        # name = os.path.basename(dae_path).split('.')[0]

    pm.newFile(force=True)

    for f in mb_paths:
        pm.importFile(f)

    # Cleanup

    # Remove lights
    for light in pm.ls(type='pointLight'):
        pm.delete(light.getParent())

    # Group mesh
    root_grp = pm.group(empty=True, world=True, name='mesh')
    for grp in pm.ls(assemblies=True):
        if grp != root_grp and not grp.getShape():
            grp.setParent(root_grp)
예제 #5
0
def createRenderABC(assetName, modName, path):
    try:
        abcPath = os.path.dirname(path)
        tempAbc = abcPath + '/{}_abc.abc'.format(assetName)
        rootNode = pm.PyNode(modName)

        ctrl = pm.PyNode('WorldCtrl')
        pm.currentTime(1)
        ctrl.t.set(0, 0, 0)
        pm.setKeyframe(ctrl)
        pm.currentTime(2)
        ctrl.t.set(1, 0, 0)
        pm.setKeyframe(ctrl)

        pm.AbcExport(
            j="-frameRange 1 2 -uvWrite -worldSpace -writeVisibility -root {} -file {}"
            .format(rootNode.name(), tempAbc))
        pm.newFile(f=True)
        pm.AbcImport(tempAbc, mode='open', fitTimeRange=1)
        return True
    except:
        return False
예제 #6
0
def createAbcForAsset(shaderPath):
    dirname = os.path.dirname(shaderPath)
    tempAbc = dirname + '/tempAbc.abc'

    pm.select('*ModGrp')
    rootNode = pm.ls(sl=True)[0]

    ctrl = pm.PyNode('WorldCtrl')
    pm.currentTime(1)
    ctrl.t.set(0, 0, 0)
    pm.setKeyframe(ctrl)
    pm.currentTime(2)
    ctrl.t.set(1, 0, 0)
    pm.setKeyframe(ctrl)

    pm.AbcExport(
        j="-frameRange 1 2 -uvWrite -worldSpace -writeVisibility -dataFormat ogawa -root {} -file {}"
        .format(rootNode.name(), tempAbc))
    pm.newFile(f=True)
    pm.AbcImport(tempAbc, mode='open', fitTimeRange=1)

    importShader(shaderPath)
    os.remove(tempAbc)