Skip to content

USD -> SDF: polygon triangulation#819

Merged
ahcorde merged 5 commits intoahcorde/usd/prototype_mainfrom
koonpeng/polygon-triangulation
Jan 18, 2022
Merged

USD -> SDF: polygon triangulation#819
ahcorde merged 5 commits intoahcorde/usd/prototype_mainfrom
koonpeng/polygon-triangulation

Conversation

@koonpeng
Copy link
Copy Markdown

@koonpeng koonpeng commented Jan 12, 2022

🎉 New feature

Summary

This implements the PolygonToTriangles function using the fan-triangulation algorithm. Initially tried to implement delaunay triangulation based on ignition::common's implementation, but the implementation is a wrapper around gts's implementation, which does not support 3D.

While researching a custom implementation, found out that there is a much simpler way using the fan-triangulation, it is not as robust as delaunay but it looks like a better fit for the use case of triangulating convex polygons. It seems like tools like blender also uses a form of fan-triangulation of these use cases and delaunay is more commonly used for more complex scenarios like generating terrains/heightmaps etc.

Test it

Currently tested with GearJoint.usd in isaac sim's examples (should be able to find it with a file system search). It seems to work somewhat, but I'm not sure if the current output is due to bad triangulation or other bugs.

usd:

image

sdf:

image

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Jan 12, 2022
@koonpeng koonpeng changed the base branch from sdf12 to ahcorde/usd/prototype_main January 12, 2022 10:19
@koonpeng koonpeng requested a review from ahcorde January 12, 2022 10:20
@adlarkin adlarkin mentioned this pull request Jan 13, 2022
7 tasks
@koonpeng koonpeng marked this pull request as draft January 13, 2022 01:11
@koonpeng
Copy link
Copy Markdown
Author

koonpeng commented Jan 13, 2022

It appears that gts already supports triangulating meshes, gts_surface_strip should do the trick. I will start that functionality to ignition common, after which, this PR will need the new version.

gts_surface_strip is to create triangle strips from a gts surface, which must already be a triangle mesh, there is gts_triangles_from_edges, I thought it can create a list of triangles from the edges of a polygon but looking at the source, it requires the edges to be already part of a triangle. I can't find any functions in gts to do polygon triangulation.

@koonpeng koonpeng marked this pull request as ready for review January 13, 2022 03:41
Teo Koon Peng and others added 3 commits January 13, 2022 04:06
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Copy link
Copy Markdown
Collaborator

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something is wrong here.

  • I modified the gearjoint.usd inside IssacSim and I removed everything expect one of the cylinders and I saved this world
  • Then I converted this saved world with the sdfconverter and I get the following shape:

cylinder

If we forget for a moment the transformations, the mesh is not rendered properly.

@koonpeng
Copy link
Copy Markdown
Author

Opening the dae in blender at least looks like a cylinder

image

Will try to find out more about what is going on, maybe the way ign performs smoothing causes the distortion.

@koonpeng
Copy link
Copy Markdown
Author

I think the problem is caused by wrong scaling, changing the scales from

<scale>0.733134 0.1 0.1</scale>

to

<scale>0.1 0.1 0.733134</scale>

fixes it

image

Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
@ahcorde ahcorde merged commit aa1333d into ahcorde/usd/prototype_main Jan 18, 2022
@ahcorde ahcorde deleted the koonpeng/polygon-triangulation branch January 18, 2022 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏯 fortress Ignition Fortress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants