예제 #1
0
    def create_scene(self, hws, alphas, N):
        batch = []
        for i in range(N):
            scene = []
            for mesh_name in self.models:
                hw = hws[mesh_name]
                alpha = alphas[mesh_name]
                N, K, _ = hw.shape
                for k in range(K):
                    c = self.colors[mesh_name].clone()
                    c[..., 3] = alpha[i, k]

                    textures = TexturesVertex(verts_features=[c])
                    m = Meshes(verts=[self.verts[mesh_name].clone()],
                               faces=[self.faces[mesh_name].clone()],
                               textures=textures)

                    t = Translate(y=hw[i, k, 0],
                                  x=hw[i, k, 1],
                                  z=torch.zeros(1, device=self.device),
                                  device=str(self.device))
                    m = m.update_padded(t.transform_points(m.verts_padded()))
                    scene += [m]
            batch += [join_meshes_as_scene(scene)]
        batch = join_meshes_as_batch(batch)
        return batch
예제 #2
0
        hw = hws[mesh_name]
        alpha = alphas[mesh_name]
        N, K, _ = hw.shape
        for k in range(K):
            c = colors[mesh_name].clone()
            c[..., 3] = c[..., 3] * alpha[i, k]
            textures = TexturesVertex(verts_features=[c])
            m = Meshes(verts=[verts[mesh_name].clone()],
                       faces=[faces[mesh_name].clone()],
                       textures=textures)
            #m = meshes[mesh_name].clone().detach().to(device)
            t = Translate(y=hw[i, k, 0],
                          x=hw[i, k, 1],
                          z=torch.zeros(1, device=device),
                          device=str(device))
            m = m.update_padded(t.transform_points(m.verts_padded()))
            scene += [m]

teapot_mesh = join_meshes_as_scene(scene)

#for i, (name, particles) in particles_per_mesh:

#textures = TexturesVertex(verts_features=colors)

# meshes = Meshes(
#     verts=verts,
#     faces=faces,
#     textures=textures,
# )

# model_transforms = torch.zeros(len(models), 3)