Hilma is 3D geometry library in C++ with Python bindings (with support for Numpy) ready to be embed into your projects.
Dependencies:
- CMake, Swig and Python3
- GLM required
- OpenImageDenoise optional
- Before compiling install dependencies:
// In linux
sudo apt install libglm-dev cmake swig python3-numpy
// In MacOS
brew install glm cmake swig
brew install --build-from-source open-image-denoise
- Then compile
mkdir build
cd build
cmake ..
make
sudo make install
Note: to install inside anaconda do:
swig -c++ -python hilma.i
/anaconda3/bin/./python3.7 setup.py build_ext --inplace
/anaconda3/bin/./python3.7 setup.py install
Alternatively to installing Hilma on your system you can easily copy the content of include/
and src/
folder to your project, just make sure you
#include "hilma/types/mesh.h"
#include "hilma/io/ply.h"
int main(int argc, char **argv) {
float vertices[][2] = { {-1.0, -1.0} , {-1.0, 1.0} , {1.0, 1.0}, {1.0, -1.0} };
int indices[][3] = { {1, 0, 3}, {1, 3, 2 } };
hilma::Mesh mesh;
mesh.addVertices( &vertices[0][0], 4, 2);
mesh.addIndices( &indices[0][0], 2, 3);
hilma::savePly("rect.ply", mesh, false);
return 1;
}
First you need to create the package and install it
sudo apt install swig
make install
Then you can use it as follow:
from hilma import Mesh, savePly
mesh = Mesh()
mesh.addVertices( [ [-1.0, -1.0], [-1.0, 1.0], [1.0, 1.0], [1.0, -1.0] ] )
mesh.addIndices( [( 1, 0, 3 ), (1, 3, 2)] )
savePly("rect.ply", mesh, False)
Some of the code is based or depends 3rd party libraries such us:
- OpenFrameworks
ofMesh
andofPolyline
- Mapbox's Earcut tessellator
- Tangram-es's ployline to spline converter
- Dan Wilcox's swig wrapper for GLM
- Dimitri Diakopoulos' TinyPly
- Syoyo Fujita's TinyGltf
- Syoyo Fujita's TinyObj loader
- Peter Shirley's Ray Tracing in One Weekend
- Ray/Triangle intersection
- Michael Fogleman's Heightmap meshing utility
- Felzenszwalb page at Brown University for Image to SDF
HILMA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors will be added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed.