Ejemplo n.º 1
0
def generate_Preview():
    # toggle OBJECT mode
    if bpy.ops.object.mode_set.poll():
        bpy.ops.object.mode_set(mode = 'OBJECT', toggle = False)

    config = bpy.context.scene.CONFIG_MeshPy

    vertList = []
    faceList = []
    meshPoints = []
    meshFacets = []
    split_faceList = []
    split_vertList = []
    ob = bpy.context.active_object
    obname = ob.name

    # compute mesh
    compute_vertices(ob, meshPoints)
    compute_polygones(ob, meshFacets)

    if config.make_subdivision == False:
        arg = "Y"
    else:
        arg = ""

    mesh_info = MeshInfo()
    mesh_info.set_points(meshPoints)
    mesh_info.set_facets(meshFacets)
    # args = ("pq" + str(config.ratio_quality) + "a" + str(config.ratio_maxsize) + str(arg))
    '''
Ejemplo n.º 2
0
def generate_TetMesh():
    # toggle OBJECT mode
    if bpy.ops.object.mode_set.poll():
        bpy.ops.object.mode_set(mode = 'OBJECT', toggle = False)

        # bpy.context.scene.update()
        config = bpy.context.scene.CONFIG_MeshPy

        tetIndex = 0
        vertList = []
        faceList = []
        meshPoints = []
        meshFacets = []
        split_faceList = []
        split_vertList = []

        ob = bpy.context.active_object
        obname = ob.name

        # lets try to catch the crash position


        # compute mesh
        # using polygones instead of faces for bmesh
        # def compute_faces(ob, meshFacets):
        for p in ob.data.polygons:
            meshFacets.append(p.vertices[:])



        # def compute_vertices(ob, meshPoints):
        for v in ob.data.vertices:
            meshPoints.append([v.co[0], v.co[1], v.co[2]])



        mesh_info = MeshInfo()
        mesh_info.set_points(meshPoints)
        mesh_info.set_facets(meshFacets)

        args = "pqY"

        tetmesh = build(mesh_info, Options(args))
        compute_mesh(tetmesh, vertList, faceList)

        # create mesh
        tetname = obname + "Tet"
        # print("here we create the new mesh")
        tetMesh = create_mesh(tetname, vertList, faceList)
Ejemplo n.º 3
0
def generate_TetMesh_BAK():
    # toggle OBJECT mode
    if bpy.ops.object.mode_set.poll():
        bpy.ops.object.mode_set(mode = 'OBJECT', toggle = False)
        bpy.context.scene.update()
        config = bpy.context.scene.CONFIG_MeshPy

        tetIndex = 0
        vertList = []
        faceList = []
        meshPoints = []
        meshFacets = []
        split_faceList = []
        split_vertList = []

        ob = bpy.context.active_object
        obname = ob.name

        # lets try to catch the crash position


        # compute mesh
        compute_vertices(ob, meshPoints)
        compute_faces(ob, meshFacets)

        if config.make_subdivision == False:
            arg = "Y"
        else:
            arg = ""

        mesh_info = MeshInfo()
        mesh_info.set_points(meshPoints)
        mesh_info.set_facets(meshFacets)
        debugArg = ""
        # args = (debugArg + "pq" + str(config.ratio_quality) + "a" + str(config.ratio_maxsize) + str(arg))
        # args = ("o2" + str(arg))
        args = "pq"

        tetmesh = build(mesh_info, Options("pq"))
        compute_mesh(tetmesh, vertList, faceList)

        # #all this should only be executed when preview is disabled
        if config.make_split == True:
            # #add counter to iterate to iterate the loop through all tetras
            # print(len(tetmesh.elements))

            while tetIndex < len(tetmesh.elements):
                compute_mesh_split(tetmesh, split_faceList, split_vertList, vertList)
                # print("split_faceList ", tetIndex, ": ", split_faceList[tetIndex])
                # print("split_vertList ", tetIndex, ": ", split_vertList[tetIndex])

                # put this in a separate loop maybe bring some speed up
                # create mesh
                tetname = obname + "Tet"
                tet = create_mesh(tetname, split_vertList[tetIndex], split_faceList[tetIndex])
                # run configs
                enable_game(config, tet)
                enable_physics(config, tet, tetname)

                # bpy.ops.group.create(name='test')
                world_correction(config, ob, tet)

                tetIndex = tetIndex + 1
        else:
            # create mesh
            tetname = obname + "Tet"
            tetMesh = create_mesh(tetname, vertList, faceList)
            # run configs
            enable_game(config, tetMesh)
            enable_physics(config, tetMesh, tetname)
            world_correction(config, ob, tetMesh)