• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

cj-dimaggio/godot-slicer: A port of Ezy-Slicer for the Godot game engine

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

cj-dimaggio/godot-slicer

开源软件地址:

https://github.com/cj-dimaggio/godot-slicer

开源编程语言:

C++ 97.0%

开源软件介绍:

Godot-Slicer

A port of Ezy-Slicer for the Godot game engine.

Example Image

About

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:

git clone [email protected]:cj-dimaggio/godot-slicer.git <godot-repo>/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:

extends RigidBody

class_name Sliceable

export(Material) var cross_section_material
export(Mesh) var mesh_override

func _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:

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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
cdoty/SuperPlay: Super Play - SNES inspired game engine发布时间:2022-06-07
下一篇:
Alairion/captal-engine: A C++20 2D oriented game engine发布时间:2022-06-07
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap