How to use the trimesh.creation function in trimesh

To help you get started, we’ve selected a few trimesh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cselab / Mirheo / tests / restart / rigid_vector.py View on Github external
parser = argparse.ArgumentParser()
parser.add_argument("--restart", action='store_true', default=False)
parser.add_argument("--ranks", type=int, nargs=3)
args = parser.parse_args()

ranks  = args.ranks
domain = (16, 16, 16)
dt = 0.0

u = mir.Mirheo(ranks, domain, dt, debug_level=9,
              log_filename='log', no_splash=True,
              checkpoint_every = (0 if args.restart else 5))

    
mesh = trimesh.creation.icosphere(subdivisions=1, radius = 0.1)

coords = [[-0.01, 0., 0.],
          [ 0.01, 0., 0.],
          [0., -0.01, 0.],
          [0.,  0.01, 0.],
          [0., 0., -0.01],
          [0., 0.,  0.01]]

udx_mesh = mir.ParticleVectors.Mesh(mesh.vertices.tolist(), mesh.faces.tolist())
pv       = mir.ParticleVectors.RigidObjectVector("pv", mass=1.0, inertia=[0.1, 0.1, 0.1], object_size=len(coords), mesh=udx_mesh)

nobjs = 10
pos = [ np.array(domain) * t for t in np.linspace(0, 1.0, nobjs) ]
Q = [ np.array([1.0, 0., 0., 0.])  for i in range(nobjs) ]
pos_q = np.concatenate((pos, Q), axis=1)
github mikedh / trimesh / trimesh / resources / helpers / id_helper.py View on Github external
capsule = trimesh.creation.capsule(
            radius=np.random.random() * 100,
            height=np.random.random() * 1000,
            count=np.clip(np.random.random(2) * 720,
                          20,
                          720).astype(int))
        bodies.append(cylinder)
        bodies.append(capsule)
    for i in range(10):
        bodies.append(trimesh.creation.random_soup(
            int(np.clip(np.random.random() * 1000,
                        20,
                        1000))))
    bodies.append(trimesh.creation.icosphere())
    bodies.append(trimesh.creation.uv_sphere())
    bodies.append(trimesh.creation.icosahedron())

    return np.array(bodies)
github hassony2 / obman_train / mano_train / networks / branches / atlasbranch.py View on Github external
torch.nn.ReLU(),
                torch.nn.Linear(int(self.bottleneck_size / 2), 3),
            )
        self.predict_scale = predict_scale
        if self.predict_scale:
            self.decode_scale = torch.nn.Sequential(
                torch.nn.Linear(
                    self.bottleneck_size, int(self.bottleneck_size / 2)
                ),
                torch.nn.ReLU(),
                torch.nn.Linear(int(self.bottleneck_size / 2), 1),
            )
            self.decode_scale[-1].bias.data.fill_(1)

        if mode == "sphere":
            test_mesh = trimesh.creation.icosphere(
                subdivisions=inference_ico_divisions
            )

            # Initialize inference vertices and faces
            test_faces = np.array(test_mesh.faces)
            test_verts = test_mesh.vertices
        else:
            raise ValueError("{} not in [sphere]".format(mode))
        self.test_verts = torch.Tensor(
            np.array(test_verts).astype(np.float32)
        ).cuda()
        self.test_faces = test_faces
github musyoku / gqn-dataset-renderer / opengl / pyrender / objects.py View on Github external
def Capsule():
    sphere = trimesh.creation.capsule(radius=0.25, height=0.75)
    mesh = Mesh.from_trimesh(sphere, smooth=True)
    node = Node(
        mesh=mesh,
        rotation=quaternion.from_pitch(math.pi / 2),
        translation=np.array([0, 0.75, 0]))
    return node
github boschresearch / pcg_gazebo_pkgs / pcg_libraries / src / pcg_gazebo / visualization.py View on Github external
def create_scene(models, mesh_type='collision', add_pseudo_color=False, alpha=0.5, add_axis=True):
    scene = trimesh.scene.Scene()
    if add_axis:
        scene.add_geometry(trimesh.creation.axis())

    if isinstance(models, list):
        meshes = list()
        for item in models:
            try:
                new_meshes = item.get_meshes(mesh_type=mesh_type)    
            except RuntimeWarning as ex:
                PCG_ROOT_LOGGER.error('Cannot display {}, message={}'.format(item.name, ex))
                new_meshes = list()
            meshes = meshes + new_meshes
    else:
        meshes = models.get_meshes(mesh_type=mesh_type)
    if len(meshes) > 0:
        if add_pseudo_color:
            for i in range(len(meshes)):
                meshes[i].visual.face_colors = np.hstack((255. * np.random.random(3), [alpha * 255]))
github musyoku / gqn-dataset-renderer / pyrender / objects.py View on Github external
def Capsule():
    sphere = trimesh.creation.capsule(radius=0.25, height=0.5)
    mesh = Mesh.from_trimesh(sphere, smooth=True)
    node = Node(
        mesh=mesh,
        rotation=quaternion.from_pitch(math.pi / 2),
        translation=np.array([0, 0.5, 0]))
    return node
github mikedh / trimesh / trimesh / primitives.py View on Github external
def _create_mesh(self):
        log.debug('creating mesh for Capsule primitive')

        mesh = creation.capsule(radius=self.primitive.radius,
                                height=self.primitive.height)
        mesh.apply_transform(self.primitive.transform)

        self._cache['vertices'] = mesh.vertices
        self._cache['faces'] = mesh.faces
        self._cache['face_normals'] = mesh.face_normals
github PaddlePaddle / RLSchool / rlschool / quadrotor / render.py View on Github external
def _add_drone_velocity(self, init_velocity_vector, radius=0.008,
                            color=[255, 0, 0]):
        """
        Add the drone velocity vector as a cylinder into drone drawer batch.
        """
        translation = np.eye(4)
        translation[:3, 3] = [0, 0, 0.5]

        height = np.linalg.norm(init_velocity_vector)
        transform_z_axis = init_velocity_vector / height
        transform = np.eye(4)
        transform[:3, 2] = transform_z_axis
        transform = np.dot(translation, transform)

        velocity_axis = trimesh.creation.cylinder(
            radius=radius, height=height, transform=transform)
        velocity_axis.visual.face_colors = color
        axis_origin = trimesh.creation.uv_sphere(
            radius=radius*5, count=[10, 10])
        axis_origin.visual.face_colors = color

        merge = trimesh.util.concatenate([axis_origin, velocity_axis])
        args = rendering.convert_to_vertexlist(merge)
        drawer = self.drone_batch.add_indexed(*args)
        return drawer