diff options
| author | Thomas Grothe <grothe.tr@gmail.com> | 2026-06-22 22:13:11 -0400 |
|---|---|---|
| committer | Thomas Grothe <grothe.tr@gmail.com> | 2026-06-22 22:13:11 -0400 |
| commit | 9f299543778b3885d3b5b97f54e145aabb18056e (patch) | |
| tree | 02884451fc6708621856a059147c741a34afe6ce /AutoMeshInstance.cs | |
| parent | 27aec4dcc347070422bb77adf71c802008278756 (diff) | |
Diffstat (limited to 'AutoMeshInstance.cs')
| -rw-r--r-- | AutoMeshInstance.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/AutoMeshInstance.cs b/AutoMeshInstance.cs new file mode 100644 index 0000000..43c6748 --- /dev/null +++ b/AutoMeshInstance.cs @@ -0,0 +1,36 @@ +using Godot; +using System; + +/** +* Used to auto-generate Meshes that are the same as collision objects, for convenience. +* makes a new MeshInstance3D as a sibling (child of this object's parent) +* and applies the same shape, tranform, and scale. +*/ +public partial class AutoMeshInstance : CollisionShape3D +{ + public override void _Ready() + { + base._Ready(); + + MeshInstance3D mi = new MeshInstance3D(); + if (Shape is BoxShape3D boxshp){ + BoxMesh m = new BoxMesh(); + m.Size = boxshp.Size; + mi.Mesh = m; + } + if (Shape is CylinderShape3D cylshp){ + CylinderMesh m = new CylinderMesh(); + m.TopRadius = cylshp.Radius; + m.BottomRadius = cylshp.Radius; + m.Height = cylshp.Height; + mi.Mesh = m; + } + if (Shape is CapsuleShape3D){} + if (Shape is SphereShape3D){} + + mi.Rotation = Rotation; + mi.Position = Position; + + GetParent().CallDeferred("add_child", mi); + } +} |
