Outputting the heightmap of a SCMDeformableTerrain?

43 views
Skip to first unread message

Whop42 Whop42

unread,
Jan 11, 2023, 8:17:47 PM1/11/23
to ProjectChrono
Hi,

I'm simulating an object deforming soil, and would like to have the data in the form of a heightmap. I have a simulation rendering properly with a SCMDeformableTerrain instance, but how do I get the information out of that into a .png or something similar?

Thanks,
whop42

huwe...@gmail.com

unread,
Jan 13, 2023, 10:21:09 AM1/13/23
to ProjectChrono
Take a look at this demo at line327, I think that might be what you would like to find.

Thank you,
Wei

Radu Serban

unread,
Jan 13, 2023, 11:42:26 AM1/13/23
to ProjectChrono

Wei – this is not what the original poster asked for.

 

Whop42 – we do not have a function for exporting the deformed state of an SCM terrain patch as a heightmap. I’d be curious to know why you would want that in the first place.  Nonetheless, you can generate a heightmap image yourself (e.g., with STB which is what we use to initialize an SCM patch from a heightmap). To do that, you can extract the current height of the SCM terrain at the locations you are interested in (SCMDeformableTerrain::GetHeight) or else grab the current visualization mesh ( SCMDeformableTerrain::GetMesh) and then convert these heights to grayscale and load an image pixel-by-pixel, effectively doing the reverse of what we do in SCMDeformableSoil::Initialize.

 

--Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/76724687-dbbb-48b0-a730-87b088f21cf6n%40googlegroups.com.

Whop42 Whop42

unread,
Jan 15, 2023, 2:06:05 PM1/15/23
to ProjectChrono
Thank you, that was exactly what I was looking for.

Whop42 Whop42

unread,
Jan 19, 2023, 7:11:31 PM1/19/23
to ProjectChrono
Hello again,
I have run into a problem with this approach (although i suspect it's just my code.) I used the SCMDeformableTerrain's mesh's ChTriangleMeshConnected to gather a list of all the vertices in the mesh. I then added the heights to a 2D list (and normalized them), then dumped them into a grayscale image. However, the image turns out unintelligible (example attached.) It's supposed to be a shoeprint, imprinted from a (3D-scanned) .obj of a shoe.

tmpw15joiam.PNG
Print in Irrlicht:2023-01-19_16-10.png
How do I rectify this problem and make the print show up, like it is in Irrlicht?
Reply all
Reply to author
Forward
0 new messages