|Project Name||Stars||Downloads||Repos Using This||Packages Using This||Most Recent Commit||Total Releases||Latest Release||Open Issues||License||Language|
|3d Machine Learning||8,647||4 months ago||19|
|A resource repository for 3D machine learning|
|Pytorch3d||7,340||5||2 days ago||10||April 28, 2022||187||other||Python|
|PyTorch3D is FAIR's library of reusable components for deep learning with 3D data|
|Draco||5,664||13||20||17 days ago||23||July 07, 2022||100||apache-2.0||C++|
|Draco is a library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics.|
|Meshlab||3,671||2 months ago||141||gpl-3.0||C++|
|The open source mesh processing system|
|Cloudcompare||2,722||5 days ago||186||other||C++|
|CloudCompare main repository|
|Graphics||2,708||3||1||a month ago||25||December 03, 2021||147||apache-2.0||Python|
|TensorFlow Graphics: Differentiable Graphics Layers for TensorFlow|
|Yocto Gl||2,590||a month ago||9||C++|
|Yocto/GL: Tiny C++ Libraries for Data-Driven Physically-based Graphics|
|Pyvista||1,810||13||99||20 hours ago||60||June 30, 2022||354||mit||Python|
|3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)|
|A solution to visualize and explore 3D models in your browser.|
|Vedo||1,639||12||a day ago||18||May 08, 2022||92||mit||Python|
|A python module for scientific analysis of 3D data based on VTK and Numpy|
[Fuhrmann,2003] introduces an efficient method to calculate the SDF of 3D objects.
In their paper, they state that the distance from a point to a triangle can be calculated using Voronoi regions, but they do not provide any details. After a lot of searching, I found this article written by Erin Catto which explains exactly how to calculate that distance using Voronoi regions.
Strongly recommend you to use SDFGen from Christopher Batty. It is much more efficient and accurate than mine.
The MIT License (MIT)
Copyright (c) 2021, Jiang Ye
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For example, in Fig.1, we want to find the distance from
We first project
P onto the plane of
ΔABC to get
By examining the barycentric coordinate of
P with respect to
we can know whether
P' is inside
ΔABC or not.
If inside, then
dist = dot(n, AP) * theSignOf(dot(n, AP)).
Otherwise, we must find the closest edge (Fig.2 left) or vertex (Fig.2 right) of
One way to achieve this is to use Voronoi regions. Details of the algorithm can be found in Erin Catto's article. Here, I only provide the summary (Fig.3).
Note that the
(u,v) of a line segment and the
(u,v,w) of a barycentric coordinate may be different due to the definition we use.
In that case, the conditional statements in Fig.3 may also be different.
So be careful with that.
The full article of calculating the barycentric coordinate of a point can be found here.
For short, if a triangle is defined by vertices
ABC in counter-clockwise,
P is a point on the same plane with
P can be described as
P = uA + vB + wC.
(u, v, w) is called the barycentric coordinate of
P with respect to
(u, v, w) can be calculated using the ratio of triangle areas.
Scap be the area of triangle
(u, v, w) can be calculated as
u = Sbcp/Sabc v = Scap/Sabc w = Sabp/Sabc
If a triangle is defined by vertices
then its area can be calculated as
Sabc = 0.5 * length(cross(AB, AC)).
Note that the magnitude of the cross product of
AC defines the area of a parallelogram,
and the area of a triangle is equal to half of that area, i.e.
Sparallelogram = |AB|*|AC|*sin(∠A) = length(cross(AB, AC)) Striangle = 0.5 * Sparallelogram
Be careful that the order of the vectors in cross product matters.
For example, when point
P is outside the triangle,
the four areas will have different signs.
In this case, we must use something like
vec3 temp = cross(AB, AC); float area = 0.5 * length(temp) * sign;
to calculate the signed area.
In 2D, we can use the z-component to decide
float sign = (temp.z > 0) ? 1 : -1;
In 3D, However, things become a little different because
temp can points to any direction.
As a result, we cannot decide
sign only based on z-component.
Instead, we can use the surface normal
temp points to the same direction as
then we decide
sign = 1.
sign = -1, i.e.
float sign = dot(normalize(temp), N);
This case is essentially equal to the "changing signs" cases pointed out by [Fuhrmann, 2003].
Assume that there are two adjacent triangles
B, and point
Q is one of their shared vertices.
P is a point outside the triangle, and the distance from
B are both
P is forward to
B, but is backward to
So the corresponding signed distance are
In this case,
P is obviously outside the mesh.
However, if we simply use
abs(newDist) < abs(oldDist) to decide the new distance,
That is, if
B is previously iterated than
then the signed distance will always be
P will be decided as inside the mesh.
To solve this problem, we assume that if
abs(newDist) == abs(oldDist), but their signs are different, we keep the positive one as the new distance.
This correctly decides
P as outside the mesh.
Add some simple simulation code to test the SDF-based collision detection.
To increase accuracy, we can use smaller
cellSize when creating SDF,
and smaller threshold when doing collision detection.
A common way to solid-voxelize a mesh is to use octree.
A signed distance field can also be used as a solid voxelizer.
for the entire field: if(signedDistance < 0) voxelPosition = cellPosition;
When calculating SDF for a mesh, we use surface normals, not vertex normals. So be careful when you export your mesh data from your 3D modeling software (e.g. Blender). Especially, if you use a smooth shader, you should prepare two same meshes. One with surface normals for calculating SDF, the other one with vertex normals for smooth shading.
[Fuhrmann,2003] Fuhrmann, Arnulph, Gerrit Sobotka, and Clemens Groß. "Distance fields for rapid collision detection in physically based modeling." Proceedings of GraphiCon 2003. 2003.