You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Built as a Godot module in C++, Slicer is a port of David Arayan's Ezy-Slicer Unity plugin (who deserves all credit). It allows for the dynamic slicing of convex meshes along a plane. Built against Godot version 3.2.1.
Installing
Slicer follows the installation procedure defined in the Godot custom module documentation guide. It can be built into a compilation of the engine by cloning the repo into Godot's modules folder:
After building Godot with the Slicer module a Slicer node will now be available under Spatial. A Slicer instance can then be used to trigger slices of Mesh geometry like so:
extendsRigidBodyclass_nameSliceableexport(Material) varcross_section_materialexport(Mesh) varmesh_overridefunc_ready():
ifmesh_override:
$MeshInstance.mesh=mesh_override# Setup the collision shape to be the mesh's shapevarshape=ConvexPolygonShape.new()
shape.points=$MeshInstance.mesh.surface_get_arrays(0)[Mesh.ARRAY_VERTEX]
shape.margin=0.015varowner_id=self.create_shape_owner(self)
self.shape_owner_add_shape(owner_id, shape)
funccut(plane_origin: Vector3, plane_normal: Vector3):
varsliced: SlicedMesh=$Slicer.slice($MeshInstance.mesh, self.transform, plane_origin, plane_normal, cross_section_material)
ifnotsliced:
print("No slice occurred")
ifsliced.upper_mesh:
print("Instantiate the upper cut mesh somewhere")
ifsliced.lower_mesh:
print("Instantiate the lower cut mesh somewhere")
For development purposes, Slicer can be built as a dynamic library by passing in the slicer_shared=no option to SCons and using the slicer-shared build alias, such as:
scons slicer_shared=yes slicer-shared
which will build a new dynamic library artifact into Godot's ./bin folder.
There is also a test suite that can be built and run on Unix systems using:
scons platform=osx slicer_tests=yes
For more information on the testing framework and development see the corresponding readme.