예제 #1
0
if extrude:
    try:
        lx.eval("user.defNew name:threshold type:integer life:momentary")
        lx.eval("user.def threshold username {Extrude Distance}")
        lx.eval("user.value threshold")
    except:
        sys.exit("LXe_ABORT")

    distance = lx.eval("user.value threshold ?")

lx.eval("select.typeFrom polygon")
polys = lx.eval("query layerservice polys ? selected")
if not polys:
    lx.eval("select.all")
if not polys:
    modoutil.error("No Geometry", "No polygons in layer")
    sys.exit("LXe_ABORT")

lx.eval("hide.Unsel")

lx.eval("tool.set xfrm.quantize on")
lx.eval("tool.attr xfrm.quantize X 1.0")
lx.eval("tool.attr xfrm.quantize Y 1.0")
lx.eval("tool.attr xfrm.quantize Z 1.0")
lx.eval("tool.doApply")
lx.eval("tool.set xfrm.quantize off")

if extrude:
    lx.eval("vert.split")

tmp_file = open(map_file, 'w')
예제 #2
0
def writeMesh(name):
    layer_name = lx.eval("query layerservice layer.name ? " + name)
    lx.eval("select.item item:" + name + " mode:set")
    vert_idxs = lx.evalN("query layerservice verts ? all")
    vert_pos = list()
    vert_normal = list()
    for idx in vert_idxs:
        vert_pos.append(lx.eval("query layerservice vert.pos ? " + idx))
        vert_normal.append(lx.eval("query layerservice vert.normal ? " + idx))

    textures = dict()
    materials = dict()
    for material_idx in lx.evalN("query layerservice materials ?"):
        material_name = lx.eval("query layerservice material.name ? " + material_idx)
        material_textures = lx.evalN("query layerservice material.textures ? " + material_idx)
        materials[material_name] = material_textures
    for texture_idx in lx.evalN("query layerservice textures ? all"):
        texture_name = lx.eval("query layerservice texture.id ? " + texture_idx)
        if lx.eval("query layerservice texture.type ? " + texture_idx) == 'imageMap':
            texture_clip = lx.eval("query layerservice texture.clipFile ? " + texture_idx)
            if 'iOS' in platform:
                if '.pvr.ccz' in material_name:
                    texture_clip = texture_clip[:-4]
                    texture_clip = texture_clip + ".pvr.ccz"
            if 'android' in platform:
                if '.pkm' in material_name:
                    texture_clip = texture_clip[:-4]
                    texture_clip = texture_clip + ".pkm"
            texture_uv_idx = lx.eval("query layerservice texture.uvMap ? " + texture_idx)
            if texture_uv_idx:
                texture_uv = lx.eval("query layerservice vmap.name ? " + str(texture_uv_idx))
            textures[texture_name] = [texture_clip, texture_uv]
        elif lx.eval("query layerservice texture.type ? " + texture_idx) == 'advancedMaterial':
            lx.eval("select.subItem " + texture_name + " set textureLayer;")
            lx.eval("item.channel advancedMaterial$smAngle 180.0")

    poly_idxs = lx.evalN("query layerservice polys ? all")
    poly_verts = list()
    poly_materials = list()
    for idx in poly_idxs:
        poly_materials.append(lx.eval("query layerservice poly.material ? " + idx))
        poly_verts.append(lx.eval("query layerservice poly.vertList ? " + idx))

    vmaps = lx.eval("query layerservice vmaps ? all")

    uvmaps =            list()
    colormaps =         list()

    for vmap in vmaps:

        vmap_type = lx.eval("query layerservice vmap.type ? " + vmap)
        vmap_name = lx.eval("query layerservice vmap.name ? " + vmap)
        
        if "texture" == vmap_type:
            uvmap_values = list()
            active_uv = False
            for idx in poly_idxs:
                uvmap_value = lx.eval("query layerservice poly.vmapValue ? " + idx)
                uvmap_values.append(uvmap_value)
                for val in uvmap_value:
                    if val > 0.0:
                        active_uv = True
            if active_uv:
                lx.out(uvmap_values)
                uvmaps.append((vmap_name, uvmap_values))
                
        elif "rgb" == vmap_type or "rgba" == vmap_type:
            colormap_values = list()
            active_color = False
            for idx in vert_idxs:
                colormap_value = lx.eval("query layerservice vert.vmapValue ? " + idx)
                if not colormap_value:
                    colormap_value = (0.0,0.0,0.0)
                colormap_values.append(colormap_value)
                for val in colormap_value:
                        if val > 0.0:
                            active_color = True
            if active_color:
                colormaps.append((vmap_name,colormap_values))
                
    filename = scenedir + layer_name + ".fbx"
    lx.out(materials)
    lx.out(textures)
    for uvmap in uvmaps:
        lx.out(uvmap)


    lx.out(len(vert_normal))
    data = {'name':             layer_name, \
            'verts':            vert_pos,\
            'normals':          vert_normal,\
            'polys':            poly_verts,\
            'polymaterials':    poly_materials,\
            'uvmaps':           uvmaps,\
            'colormaps':        colormaps, \
            'materials':        materials, \
            'textures':         textures} 
    lx.out(colormaps)
    if os.path.exists(filename):
        os.remove(filename)
    fbx_file = open(filename, 'w+')
    cPickle.dump(data,fbx_file)
    fbx_file.flush()
    fbx_file.close()

    path = lx.eval("query platformservice path.path ? kits")
    path = path + "\petermodo\scripts\make_cocos2DFBX.py"
    if not os.path.exists(path):
        modoutil.error("Bad Path", "Can't find FBX Materials Script")
        sys.exit("LXe_ABORT")
    command = path + " " + filename
    os.system(command)
    os.system(scenedir + "fbx-conv.exe -a " + filename)
예제 #3
0
import shlex
import sys
import cPickle
import math

lx.eval("anim.setup on")

args = lx.args()

platform = None
for arg in args:
    platform = arg

scenedir = lx.eval("query sceneservice scene.file ? current")
if not scenedir:
    modoutil.error("Bad file", "Save file before exporting")

scenename = lx.eval("query sceneservice scene.name ? current")
scenedir = scenedir[:-len(scenename)]
layer_name = lx.eval("query layerservice layer.name ? main")

num_item = lx.eval("query sceneservice item.N ?")
for idx in range(num_item):
    if lx.eval("query sceneservice item.type ? " + str(idx)) == "locator":
        item_idx = lx.eval("query sceneservice item.id ? " + str(idx))
        name = lx.eval("query sceneservice item.name ? " + str(idx))
        xfrms = lx.eval("query sceneservice item.xfrmItems ? " + name)
        rot_zero = list()
        rot = list()
        for xfrm in xfrms:
            if lx.eval("query sceneservice item.type ? " + xfrm) == "rotation":
예제 #4
0
vertex_index_list = set()
if selmode == "vertex":
    vertex_index_list = set(lx.eval("query layerservice verts ? selected"))
    lx.eval("select.convert polygon")
    poly_index_list = set(lx.eval("query layerservice polys ? selected"))
elif selmode == "edge":
    lx.eval("select.convert vertex")
    vertex_index_list = set(lx.eval("query layerservice verts ? selected"))
    lx.eval("select.convert polygon")
    poly_index_list = set(lx.eval("query layerservice polys ? selected"))
elif selmode == "polygon":
    poly_index_list = set(lx.eval("query layerservice polys ? selected"))
    lx.eval("select.convert vertex")
    vertex_index_list = set(lx.eval("query layerservice verts ? selected"))
else:
    modoutil.error("Bad selection mode",
                   "Only works with vertex, edge or polygon selection mode")
    sys.exit("LXe_ABORT")

if setpTarget:
    if poly_index_list:
        part_list = set()
        for part in lx.eval("query layerservice parts ? all"):
            part_list.add(
                lx.eval("query layerservice part.name ? " + str(part)))
        if "pr_target_part" in part_list:
            lx.eval("select.polygon set part face pr_target_part")
            lx.eval("poly.setPart Default")
        modoutil.selectPolygons(poly_index_list)
        lx.eval("poly.setPart pr_target_part")
        sys.exit("LXe_SUCCESS")
    else: