当前位置: 首页>>代码示例>>Python>>正文


Python trimesh.Trimesh方法代码示例

本文整理汇总了Python中trimesh.Trimesh方法的典型用法代码示例。如果您正苦于以下问题:Python trimesh.Trimesh方法的具体用法?Python trimesh.Trimesh怎么用?Python trimesh.Trimesh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trimesh的用法示例。


在下文中一共展示了trimesh.Trimesh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: transform_mesh

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def transform_mesh(mesh, name, trans_dir):
  """Transform mesh back to the same coordinate of ground truth.

  Args:
    mesh: trimesh.Trimesh, predicted mesh before transformation.
    name: Tensor, hash name of the mesh as recorded in the dataset.
    trans_dir: string, path to the directory for loading transformations.

  Returns:
    mesh: trimesh.Trimesh, the transformed mesh.
  """
  if trans_dir is None:
    raise ValueError("Need to specify args.trans_dir for loading pred-to-target"
                     "transformations.")
  cls_name, obj_name = mesh_name_helper(name)
  with tf.io.gfile.GFile(
      path.join(trans_dir, "test", cls_name, obj_name, "occnet_to_gaps.txt"),
      "r") as fin:
    tx = np.loadtxt(fin).reshape([4, 4])
    mesh.apply_transform(np.linalg.inv(tx))
  return mesh 
开发者ID:tensorflow,项目名称:graphics,代码行数:23,代码来源:utils.py

示例2: generate_mesh_t0

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def generate_mesh_t0(self, z=None, c_s=None, c_t=None, data=None,
                         stats_dict={}):
        ''' Generates the mesh at time step t=0.

        Args:
            z (tensor): latent code z
            c_s (tensor): conditioned spatial code c_s
            c_t (tensor): conditioned temporal code c_t
            data (dict): data dictionary
            stats_dict (dict): (time) statistics dictionary
        '''
        if self.onet_generator.model.decoder is not None:
            mesh = self.onet_generator.generate_from_latent(
                z, c_s, stats_dict=stats_dict)
        else:
            vertices = data['mesh.vertices'][:, 0].squeeze(0).cpu().numpy()
            faces = data['mesh.faces'].squeeze(0).cpu().numpy()
            mesh = trimesh.Trimesh(
                vertices=vertices, faces=faces, process=False)
        return mesh 
开发者ID:autonomousvision,项目名称:occupancy_flow,代码行数:22,代码来源:generation.py

示例3: visual_mesh

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def visual_mesh(self, mesh):
        """Setter of visual mesh

        Parameters
        ----------
        mesh : None, trimesh.Trimesh, sequence of trimesh.Trimesh, or str
            A set of visual meshes for the link in the link frame.
        """
        if not (mesh is None
                or isinstance(mesh, trimesh.Trimesh)
                or (isinstance(mesh, collections.Sequence)
                    and all(isinstance(m, trimesh.Trimesh) for m in mesh))
                or isinstance(mesh, str)):
            raise TypeError(
                'mesh must be None, trimesh.Trimesh, sequence of '
                'trimesh.Trimesh, or path of mesh file, but got: {}'.format(
                    type(mesh)))
        if isinstance(mesh, str):
            mesh = trimesh.load(mesh)
        self._visual_mesh = mesh 
开发者ID:iory,项目名称:scikit-robot,代码行数:22,代码来源:model.py

示例4: generate_mesh

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def generate_mesh(self, data):
        self.model.eval()
        device = self.device

        inputs = data.get('inputs', torch.empty(1, 0)).to(device)

        inputs = self.num_voxels * (inputs / 1.2 + 0.5)

        with torch.no_grad():
            offset, topology, occupancy = self.model(inputs)

        offset = offset.squeeze()
        topology = topology.squeeze()
        topology = topology[:, self.vis_topology]

        vertices, faces = pred_to_mesh_max(offset, topology)
        faces = faces.astype(np.int64)

        vertices = 1.2 * (vertices / self.num_voxels - 0.5)
        mesh = trimesh.Trimesh(vertices=vertices, faces=faces, process=False)
        return mesh 
开发者ID:autonomousvision,项目名称:occupancy_networks,代码行数:23,代码来源:generation.py

示例5: load_dynamic_contour

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def load_dynamic_contour(template_flame_path='None', contour_embeddings_path='None', static_embedding_path='None', angle=0):
    template_mesh = Mesh(filename=template_flame_path)
    contour_embeddings_path = contour_embeddings_path
    dynamic_lmks_embeddings = np.load(contour_embeddings_path, allow_pickle=True).item()
    lmk_face_idx_static, lmk_b_coords_static = load_static_embedding(static_embedding_path)
    lmk_face_idx_dynamic = dynamic_lmks_embeddings['lmk_face_idx'][angle]
    lmk_b_coords_dynamic = dynamic_lmks_embeddings['lmk_b_coords'][angle]
    dynamic_lmks = mesh_points_by_barycentric_coordinates(template_mesh.v, template_mesh.f, lmk_face_idx_dynamic, lmk_b_coords_dynamic)
    static_lmks = mesh_points_by_barycentric_coordinates(template_mesh.v, template_mesh.f, lmk_face_idx_static, lmk_b_coords_static)
    total_lmks = np.vstack([dynamic_lmks, static_lmks])

    # Visualization of the pose dependent contour on the template mesh
    vertex_colors = np.ones([template_mesh.v.shape[0], 4]) * [0.3, 0.3, 0.3, 0.8]
    tri_mesh = trimesh.Trimesh(template_mesh.v, template_mesh.f,
                               vertex_colors=vertex_colors)
    mesh = pyrender.Mesh.from_trimesh(tri_mesh)
    scene = pyrender.Scene()
    scene.add(mesh)
    sm = trimesh.creation.uv_sphere(radius=0.005)
    sm.visual.vertex_colors = [0.9, 0.1, 0.1, 1.0]
    tfs = np.tile(np.eye(4), (len(total_lmks), 1, 1))
    tfs[:, :3, 3] = total_lmks
    joints_pcl = pyrender.Mesh.from_trimesh(sm, poses=tfs)
    scene.add(joints_pcl)
    pyrender.Viewer(scene, use_raymond_lighting=True) 
开发者ID:soubhiksanyal,项目名称:RingNet,代码行数:27,代码来源:dynamic_contour_embedding.py

示例6: load_mesh

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def load_mesh(mesh_file):
    with open(mesh_file, 'r') as f:
        str_file = f.read().split('\n')
        n_vertices, n_faces, _ = list(
            map(lambda x: int(x), str_file[1].split(' ')))
        str_file = str_file[2:]  # Remove first 2 lines

        v = [l.split(' ') for l in str_file[:n_vertices]]
        f = [l.split(' ') for l in str_file[n_vertices:]]

    v = np.array(v).astype(np.float32)
    f = np.array(f).astype(np.uint64)[:, 1:4]

    mesh = trimesh.Trimesh(vertices=v, faces=f, process=False)

    return mesh 
开发者ID:autonomousvision,项目名称:occupancy_flow,代码行数:18,代码来源:io.py

示例7: _create_trimesh

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def _create_trimesh(self):
        """
        creates a trimesh object
        """
        
        if np.any(np.array([len(x) for x in self.faces])>3):
            faces = []
            for i in range(0,len(self.pyvista_obj.triangulate().faces),4):
                point_1 = self.pyvista_obj.triangulate().faces[i+1]
                point_2 = self.pyvista_obj.triangulate().faces[i+2]
                point_3 = self.pyvista_obj.triangulate().faces[i+3]
                faces.append([point_1, point_2, point_3])
            self.trimesh_obj = trimesh.Trimesh(vertices=self.verts,faces=faces)

        else:

            self.trimesh_obj = trimesh.Trimesh(vertices=self.verts,faces=self.faces) 
开发者ID:romerogroup,项目名称:pyprocar,代码行数:19,代码来源:surface.py

示例8: meshes

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def meshes(self, value):
        if isinstance(value, six.string_types):
            value = load_meshes(value)
        elif isinstance(value, (list, tuple, set)):
            value = list(value)
            if len(value) == 0:
                raise ValueError('Mesh must have at least one trimesh.Trimesh')
            for m in value:
                if not isinstance(m, trimesh.Trimesh):
                    raise TypeError('Mesh requires a trimesh.Trimesh or a '
                                    'list of them')
        elif isinstance(value, trimesh.Trimesh):
            value = [value]
        else:
            raise TypeError('Mesh requires a trimesh.Trimesh')
        self._meshes = value 
开发者ID:iory,项目名称:scikit-robot,代码行数:18,代码来源:urdf.py

示例9: collision_mesh

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def collision_mesh(self):
        """:class:`~trimesh.base.Trimesh` : A single collision mesh for
        the link, specified in the link frame, or None if there isn't one.
        """
        if len(self.collisions) == 0:
            return None
        if self._collision_mesh is None:
            meshes = []
            for c in self.collisions:
                for m in c.geometry.meshes:
                    m = m.copy()
                    pose = c.origin
                    if c.geometry.mesh is not None:
                        if c.geometry.mesh.scale is not None:
                            S = np.eye(4)
                            S[:3,:3] = np.diag(c.geometry.mesh.scale)
                            pose = pose.dot(S)
                    m.apply_transform(pose)
                    meshes.append(m)
            if len(meshes) == 0:
                return None
            self._collision_mesh = (meshes[0] + meshes[1:])
        return self._collision_mesh 
开发者ID:mmatl,项目名称:urdfpy,代码行数:25,代码来源:urdf.py

示例10: box_show

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def box_show(self, scene):
    """Render box."""
    A2B = tm.get_transform(self.frame, frame)

    corners = np.array([
        [0, 0, 0],
        [0, 0, 1],
        [0, 1, 0],
        [0, 1, 1],
        [1, 0, 0],
        [1, 0, 1],
        [1, 1, 0],
        [1, 1, 1]
    ])
    corners = (corners - 0.5) * self.size
    corners = transform(
        A2B, np.hstack((corners, np.ones((len(corners), 1)))))[:, :3]

    mesh = trimesh.Trimesh(
        vertices=corners,
        faces=[[0, 1, 2], [2, 3, 4], [4, 5, 6], [6, 7, 0]]).bounding_box

    mesh = pr.Mesh.from_trimesh(mesh)
    scene.add(mesh) 
开发者ID:rock-learning,项目名称:pytransform3d,代码行数:26,代码来源:render_urdf.py

示例11: sphere_show

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def sphere_show(self, scene):
    """Render sphere."""
    A2B = tm.get_transform(self.frame, frame)

    center = A2B[:3, 3]
    phi, theta = np.mgrid[0.0:np.pi:100j, 0.0:2.0 * np.pi:100j]
    X = center[0] + self.radius * np.sin(phi) * np.cos(theta)
    Y = center[1] + self.radius * np.sin(phi) * np.sin(theta)
    Z = center[2] + self.radius * np.cos(phi)

    vertices = []
    faces = []
    for i in range(X.shape[0] - 1):
        for j in range(X.shape[1] - 1):
            v1 = [X[i, j], Y[i, j], Z[i, j]]
            v2 = [X[i, j + 1], Y[i, j + 1], Z[i, j + 1]]
            v3 = [X[i + 1, j], Y[i + 1, j], Z[i + 1, j]]
            vertices.extend([v1, v2, v3])
            faces.append(list(range(len(vertices) - 3, len(vertices))))
    mesh = trimesh.Trimesh(vertices=vertices, faces=faces).convex_hull

    mesh = pr.Mesh.from_trimesh(mesh)
    scene.add(mesh) 
开发者ID:rock-learning,项目名称:pytransform3d,代码行数:25,代码来源:render_urdf.py

示例12: save_mesh

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def save_mesh(mesh, name, eval_dir):
  """Save a mesh to disk.

  Args:
    mesh: trimesh.Trimesh, the mesh to save.
    name: Tensor, hash name of the mesh as recorded in the dataset.
    eval_dir: string, path to the directory to save the mesh.
  """
  cls_name, obj_name = mesh_name_helper(name)
  cls_dir = path.join(eval_dir, "meshes", cls_name)
  if not tf.io.gfile.isdir(cls_dir):
    tf.io.gfile.makedirs(cls_dir)
  with tf.io.gfile.GFile(path.join(cls_dir, obj_name + ".obj"), "w") as fout:
    mesh.export(fout, file_type="obj") 
开发者ID:tensorflow,项目名称:graphics,代码行数:16,代码来源:utils.py

示例13: to_trimesh

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def to_trimesh(data):
    r"""Converts a :class:`torch_geometric.data.Data` instance to a
    :obj:`trimesh.Trimesh`.

    Args:
        data (torch_geometric.data.Data): The data object.
    """

    if trimesh is None:
        raise ImportError('Package `trimesh` could not be found.')

    return trimesh.Trimesh(vertices=data.pos.detach().cpu().numpy(),
                           faces=data.face.detach().t().cpu().numpy(),
                           process=False) 
开发者ID:rusty1s,项目名称:pytorch_geometric,代码行数:16,代码来源:convert.py

示例14: from_trimesh

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def from_trimesh(mesh):
    r"""Converts a :obj:`trimesh.Trimesh` to a
    :class:`torch_geometric.data.Data` instance.

    Args:
        mesh (trimesh.Trimesh): A :obj:`trimesh` mesh.
    """

    if trimesh is None:
        raise ImportError('Package `trimesh` could not be found.')

    pos = torch.from_numpy(mesh.vertices).to(torch.float)
    face = torch.from_numpy(mesh.faces).t().contiguous()

    return torch_geometric.data.Data(pos=pos, face=face) 
开发者ID:rusty1s,项目名称:pytorch_geometric,代码行数:17,代码来源:convert.py

示例15: __init__

# 需要导入模块: import trimesh [as 别名]
# 或者: from trimesh import Trimesh [as 别名]
def __init__(self, mesh,
                 T_obj_world=None,
                 material=None,
                 enabled=True):
        """Initialize a scene object with the given mesh, pose, and material.

        Parameters
        ----------
        mesh : trimesh.Trimesh
            A mesh representing the object's geometry.
        T_obj_world : autolab_core.RigidTransform
            A rigid transformation from the object's frame to the world frame.
        material : MaterialProperties
            A set of material properties for the object.
        enabled : bool
            If False, the object will not be rendered.
        """
        if not isinstance(mesh, Trimesh):
            raise ValueError('mesh must be an object of type Trimesh')
        if T_obj_world is None:
            T_obj_world = RigidTransform(from_frame='obj', to_frame='world')
        if material is None:
            material = MaterialProperties()
        if material.smooth:
            mesh = mesh.smoothed()

        self._mesh = mesh
        self._material = material
        self.T_obj_world = T_obj_world
        self._enabled = True 
开发者ID:BerkeleyAutomation,项目名称:meshrender,代码行数:32,代码来源:scene_object.py


注:本文中的trimesh.Trimesh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。