nmwsharp / polyscope

A C++ & Python viewer for 3D data like meshes and point clouds
https://polyscope.run
MIT License
1.76k stars 190 forks source link

Update vertex positions when structure is translated with the gizmo? (handling multiple structures) #276

Closed rahul-mitra13 closed 2 months ago

rahul-mitra13 commented 3 months ago

Hello!

Polyscope is great and I've been using it quite a bit. I wanted to ask about translating structures, specifically surface meshes when I want to work with more than one. When I load up multiple structures in polyscope, it looks something like this:

Screenshot 2024-05-30 at 5 58 46 PM

Cause I don't want them overlayed, I translate one of the structures using the gizmo to end up with something like:

Screenshot 2024-05-30 at 6 00 46 PM

However, let's say I render a curve network (stripes in this example) over the blue structure now. It shows up as the following:

Screenshot 2024-05-30 at 6 02 26 PM

which while pretty funny is not exactly what I want. So I have two questions,

Would appreciate any help or pointers! Thanks :)

Lucascuibu commented 3 months ago

Hi rahul, I guess the mixture of blue and yellow is correctly rendered as intended. Such behaviour inheritances from opengl. I would recommend adjust the positions of two objects in other software like blender, and export each of them separately so that you maintain the relative position and still receive two independent objects.

nmwsharp commented 3 months ago

Hi Rahul, good questions! Indeed, the rendering artifacts in the first image are just good old Z fighting, which I assume you're familiar with.

This structure positioning behavior is determined by the autocenterStructures options flag. If that flag is enabled, each structure you register will be individually translated to put the center of its bounding box at the origin. If it is disabled, each structure will be rendered at exactly the world coordinates you give for it.

Neither behavior does what you want if you are registering multiple structures and want them automatically displayed next to each other :) This would be a cool feature to implement, but there's nothing to do that in Polyscope now. Your only option is to manually set appropriate offsets (either by translating the given world coordinates, or by setting a transform programmatically as you do with the gizmo).

Likewise, there is no built-in support to "parent" the curve network to the mesh and keep their transforms synced up. You have to do it manually/programmatically if you want it to happen (and you should almost certainly disable autocenterStructures). This would also be a great feature to add.

nmwsharp commented 3 months ago

I created a feature request issue here https://github.com/nmwsharp/polyscope/issues/280 for the synced transform thing, that is particularly do-able and would be very useful.

rahul-mitra13 commented 2 months ago

Hi Nick, thanks for the detailed write-up. :)

Yea, I looked into the autocenter flag and setting the transform manually when I encountered this problem but was wondering if there's a simpler or more efficient way polyscope could handle this. I think I'll just stick to manually fixing offsets for my purposes for the time being. I'm a little busy right now but if some time opens up, I'll try writing up the feature!

I'll go ahead and close this issue. Thanks once again!