Play around with internal nodes

They are selectable, isn't that interesting?
This commit is contained in:
Vojtěch Struhár 2025-02-25 22:49:55 +01:00
parent ac50e8eee7
commit 1fa1e709ff
6 changed files with 89 additions and 2 deletions

View File

@ -66,6 +66,12 @@ Mám v plánu udělat texture masku pro tvarování protálů. S házením stín
> Dal by se udělat celkem jednoduchý algoritmus co by generoval mesh "s prohlubní" pro jakýkoliv nákres zepředu. Obdélník je nejjednodušší, ale udělat oblouček by asi nebyl problém. > Dal by se udělat celkem jednoduchý algoritmus co by generoval mesh "s prohlubní" pro jakýkoliv nákres zepředu. Obdélník je nejjednodušší, ale udělat oblouček by asi nebyl problém.
> >
> **Custom Mesh subclassa?** > Podobně jak se dá "kreslit" s CSG polygonem. Ale to by byl teda komplikovaný editor widget. Ty oblouky bysme asi chtěli hladké - to vypadá na něco na styl Curve editoru... ugh
>
> ![csg-polygon](assets/csg-polygon.png)
>
> [Cyclops Level Editor](https://github.com/blackears/cyclopsLevelBuilder/blob/master/doc/index.md#display-mode)
**Custom Mesh subclassa?**
- Custom mesh subclassa je trochu divná věc. Když to všechno nastaví jeden editorový Node tak to bude asi lepší. Custom mesh se mi přegenerovává při každém spuštění, ale já chci aby se prostě "zapekl" a uložil a nazdar bazar... - Custom mesh subclassa je trochu divná věc. Když to všechno nastaví jeden editorový Node tak to bude asi lepší. Custom mesh se mi přegenerovává při každém spuštění, ale já chci aby se prostě "zapekl" a uložil a nazdar bazar...

BIN
assets/csg-polygon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

View File

@ -162,7 +162,6 @@ portal = NodePath("../Portal A")
[node name="Outer" type="CSGBox3D" parent="."] [node name="Outer" type="CSGBox3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 2.78925) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 2.78925)
visible = false
size = Vector3(2.2, 3.2, 0.25) size = Vector3(2.2, 3.2, 0.25)
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="Outer"] [node name="CSGCombiner3D" type="CSGCombiner3D" parent="Outer"]

View File

@ -0,0 +1,43 @@
@tool
extends Node3D
func _add_inspector_buttons() -> Array:
var buttons: Array = []
buttons.push_back({
"name": "Regular cube mesh",
"pressed": _add_regular_cube_mesh
})
buttons.push_back({
"name": "Internal cube mesh",
"pressed": _add_internal_cube_mesh
})
buttons.push_back({
"name": "Delete all children",
"pressed": func(): for child in get_children(true): child.queue_free()
})
return buttons
func _add_regular_cube_mesh() -> void:
var m = MeshInstance3D.new()
var b = BoxMesh.new()
m.mesh = b
add_child(m, true)
m.owner = self
m.position.x = 1.5 * get_child_count(true)
func _add_internal_cube_mesh() -> void:
var m = MeshInstance3D.new()
var b = BoxMesh.new()
m.mesh = b
add_child(m, true, Node.INTERNAL_MODE_BACK)
var mat = StandardMaterial3D.new()
mat.albedo_color = Color("ff4c4e")
b.material = mat
m.owner = self
m.position.x = 1.5 * get_child_count(true)

View File

@ -0,0 +1 @@
uid://ouk76qr5gpq0

View File

@ -0,0 +1,38 @@
[gd_scene load_steps=8 format=3 uid="uid://bnrph4k6wpruy"]
[ext_resource type="Script" uid="uid://ouk76qr5gpq0" path="res://levels/test_internal_nodes.gd" id="1_glqbe"]
[sub_resource type="BoxMesh" id="BoxMesh_glqbe"]
[sub_resource type="BoxMesh" id="BoxMesh_dodl2"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_wgeau"]
albedo_color = Color(1, 0.298039, 0.305882, 1)
[sub_resource type="BoxMesh" id="BoxMesh_j0q2q"]
material = SubResource("StandardMaterial3D_wgeau")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_47wcs"]
albedo_color = Color(1, 0.298039, 0.305882, 1)
[sub_resource type="BoxMesh" id="BoxMesh_bkhqo"]
material = SubResource("StandardMaterial3D_47wcs")
[node name="test_internal_nodes" type="Node3D"]
script = ExtResource("1_glqbe")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.5, 0, 0)
mesh = SubResource("BoxMesh_glqbe")
[node name="MeshInstance3D3" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.5, 0, 0)
mesh = SubResource("BoxMesh_dodl2")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0)
mesh = SubResource("BoxMesh_j0q2q")
[node name="MeshInstance3D4" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0)
mesh = SubResource("BoxMesh_bkhqo")