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

Can a Scene be attached to object from another scene? #2293

Open
egormkn opened this issue Sep 26, 2024 · 0 comments
Open

Can a Scene be attached to object from another scene? #2293

egormkn opened this issue Sep 26, 2024 · 0 comments

Comments

@egormkn
Copy link

egormkn commented Sep 26, 2024

Hello!

I'm trying to figure out how Scene and SceneGraph classes work. I want to use Scene to create an object group which doesn't know anything about where it will be placed, and then attach it to the object from another scene. Is it supposed to work this way?

Here is an example code:

def make_head_frame():
    head_frame = trimesh.Scene(base_frame="head_frame")

    head = trimesh.creation.icosphere(radius=3)
    left_ear = trimesh.creation.icosphere(radius=1)
    right_ear = trimesh.creation.icosphere(radius=1)
    
    head_frame.add_geometry(head, node_name="head")
    head_frame.add_geometry(left_ear, node_name="left_ear", parent_node_name="head", transform=trimesh.transformations.translation_matrix([-2, 0, 2]))
    head_frame.add_geometry(right_ear, node_name="right_ear", parent_node_name="head", transform=trimesh.transformations.translation_matrix([2, 0, 2]))

    return head_frame


def make_body_frame():
    body_frame = trimesh.Scene(base_frame="body_frame")
    
    body = trimesh.creation.box((5, 4, 10))
    body_frame.add_geometry(body, node_name="body")

    head_frame = make_head_frame()
    # parent_node_name seems to be unused here
    body_frame.add_geometry(head_frame, parent_node_name="body", transform=trimesh.transformations.translation_matrix([0, 0, 10]))
    
    body_frame.graph.show()

    return body_frame


make_body_frame().show()

Here is a transform graph I get:
image

Could you provide some examples on composing multiple scenes (object groups) with transforms between them?

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

1 participant