support glb and more input
Browse files
Anymate/utils/ui_utils.py
CHANGED
@@ -19,8 +19,8 @@ def visualize_results(mesh_file=None, joints=None, conns=None, skins=None):
|
|
19 |
|
20 |
if mesh_file is not None:
|
21 |
# Load the original mesh (in blue) with transparency
|
22 |
-
|
23 |
-
original_mesh = obj2mesh(mesh_file)
|
24 |
if skins is not None:
|
25 |
# pdb.set_trace()
|
26 |
# Get per-vertex colors based on skinning weights
|
@@ -50,8 +50,8 @@ def visualize_results(mesh_file=None, joints=None, conns=None, skins=None):
|
|
50 |
|
51 |
# face_colors = np.zeros((len(original_mesh.faces), 4))
|
52 |
|
53 |
-
|
54 |
-
processed_mesh = obj2mesh(mesh_file)
|
55 |
# Assign vertex colors from original_mesh to processed_mesh
|
56 |
# Since they might have different number of vertices, we need to find closest vertices
|
57 |
|
@@ -218,7 +218,7 @@ def prepare_blender_file(normalized_mesh_file):
|
|
218 |
|
219 |
folder = normalized_mesh_file.replace('object.obj', '')
|
220 |
abs_folder = os.path.abspath(folder)
|
221 |
-
os.system(f"python Render.py --path {abs_folder}")
|
222 |
|
223 |
blender_file = os.path.join(folder, 'blender_output.blend')
|
224 |
while not os.path.exists(blender_file):
|
@@ -248,7 +248,8 @@ def process_input(mesh_file):
|
|
248 |
# make folder for tmp files
|
249 |
os.makedirs(f"Anymate/tmp/{mesh_file.split('/')[-1].replace('.obj', '')}", exist_ok=True)
|
250 |
|
251 |
-
normalized_mesh = normalize_mesh(
|
|
|
252 |
normalized_mesh_file = f"Anymate/tmp/{mesh_file.split('/')[-1].replace('.obj', '')}/object.obj"
|
253 |
normalized_mesh.export(normalized_mesh_file)
|
254 |
|
@@ -274,8 +275,8 @@ def get_result_connectivity(mesh_file, model, pc, joints):
|
|
274 |
return get_connectivity(pc, joints, model, device=anymate_args.device, save=mesh_file.replace('object.obj', 'conns.pt'))
|
275 |
|
276 |
def get_result_skinning(mesh_file, model, pc, joints, conns):
|
277 |
-
|
278 |
-
mesh = obj2mesh(mesh_file)
|
279 |
# vertices = torch.from_numpy(mesh.vertices, device='cpu')
|
280 |
# vertex_normals = torch.from_numpy(mesh.vertex_normals, device='cpu')
|
281 |
# vertices = torch.cat([vertices, vertex_normals], dim=-1)
|
|
|
19 |
|
20 |
if mesh_file is not None:
|
21 |
# Load the original mesh (in blue) with transparency
|
22 |
+
original_mesh = trimesh.load(mesh_file)
|
23 |
+
# original_mesh = obj2mesh(mesh_file)
|
24 |
if skins is not None:
|
25 |
# pdb.set_trace()
|
26 |
# Get per-vertex colors based on skinning weights
|
|
|
50 |
|
51 |
# face_colors = np.zeros((len(original_mesh.faces), 4))
|
52 |
|
53 |
+
processed_mesh = trimesh.load(mesh_file)
|
54 |
+
# processed_mesh = obj2mesh(mesh_file)
|
55 |
# Assign vertex colors from original_mesh to processed_mesh
|
56 |
# Since they might have different number of vertices, we need to find closest vertices
|
57 |
|
|
|
218 |
|
219 |
folder = normalized_mesh_file.replace('object.obj', '')
|
220 |
abs_folder = os.path.abspath(folder)
|
221 |
+
os.system(f"python Render.py --path '{abs_folder}'")
|
222 |
|
223 |
blender_file = os.path.join(folder, 'blender_output.blend')
|
224 |
while not os.path.exists(blender_file):
|
|
|
248 |
# make folder for tmp files
|
249 |
os.makedirs(f"Anymate/tmp/{mesh_file.split('/')[-1].replace('.obj', '')}", exist_ok=True)
|
250 |
|
251 |
+
normalized_mesh = normalize_mesh(trimesh.load(mesh_file))
|
252 |
+
# normalized_mesh = normalize_mesh(obj2mesh(mesh_file))
|
253 |
normalized_mesh_file = f"Anymate/tmp/{mesh_file.split('/')[-1].replace('.obj', '')}/object.obj"
|
254 |
normalized_mesh.export(normalized_mesh_file)
|
255 |
|
|
|
275 |
return get_connectivity(pc, joints, model, device=anymate_args.device, save=mesh_file.replace('object.obj', 'conns.pt'))
|
276 |
|
277 |
def get_result_skinning(mesh_file, model, pc, joints, conns):
|
278 |
+
mesh = trimesh.load(mesh_file)
|
279 |
+
# mesh = obj2mesh(mesh_file)
|
280 |
# vertices = torch.from_numpy(mesh.vertices, device='cpu')
|
281 |
# vertex_normals = torch.from_numpy(mesh.vertex_normals, device='cpu')
|
282 |
# vertices = torch.cat([vertices, vertex_normals], dim=-1)
|