Skip to content

Commit

Permalink
Merge branch 'gz-sim9' into athenaz/texsize_tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
ahcorde authored Sep 10, 2024
2 parents 20891d5 + 9b161db commit a07babe
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 4 deletions.
27 changes: 26 additions & 1 deletion src/systems/breadcrumbs/Breadcrumbs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,33 @@ bool Breadcrumbs::MakeStatic(Entity _entity, EntityComponentManager &_ecm)
Entity childLinkEntity = _ecm.EntityByComponents(
components::CanonicalLink(), components::ParentEntity(_entity));

// If the entity does not have a canonical link, it may be a nested model
if (childLinkEntity == kNullEntity)
return false;
{
// Find canonical link within nested model
auto findCanonicalLink = [&_ecm](Entity _parent, auto &&_findCanonicalLink)
{
auto nestedEntities = _ecm.EntitiesByComponents(
components::Model(), components::ParentEntity(_parent));
for (const auto ent : nestedEntities)
{
auto comp = _ecm.Component<components::ModelCanonicalLink>(ent);
if (comp)
{
return comp->Data();
}
else
{
// recursively search for canonical link
return _findCanonicalLink(ent, _findCanonicalLink);
}
}
return kNullEntity;
};
childLinkEntity = findCanonicalLink(_entity, findCanonicalLink);
if (childLinkEntity == kNullEntity)
return false;
}

Entity detachableJointEntity = _ecm.CreateEntity();
_ecm.CreateComponent(detachableJointEntity,
Expand Down
Binary file added tutorials/files/point_cloud_to_mesh/blob2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tutorials/files/point_cloud_to_mesh/blob2.png
Binary file not shown.
Binary file added tutorials/files/point_cloud_to_mesh/error.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tutorials/files/point_cloud_to_mesh/min_space.png
Binary file not shown.
13 changes: 10 additions & 3 deletions tutorials/point_cloud_to_mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Next, you’ll need to download CloudCompare.
This is the software we will be using to convert our point cloud to a mesh.
CloudCompare is free and open source.
You can download it [here](http://www.danielgm.net/cc/release/).
This tutorial was created using CloudCompare 1.13.2.

## Converting with CloudCompare

Expand All @@ -34,7 +35,7 @@ We'll still walk through reducing points, however, to make the process quicker.

To reduce the number of points in your cloud, click on the tunnel so a yellow cube outline appears around it, then go to `Edit` > `Subsample`.

![Min. space between points](https://raw.githubusercontent.com/gazebosim/gz-sim/main/tutorials/files/point_cloud_to_mesh/min_space.png)
![Min. space between points](https://raw.githubusercontent.com/gazebosim/gz-sim/main/tutorials/files/point_cloud_to_mesh/min_space.jpg)

The number you will need to enter in the `min. space between points` field will vary depending on your point cloud.
A value of .01 was sufficient to bring our point cloud to an easy-to-manage 1 million points.
Expand Down Expand Up @@ -93,7 +94,7 @@ Our tunnel has turned into a blob shape.
This is because the mesh that CloudCompare creates will always be water tight even if it has to add polygons where there are no points.
We just want our tunnels, though, so we need to remove those unnecessary polygons.

![The blob shape](https://raw.githubusercontent.com/gazebosim/gz-sim/main/tutorials/files/point_cloud_to_mesh/blob2.png)
![The blob shape](https://raw.githubusercontent.com/gazebosim/gz-sim/main/tutorials/files/point_cloud_to_mesh/blob2.jpg)

This is where our scalar field comes in.
In the mesh's `Properties` window go to `SF display params` and take the left handle in the graph and drag it to the right until it hits the area where the bulk of the scalar field starts.
Expand All @@ -104,7 +105,7 @@ This will display only the polygons that were created from the point cloud and h
The polygons are only hidden however.
We still need to actually remove them.

![Display original polygons](https://raw.githubusercontent.com/gazebosim/gz-sim/main/tutorials/files/point_cloud_to_mesh/hidden_polygons2.png)
![Display original polygons](https://raw.githubusercontent.com/gazebosim/gz-sim/main/tutorials/files/point_cloud_to_mesh/hidden_polygons2.jpg)

To remove the hidden polygons go to `Edit` > `Scalar fields` > `Filter By Value`.

Expand All @@ -115,12 +116,18 @@ One with the polygons inside our specified range and one containing polygons out

![Splitting the mesh](https://raw.githubusercontent.com/gazebosim/gz-sim/main/tutorials/files/point_cloud_to_mesh/split.png)

It is possible that you will get error "Visibility table not instantiated". This error causes only the "wanted" part of the mesh to be created when splitting, while the other ("unwanted") part will not be generated. But that is not a problem for our use-case.

![Error "Visibility table not instantiated"](https://raw.githubusercontent.com/gazebosim/gz-sim/main/tutorials/files/point_cloud_to_mesh/error.jpg)

### The Completed Model

By hitting `Split` we can view the model before exporting by simply going to `File` > `Save`.
Remember to have the correct mesh selected (`<mesh_name>.part`) since choosing `Split` will give you two new meshes, plus you will still have your original, complete mesh.
Your file format will depend on the software you want to use but `.obj` is a widely supported format that should work in most 3D applications.

Before exporting, check your mesh for holes. If still checked, disable display of the pointcloud, so that only your output mesh is shown. Inspect ground parts of the mesh (or any other parts you are most interested in) and check if there aren't holes in it. If there are some, you can try to repeat the trimming step with more relaxed threshold.

![The completed mesh](https://raw.githubusercontent.com/gazebosim/gz-sim/main/tutorials/files/point_cloud_to_mesh/complete2.png)

You can find more information on CloudCompare and a more in depth look at the tools we used in this tutorial on [the CloudCompare website](https://www.cloudcompare.org/) and the [CloudCompare wiki](https://www.cloudcompare.org/doc/wiki/index.php?title=Main_Page).

0 comments on commit a07babe

Please sign in to comment.