Skip to content

Extracting Coordinates of a specific object ID #617

Closed Answered by merlinND
Sina7474 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @Sina7474,

Does the following snippet do what you are looking for? Please double-check the results since I didn't verify correctness myself.

import mitsuba as mi
import sionna as sn


def get_max_height_per_shape(scene: mi.Scene, axis: int = 2) -> dict[str, float]:
    heights = {}
    for shape in scene.shapes():
        key = shape.id()
        assert key not in heights
        heights[shape.id()] = shape.bbox().extents()[axis]

    return heights

def main():
    scene = sn.rt.load_scene(sn.rt.scene.etoile)
    heights = get_max_height_per_shape(scene.mi_scene)
    print(heights)


if __name__ == "__main__":
    main()

This assumes that the buildings are parallel to "the ground" …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Sina7474
Comment options

@merlinND
Comment options

Answer selected by merlinND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants