Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualize with GLB #138

Open
tuan02092000 opened this issue Aug 14, 2024 · 2 comments
Open

Visualize with GLB #138

tuan02092000 opened this issue Aug 14, 2024 · 2 comments

Comments

@tuan02092000
Copy link

Hello, i use the output as obj files to visualize in a glb file, but the coordinates are not correct. How to fix it? thank you

@tuan02092000
Copy link
Author

tuan02092000 commented Aug 14, 2024

here is an example

Screenshot from 2024-08-14 17-20-56

Screenshot from 2024-08-14 17-17-16

code:

`import trimesh
import pyrender
import os
import glob
import numpy as np
import random

def random_color():
return (np.random.choice(range(1,225))/255, np.random.choice(range(1,225))/255, np.random.choice(range(1,225))/255)

def merge_objs_to_glb(obj_files, output_glb_path):
merged_scene = trimesh.Scene()

rotate_matrix = trimesh.transformations.rotation_matrix(
    angle=np.pi, 
    direction=[1, 0, 0],
    point=[0, 0, 0]
)

for file in obj_files:
    mesh = trimesh.load(file)
    mesh.apply_transform(rotate_matrix)
    mesh.visual.vertex_colors = random_color()
    merged_scene.add_geometry(mesh)

merged_scene.export(output_glb_path)

obj_files = glob.glob("output/*.obj")
output_glb_path = 'merged_model.glb'
merge_objs_to_glb(obj_files, output_glb_path)`

@SebastianJanampa
Copy link

Hi,
I am also working on a problem similar to yours. Could you share the code to get the plot with the meshes?
Also, I think you forgot to add the camera parameters, which are changed for each person.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants