Beispiel #1
0
def load(filepath,
         import_scale=0.05,
         read_surface=True,
         voxel_dir=VOXEL_DATA_DIR,
         use_voxel_id=False):
    global READ_SURFACES, IMPORT_SCALE, VOXEL_DATA_DIR, VOXEL_DIR_PATH, USE_VOXEL_ID

    READ_SURFACES = read_surface
    IMPORT_SCALE = import_scale
    VOXEL_DATA_DIR = voxel_dir
    USE_VOXEL_ID = use_voxel_id

    # Voxel Directory check
    curdir = os.path.dirname(bpy.data.filepath)
    if len(curdir) <= 0:
        #raise NameError("The blend file must be saved to export voxel datas.")
        return ({'ERROR'}, 'Please save the blend file before import')

    VOXEL_DIR_PATH = os.path.join(curdir, VOXEL_DATA_DIR)
    if os.path.exists(VOXEL_DIR_PATH):
        # Directory is exists
        if os.path.isfile(VOXEL_DIR_PATH):
            # It is file!
            # raise IOError("Same name file found: {}".format(VOXEL_DIR_PATH))
            return ({'ERROR'}, 'Voxel save dir open Error')
    else:
        # Create voxels output dir
        os.makedirs(VOXEL_DIR_PATH)

    # Load File
    contents = ThreeB.load_3bfile(filepath)
    if contents:
        voxtree = ThreeB.create_VoxTree(contents)
        objlist = []
        traverse_VoxTree(voxtree, objlist)

    return (None, None)
Beispiel #2
0
def load(filepath,
         import_scale=0.05,
         read_surface=True,
         voxel_dir=VOXEL_DATA_DIR,
         use_voxel_id=False):
    global READ_SURFACES, IMPORT_SCALE, VOXEL_DATA_DIR, VOXEL_DIR_PATH, USE_VOXEL_ID
    
    READ_SURFACES =read_surface
    IMPORT_SCALE = import_scale
    VOXEL_DATA_DIR = voxel_dir
    USE_VOXEL_ID = use_voxel_id
    
    # Voxel Directory check
    curdir = os.path.dirname(bpy.data.filepath)
    if len(curdir) <= 0:
        #raise NameError("The blend file must be saved to export voxel datas.")
        return ({'ERROR'}, 'Please save the blend file before import')
    
    VOXEL_DIR_PATH = os.path.join(curdir, VOXEL_DATA_DIR)
    if os.path.exists(VOXEL_DIR_PATH):
        # Directory is exists
        if os.path.isfile(VOXEL_DIR_PATH):
            # It is file!
            # raise IOError("Same name file found: {}".format(VOXEL_DIR_PATH))
            return ({'ERROR'}, 'Voxel save dir open Error')
    else:
        # Create voxels output dir
        os.makedirs(VOXEL_DIR_PATH)
    
    # Load File
    contents = ThreeB.load_3bfile(filepath)
    if contents:
        voxtree = ThreeB.create_VoxTree(contents)
        objlist = []
        traverse_VoxTree(voxtree, objlist)
    
    return (None, None)
Beispiel #3
0
        print("num of cells: {0}".format(len(voldat.cells)))
        print("cell AABB: {0}".format(voldat.cell_AABB))
        print("effect AABB: {0}".format(voldat.effect_AABB))
        if voldat.representation == 256:
            print("surface vertices: {}".format(voldat.num_vertices))
            print("surface faces: {}".format(voldat.num_faces))
            print("initial surface vertices: {}".format(voldat.num_init_vertices))
            
    else:
        print("No Volume data")
    
    if voxbranch.childs:
        print("{} childs".format(len(voxbranch.childs)))
        for i in voxbranch.childs:
            print_VoxInfo(i)

if len(sys.argv) <= 1:
    print("usage {0} file1.3b".format(sys.argv[0]))

for i,fname in enumerate(sys.argv[1:]):
    print("input {0}".format(fname))
    threeb = ThreeB.load_3bfile(fname)
    
    chunk = threeb.get("VOL3")
    chunkdata = chunk.data
    print("VOL3 chunk version: {}".format(chunkdata.version))
    #print("VoxTreeXML:\n{0}".format(chunkdata.VoxTreeXML))
    
    voxtree = ThreeB.create_VoxTree(threeb)
    print_VoxInfo(voxtree)
Beispiel #4
0
            outf.write("\n".join(vertlist) + "\n")
            outf.write("\n".join(normlist) + "\n")
            outf.write("\n".join(facelist) + "\n")

            vertcount += len(vertlist)
        else:
            print("This volume has no surfaces")
    else:
        print("No Volume data")

    # convert childs
    if voxbranch.childs:
        for childvox in voxbranch.childs:
            vertcount = convert_surface_to_obj(childvox, vertcount, mtrx, outf)

    return vertcount


if len(sys.argv) <= 1:
    print("usage {0} file1.3b".format(sys.argv[0]))

for i, fname in enumerate(sys.argv[1:]):
    print("input {0}. reading...".format(fname))
    threeb = ThreeB.load_3bfile(fname)
    if threeb:
        print("creating Voxel Data Tree")
        voxtree = ThreeB.create_VoxTree(threeb)
        output_surface_as_obj(voxtree, fname + ".obj")
    else:
        print("{} is not a 3b file".format(fname))