Adds missing data

This commit is contained in:
Michel 2025-02-03 19:17:20 +01:00
parent e6391d9fdd
commit 53cdcc3433
620 changed files with 47293 additions and 151 deletions

View file

@ -0,0 +1,85 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends Window
class_name ExporterCyclopsWizard
var file_dialog:FileDialog
var save_path:String
var plugin:CyclopsLevelBuilder
# Called when the node enters the scene tree for the first time.
func _ready():
file_dialog = FileDialog.new()
add_child(file_dialog)
file_dialog.size = Vector2(600, 400)
file_dialog.file_mode = FileDialog.FILE_MODE_SAVE_FILE
file_dialog.set_access(FileDialog.ACCESS_RESOURCES)
file_dialog.title = "Save file..."
file_dialog.filters = PackedStringArray(["*.cyclops; Cyclops files"])
file_dialog.current_file = save_path
file_dialog.file_selected.connect(on_save_file)
%lineEdit_path.text = save_path
#_text_path = %lineEdit_path
#_text_path.text = save_path
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func on_save_file(path:String):
save_path = path
%lineEdit_path.text = path
func _on_bn_browse_pressed():
file_dialog.popup_centered()
func _on_bn_cancel_pressed():
hide()
func _on_close_requested():
hide()
func _on_bn_okay_pressed():
var path:String = save_path
if !save_path.to_lower().ends_with(".cyclops"):
path = save_path + ".cyclops"
var cyclops_file_builder:CyclopsFileBuilder = CyclopsFileBuilder.new(plugin)
cyclops_file_builder.build_file()
var text = JSON.stringify(cyclops_file_builder.document, " ", false)
var file:FileAccess = FileAccess.open(path, FileAccess.WRITE)
file.store_string(text)
hide()

View file

@ -0,0 +1,60 @@
[gd_scene load_steps=3 format=3 uid="uid://bxmmf4lvpqtvr"]
[ext_resource type="Script" path="res://addons/cyclops_level_builder/io/exporter/exporter_cyclops_wizard.gd" id="1_107gl"]
[sub_resource type="Theme" id="Theme_5yuos"]
MarginContainer/constants/margin_bottom = 10
MarginContainer/constants/margin_left = 10
MarginContainer/constants/margin_right = 10
MarginContainer/constants/margin_top = 10
[node name="Window" type="Window"]
position = Vector2i(0, 36)
size = Vector2i(600, 100)
script = ExtResource("1_107gl")
[node name="MarginContainer" type="MarginContainer" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = SubResource("Theme_5yuos")
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Path
"
[node name="lineEdit_path" type="LineEdit" parent="MarginContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
[node name="bn_browse" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
tooltip_text = "Browse"
text = "..."
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
[node name="bn_okay" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "Okay"
[node name="bn_cancel" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "Cancel"
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/bn_browse" to="." method="_on_bn_browse_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/bn_okay" to="." method="_on_bn_okay_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/bn_cancel" to="." method="_on_bn_cancel_pressed"]

View file

@ -0,0 +1,167 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends Window
class_name ExporterGltfWizard
#@onready var _text_path:LineEdit = $VBoxContainer/HBoxContainer/text_path
#var _text_path:LineEdit
var file_dialog:FileDialog
var save_path:String
var plugin:CyclopsLevelBuilder
# Called when the node enters the scene tree for the first time.
func _ready():
file_dialog = FileDialog.new()
add_child(file_dialog)
file_dialog.size = Vector2(600, 400)
file_dialog.file_mode = FileDialog.FILE_MODE_SAVE_FILE
file_dialog.set_access(FileDialog.ACCESS_FILESYSTEM)
file_dialog.title = "Export scene..."
file_dialog.filters = PackedStringArray(["*.gltf; glTF files"])
file_dialog.current_file = save_path
file_dialog.file_selected.connect(on_save_file)
# _text_path = $VBoxContainer/HBoxContainer/lineEdit_path
#var hh = get_node("VBoxContainer")
#var children = get_children()
# _text_path = get_node("VBoxContainer/HBoxContainer/lineEdit_path")
%lineEdit_path.text = save_path
#_text_path = %lineEdit_path
#_text_path.text = save_path
func on_save_file(path:String):
save_path = path
%lineEdit_path.text = path
func _on_bn_browse_pressed():
file_dialog.popup_centered()
func branch_is_valid(node:Node)->bool:
if node is CyclopsBlock || (%check_markers.button_pressed && node is Marker3D):
return true
for child in node.get_children():
if child is Node3D and branch_is_valid(child):
return true
return false
func clean_branch(node:Node3D)->Node3D:
if node is CyclopsBlock:
var block:CyclopsBlock = node
var new_mesh_node:MeshInstance3D = block.mesh_instance.duplicate()
new_mesh_node.name = block.mesh_instance.name
var new_node:Node3D = Node3D.new()
new_node.name = node.name
new_node.transform = node.transform
new_node.add_child(new_mesh_node)
return new_node
elif node is Marker3D:
var new_node:Marker3D = node.duplicate()
return new_node
else:
var new_node:Node3D = Node3D.new()
new_node.transform = node.transform
new_node.name = node.name
for child in node.get_children():
if branch_is_valid(child):
new_node.add_child(clean_branch(child))
return new_node
func search_nodes_flat(node:Node, root:Node3D):
# print("searching %s" % node.name)
if node is CyclopsBlock:
#print("exporting block %s" % node.name)
var block:CyclopsBlock = node
var new_mesh_node:MeshInstance3D = block.mesh_instance.duplicate()
new_mesh_node.name = block.name
root.add_child(new_mesh_node)
new_mesh_node.global_transform = block.mesh_instance.global_transform
elif node is Marker3D:
if %check_markers.button_pressed:
var new_node:Marker3D = Marker3D.new()
new_node.name = node.name
root.add_child(new_node)
new_node.global_transform = node.global_transform
for child in node.get_children():
search_nodes_flat(child, root)
func clean_flat(node:Node3D)->Node3D:
#print("clean_flat")
var root:Node3D = Node3D.new()
root.name = "CyclopsScene"
for child in node.get_children():
#print("rpt chjild %s" % child.name)
search_nodes_flat(child, root)
return root
func _on_bn_okay_pressed():
var path:String = save_path
if !save_path.to_lower().ends_with(".gltf") && !save_path.to_lower().ends_with(".glb"):
path = save_path + ".gltf"
var doc:GLTFDocument = GLTFDocument.new()
var state:GLTFState = GLTFState.new()
var root:Node = plugin.get_editor_interface().get_edited_scene_root()
var root_clean:Node3D = clean_flat(root) if %check_flatten.button_pressed else clean_branch(root)
doc.append_from_scene(root_clean, state)
doc.write_to_filesystem(state, path)
hide()
func _on_bn_cancel_pressed():
hide()
func _on_close_requested():
hide()

View file

@ -0,0 +1,75 @@
[gd_scene load_steps=3 format=3 uid="uid://ct2mftn2hge7k"]
[ext_resource type="Script" path="res://addons/cyclops_level_builder/io/exporter/exporter_gltf_wizard.gd" id="1_asb2l"]
[sub_resource type="Theme" id="Theme_pvimd"]
MarginContainer/constants/margin_bottom = 10
MarginContainer/constants/margin_left = 10
MarginContainer/constants/margin_right = 10
MarginContainer/constants/margin_top = 10
[node name="Window" type="Window"]
title = "Gltf Wizard"
position = Vector2i(0, 36)
size = Vector2i(400, 150)
script = ExtResource("1_asb2l")
[node name="MarginContainer" type="MarginContainer" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = SubResource("Theme_pvimd")
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
[node name="check_flatten" type="CheckBox" parent="MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "If unchecked, the scene heierarchy will be refelected in the exported nodes. Otherwise all nodes will be children of the root."
button_pressed = true
text = "Flatten"
[node name="check_markers" type="CheckBox" parent="MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Include Marker3Ds in export."
button_pressed = true
text = "Markers"
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Path
"
[node name="lineEdit_path" type="LineEdit" parent="MarginContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
[node name="bn_browse" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
tooltip_text = "Browse"
text = "..."
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
[node name="bn_okay" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "Okay"
[node name="bn_cancel" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "Cancel"
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/bn_browse" to="." method="_on_bn_browse_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/bn_okay" to="." method="_on_bn_okay_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/bn_cancel" to="." method="_on_bn_cancel_pressed"]

View file

@ -0,0 +1,155 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends Window
class_name ExporterGodotSceneWizard
#var _text_path:LineEdit
var default_material:Material = preload("res://addons/cyclops_level_builder/materials/grid.tres")
var file_dialog:FileDialog
var save_path:String
var plugin:CyclopsLevelBuilder
# Called when the node enters the scene tree for the first time.
func _ready():
file_dialog = FileDialog.new()
add_child(file_dialog)
file_dialog.size = Vector2(600, 400)
file_dialog.file_mode = FileDialog.FILE_MODE_SAVE_FILE
file_dialog.set_access(FileDialog.ACCESS_RESOURCES)
file_dialog.title = "Export scene..."
file_dialog.filters = PackedStringArray(["*.tscn; tscn files"])
file_dialog.current_file = save_path
file_dialog.file_selected.connect(on_save_file)
%lineEdit_path.text = save_path
#_text_path = %lineEdit_path
#_text_path.text = save_path
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func on_save_file(path:String):
save_path = path
%lineEdit_path.text = path
func _on_bn_browse_pressed():
file_dialog.popup_centered()
func _on_bn_cancel_pressed():
hide()
func _on_close_requested():
hide()
func _on_bn_okay_pressed():
var path:String = save_path
if !save_path.to_lower().ends_with(".tscn") && !save_path.to_lower().ends_with(".tscn"):
path = save_path + ".tscn"
var root:Node = plugin.get_editor_interface().get_edited_scene_root()
#var dup_node:Node = copy_scene_recursive(root)
var dup_node:Node = root.duplicate()
await get_tree().process_frame
replace_blocks_recursive(dup_node, dup_node)
#dup_node.name = "aaaaaaa"
var dup_scene:PackedScene = PackedScene.new()
dup_scene.pack(dup_node)
ResourceSaver.save(dup_scene, path)
hide()
func replace_blocks_recursive(node:Node, root:Node):
for child in node.get_children():
#print("child.name ", child.name)
if child is CyclopsBlock:
var child_block:CyclopsBlock = child
var new_child:Node3D = Node3D.new()
child.add_sibling(new_child)
new_child.owner = root
new_child.transform = child_block.transform
new_child.set_display_folded(true)
#Mesh
var vol:ConvexVolume = ConvexVolume.new()
vol.init_from_mesh_vector_data(child_block.mesh_vector_data)
var mesh:ArrayMesh = vol.create_mesh(child_block.materials, default_material)
var mesh_instance:MeshInstance3D = MeshInstance3D.new()
new_child.add_child(mesh_instance)
mesh_instance.owner = root
mesh_instance.mesh = mesh
mesh_instance.name = "mesh_instance"
#Collision
var collision_body:PhysicsBody3D
match child_block.collision_type:
Collision.Type.STATIC:
collision_body = StaticBody3D.new()
Collision.Type.KINEMATIC:
collision_body = CharacterBody3D.new()
Collision.Type.RIGID:
collision_body = RigidBody3D.new()
if collision_body:
collision_body.collision_layer = child_block.collision_layer
collision_body.collision_mask = child_block.collision_mask
new_child.add_child(collision_body)
collision_body.owner = root
collision_body.name = "collision_body"
var collision_shape:CollisionShape3D = CollisionShape3D.new()
collision_body.add_child(collision_shape)
collision_shape.owner = root
var shape:ConvexPolygonShape3D = ConvexPolygonShape3D.new()
shape.points = vol.get_points()
collision_shape.shape = shape
collision_shape.name = "collision_shape"
var child_name:String = child.name
node.remove_child(child)
child.queue_free()
new_child.name = child_name
else:
replace_blocks_recursive(child, root)

View file

@ -0,0 +1,61 @@
[gd_scene load_steps=3 format=3 uid="uid://bqmvfbarjmc7c"]
[ext_resource type="Script" path="res://addons/cyclops_level_builder/io/exporter/exporter_godot_scene_wizard.gd" id="1_khuso"]
[sub_resource type="Theme" id="Theme_3em6s"]
MarginContainer/constants/margin_bottom = 10
MarginContainer/constants/margin_left = 10
MarginContainer/constants/margin_right = 10
MarginContainer/constants/margin_top = 10
[node name="Window" type="Window"]
title = "Export as Scene"
position = Vector2i(0, 36)
size = Vector2i(600, 100)
script = ExtResource("1_khuso")
[node name="MarginContainer" type="MarginContainer" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = SubResource("Theme_3em6s")
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Path
"
[node name="lineEdit_path" type="LineEdit" parent="MarginContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
[node name="bn_browse" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
tooltip_text = "Browse"
text = "..."
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
[node name="bn_okay" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "Okay"
[node name="bn_cancel" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "Cancel"
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/bn_browse" to="." method="_on_bn_browse_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/bn_okay" to="." method="_on_bn_okay_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/bn_cancel" to="." method="_on_bn_cancel_pressed"]