Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cj-dimaggio/godot-slicer
A port of Ezy-Slicer for the Godot game engine
https://github.com/cj-dimaggio/godot-slicer
Last synced: 6 days ago
JSON representation
A port of Ezy-Slicer for the Godot game engine
- Host: GitHub
- URL: https://github.com/cj-dimaggio/godot-slicer
- Owner: cj-dimaggio
- License: mit
- Created: 2020-05-25T03:28:44.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-05T15:41:53.000Z (over 3 years ago)
- Last Synced: 2024-08-02T06:19:27.993Z (3 months ago)
- Language: C++
- Homepage:
- Size: 1.11 MB
- Stars: 114
- Watchers: 5
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-godot - Godot-Slicer - A port of [Ezy-Slicer](https://github.com/DavidArayan/ezy-slice) for Godot. (Modules / 3D)
- awesome-godot-3 - Godot-Slicer - A port of [Ezy-Slicer](https://github.com/DavidArayan/ezy-slice) for Godot. (Modules / 3D)
- awesome-godot-3 - Godot-Slicer - A port of [Ezy-Slicer](https://github.com/DavidArayan/ezy-slice) for Godot. (Modules / 3D)
README
# Godot-Slicer
A port of [Ezy-Slicer](https://github.com/DavidArayan/ezy-slice) for the [Godot game engine](https://godotengine.org/).
![Example Image](/imgs/example.png)
## About
Built as a Godot module in C++, Slicer is a port of [David Arayan's Ezy-Slicer](https://github.com/DavidArayan/ezy-slice) 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](https://docs.godotengine.org/en/stable/development/cpp/custom_modules_in_cpp.html). It can be built into a compilation of the engine by cloning the repo into Godot's modules folder:```bash
git clone [email protected]:cj-dimaggio/godot-slicer.git /modules/slicer
```## Using
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:```gdscript
extends RigidBodyclass_name Sliceable
export(Material) var cross_section_material
export(Mesh) var mesh_overridefunc _ready():
if mesh_override:
$MeshInstance.mesh = mesh_override# Setup the collision shape to be the mesh's shape
var shape = ConvexPolygonShape.new()
shape.points = $MeshInstance.mesh.surface_get_arrays(0)[Mesh.ARRAY_VERTEX]
shape.margin = 0.015
var owner_id = self.create_shape_owner(self)
self.shape_owner_add_shape(owner_id, shape)func cut(plane_origin: Vector3, plane_normal: Vector3):
var sliced: SlicedMesh = $Slicer.slice($MeshInstance.mesh, self.transform, plane_origin, plane_normal, cross_section_material)if not sliced:
print("No slice occurred")
if sliced.upper_mesh:
print("Instantiate the upper cut mesh somewhere")if sliced.lower_mesh:
print("Instantiate the lower cut mesh somewhere")
```An example project can also be found at: https://github.com/cj-dimaggio/godot-slicer-example-project
## Development
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:```bash
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:
```bash
scons platform=osx slicer_tests=yes
```For more information on the testing framework and development see the [corresponding readme](./tests/README.md).