Genesis icon indicating copy to clipboard operation
Genesis copied to clipboard

How to export properties in simulation, e.g. point positions

Open kyleleey opened this issue 1 year ago • 3 comments

Hi, thanks for open-sourcing such a great framework.

I wonder is there an interface to export the properties of entities during each scene.step()? For example, when using mesh to initialize the entities, is there a function to directly get the positions of mesh vertices in each step?

Thanks!!

kyleleey avatar Dec 19 '24 23:12 kyleleey

Seems it's possible to use entity.solver.particles.to_numpy()['pos'] to get property like position. I wonder if there exists a more formal interface? Also when entities are with materials like liquid or fluid, the particles are more than original mesh vertices, what's the parameters that store the mapping from those particles to original mesh vertices' indices?

Thanks!!

kyleleey avatar Dec 20 '24 00:12 kyleleey

Thanks for sharing the answer. In general, you can check the member function in entity. For example, things related to what you want are

Also note that if you access directly from the solver, remember to take indexing offset into consideration, i.e., the range of particle indices that belong to the same entity like particle_start -- also for other types of entity as well.

We will try to improve the api as well as the doc

Re mesh-particle mapping, which solver are you referring to? (for some solvers, we do sampling based on the mesh and thus there is no 1-1 correspondence between mesh vertices and particles -- the sampler argument in material)

zswang666 avatar Dec 21 '24 15:12 zswang666

Hi,

Thanks for the reply! Good to know there are a bunch of interfaces on getting properties for particles.

I'm still curious if there is anyway to get the properties of input morphs, especially meshes? At least its vertices position properties. Because if set the visual mode as "visual", the renderer is rendering the mesh instead of particles, so I assume there exists some ways to get the positions of mesh vertices?

kyleleey avatar Dec 21 '24 17:12 kyleleey