Adds missing data
This commit is contained in:
parent
e6391d9fdd
commit
53cdcc3433
620 changed files with 47293 additions and 151 deletions
138
addons/cyclops_level_builder/actions/action_convert_to_mesh.gd
Normal file
138
addons/cyclops_level_builder/actions/action_convert_to_mesh.gd
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
# 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
|
||||
class_name ActionConvertToMesh
|
||||
extends CyclopsAction
|
||||
|
||||
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Convert To Godot Mesh")
|
||||
|
||||
func _execute():
|
||||
var root:Node = plugin.get_editor_interface().get_edited_scene_root()
|
||||
|
||||
#var ed_sel:EditorSelection = plugin.get_editor_interface().get_selection()
|
||||
#var sel_nodes:Array[Node] = ed_sel.get_selected_nodes()
|
||||
#
|
||||
#if sel_nodes.is_empty():
|
||||
#return
|
||||
|
||||
#var branch_to_clone:Node = sel_nodes[0]
|
||||
#var root = branch_to_clone.get_parent()
|
||||
|
||||
var converted_branch:Node3D = clone_branch(root)
|
||||
converted_branch.name = GeneralUtil.find_unique_name(root, "converted_blocks")
|
||||
root.add_child(converted_branch)
|
||||
|
||||
set_owner_recursive(converted_branch, plugin.get_editor_interface().get_edited_scene_root())
|
||||
|
||||
pass
|
||||
|
||||
func set_owner_recursive(node:Node3D, new_owner):
|
||||
node.owner = new_owner
|
||||
for child in node.get_children():
|
||||
if child is Node3D:
|
||||
set_owner_recursive(child, new_owner)
|
||||
|
||||
func clone_branch(node:Node3D)->Node3D:
|
||||
if node is CyclopsBlock:
|
||||
var block:CyclopsBlock = node
|
||||
var name_root:String = block.name
|
||||
|
||||
var new_node:Node3D = Node3D.new()
|
||||
new_node.name = name_root
|
||||
new_node.transform = node.transform
|
||||
new_node.set_meta("_edit_group_", true)
|
||||
# new_node.owner = plugin.get_editor_interface().get_edited_scene_root()
|
||||
|
||||
var new_mesh_node:MeshInstance3D = block.mesh_instance.duplicate()
|
||||
new_mesh_node.name = name_root + "_mesh"
|
||||
# new_mesh_node.owner = plugin.get_editor_interface().get_edited_scene_root()
|
||||
new_node.add_child(new_mesh_node)
|
||||
|
||||
|
||||
var vol:ConvexVolume = ConvexVolume.new()
|
||||
vol.init_from_convex_block_data(block.block_data)
|
||||
|
||||
|
||||
var collision_body:PhysicsBody3D
|
||||
|
||||
match 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.owner = plugin.get_editor_interface().get_edited_scene_root()
|
||||
collision_body.name = name_root + "_col"
|
||||
collision_body.collision_layer = block.collision_layer
|
||||
collision_body.collision_mask = block.collision_mask
|
||||
new_node.add_child(collision_body)
|
||||
|
||||
var collision_shape:CollisionShape3D = CollisionShape3D.new()
|
||||
# collision_shape.owner = plugin.get_editor_interface().get_edited_scene_root()
|
||||
collision_body.add_child(collision_shape)
|
||||
collision_shape.name = name_root + "_col_shp"
|
||||
|
||||
var shape:ConvexPolygonShape3D = ConvexPolygonShape3D.new()
|
||||
shape.points = vol.get_points()
|
||||
collision_shape.shape = shape
|
||||
|
||||
#var occluder:OccluderInstance3D = OccluderInstance3D.new()
|
||||
#occluder.name = name_root + "_occ"
|
||||
## occluder.owner = plugin.get_editor_interface().get_edited_scene_root()
|
||||
#new_node.add_child(occluder)
|
||||
#
|
||||
#var occluder_object:ArrayOccluder3D = ArrayOccluder3D.new()
|
||||
#occluder.name = name_root + "_occ"
|
||||
#occluder_object.vertices = vol.get_points()
|
||||
#occluder_object.indices = vol.get_trimesh_indices()
|
||||
#occluder.occluder = occluder_object
|
||||
|
||||
return new_node
|
||||
|
||||
else:
|
||||
var new_node:Node3D = Node3D.new()
|
||||
# new_node.owner = plugin.get_editor_interface().get_edited_scene_root()
|
||||
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(clone_branch(child))
|
||||
return new_node
|
||||
|
||||
func branch_is_valid(node:Node)->bool:
|
||||
if node is CyclopsBlock:
|
||||
return true
|
||||
|
||||
for child in node.get_children():
|
||||
if child is Node3D and branch_is_valid(child):
|
||||
return true
|
||||
|
||||
return false
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# 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
|
||||
class_name ActionDeleteSelectedBlocks
|
||||
extends CyclopsAction
|
||||
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Delete Selected Blocks")
|
||||
|
||||
func _execute():
|
||||
var blocks:Array[CyclopsBlock] = plugin.get_selected_blocks()
|
||||
if blocks.is_empty():
|
||||
return
|
||||
|
||||
var cmd:CommandDeleteBlocks = CommandDeleteBlocks.new()
|
||||
cmd.builder = plugin
|
||||
|
||||
for block in blocks:
|
||||
cmd.block_paths.append(block.get_path())
|
||||
|
||||
|
||||
var undo:EditorUndoRedoManager = plugin.get_undo_redo()
|
||||
cmd.add_to_undo_manager(undo)
|
||||
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
# 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
|
||||
class_name ActionDuplicateSelectedBlocks
|
||||
extends CyclopsAction
|
||||
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Duplicate Selected Blocks")
|
||||
|
||||
func _execute():
|
||||
var blocks:Array[CyclopsBlock] = plugin.get_selected_blocks()
|
||||
if blocks.is_empty():
|
||||
return
|
||||
|
||||
var cmd:CommandDuplicateBlocks = CommandDuplicateBlocks.new()
|
||||
cmd.builder = plugin
|
||||
|
||||
for block in blocks:
|
||||
cmd.blocks_to_duplicate.append(block.get_path())
|
||||
|
||||
|
||||
var undo:EditorUndoRedoManager = plugin.get_undo_redo()
|
||||
cmd.add_to_undo_manager(undo)
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
# 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
|
||||
class_name ActionIntersectBlock
|
||||
extends CyclopsAction
|
||||
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Intersect Blocks")
|
||||
|
||||
func _execute():
|
||||
var blocks:Array[CyclopsBlock] = plugin.get_selected_blocks()
|
||||
if blocks.size() < 2:
|
||||
plugin.log("Not enough objects selected")
|
||||
return
|
||||
|
||||
var active:CyclopsBlock = plugin.get_active_block()
|
||||
if !active:
|
||||
plugin.log("No active object selected")
|
||||
return
|
||||
|
||||
var cmd:CommandIntersectBlock = CommandIntersectBlock.new()
|
||||
cmd.builder = plugin
|
||||
|
||||
for block in blocks:
|
||||
if plugin.is_active_block(block):
|
||||
cmd.main_block_path = block.get_path()
|
||||
else:
|
||||
cmd.block_paths.append(block.get_path())
|
||||
|
||||
if cmd.main_block_path.is_empty():
|
||||
return
|
||||
|
||||
if cmd.will_change_anything():
|
||||
var undo:EditorUndoRedoManager = plugin.get_undo_redo()
|
||||
cmd.add_to_undo_manager(undo)
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
# 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
|
||||
class_name ActionMergeSelectedBlocks
|
||||
extends CyclopsAction
|
||||
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Merge Selected Blocks")
|
||||
|
||||
func _execute():
|
||||
var blocks:Array[CyclopsBlock] = plugin.get_selected_blocks()
|
||||
if blocks.is_empty():
|
||||
return
|
||||
|
||||
var cmd:CommandMergeBlocks = CommandMergeBlocks.new()
|
||||
cmd.builder = plugin
|
||||
|
||||
for block in blocks:
|
||||
cmd.block_paths.append(block.get_path())
|
||||
|
||||
|
||||
var undo:EditorUndoRedoManager = plugin.get_undo_redo()
|
||||
cmd.add_to_undo_manager(undo)
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
# 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
|
||||
class_name ActionMergeVerticesCenter
|
||||
extends CyclopsAction
|
||||
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Merge Vertices Center")
|
||||
|
||||
func _execute():
|
||||
var blocks:Array[CyclopsBlock] = plugin.get_selected_blocks()
|
||||
if blocks.is_empty():
|
||||
return
|
||||
|
||||
var cmd:CommandMergeVertices = CommandMergeVertices.new()
|
||||
cmd.builder = plugin
|
||||
|
||||
for block in blocks:
|
||||
var sel_vec:DataVector = block.mesh_vector_data.get_vertex_data(MeshVectorData.V_SELECTED)
|
||||
|
||||
if sel_vec.size() < 2:
|
||||
continue
|
||||
|
||||
var indices:Array[int]
|
||||
#print("sel vert bytes ", block.block_data.vertex_selected)
|
||||
for idx in sel_vec.size():
|
||||
if sel_vec.get_value(idx):
|
||||
indices.append(idx)
|
||||
cmd.add_vertices(block.get_path(), indices)
|
||||
|
||||
|
||||
if cmd.will_change_anything():
|
||||
var undo:EditorUndoRedoManager = plugin.get_undo_redo()
|
||||
cmd.add_to_undo_manager(undo)
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# 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
|
||||
class_name ActionMirrorSelectionX2
|
||||
extends ActionScaleSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Mirror Selection X")
|
||||
scale = Vector3(-1, 1, 1)
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# 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
|
||||
class_name ActionMirrorSelectionY2
|
||||
extends ActionScaleSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Mirror Selection Y")
|
||||
scale = Vector3(1, -1, 1)
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# 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
|
||||
class_name ActionMirrorSelectionZ
|
||||
extends ActionScaleSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Mirror Selection Z")
|
||||
scale = Vector3(1, 1, -1)
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
# 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
|
||||
class_name ActionRotateSelection
|
||||
extends CyclopsAction
|
||||
|
||||
var rotation_axis:Vector3 = Vector3.ONE
|
||||
var rotation_angle:float
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, name, accellerator)
|
||||
|
||||
func _execute():
|
||||
var blocks:Array[CyclopsBlock] = plugin.get_selected_blocks()
|
||||
if blocks.is_empty():
|
||||
return
|
||||
|
||||
var pivot:Vector3 = calc_pivot_of_blocks(blocks)
|
||||
|
||||
var cmd:CommandTransformVertices = CommandTransformVertices.new()
|
||||
cmd.builder = plugin
|
||||
|
||||
for block in blocks:
|
||||
cmd.add_block(block.get_path())
|
||||
|
||||
var xform:Transform3D = Transform3D.IDENTITY
|
||||
xform = xform.translated_local(pivot)
|
||||
xform = xform.rotated_local(rotation_axis, rotation_angle)
|
||||
xform = xform.translated_local(-pivot)
|
||||
cmd.transform = xform
|
||||
#print("cform %s" % xform)
|
||||
|
||||
var undo:EditorUndoRedoManager = plugin.get_undo_redo()
|
||||
cmd.add_to_undo_manager(undo)
|
||||
31
addons/cyclops_level_builder/actions/action_rotate_x_180.gd
Normal file
31
addons/cyclops_level_builder/actions/action_rotate_x_180.gd
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# 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
|
||||
class_name ActionRotateX180
|
||||
extends ActionRotateSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Rotate 180 X")
|
||||
rotation_axis = Vector3(1, 0, 0)
|
||||
rotation_angle = deg_to_rad(180)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# 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
|
||||
class_name ActionRotateX90Ccw
|
||||
extends ActionRotateSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Rotate 90 Ccw X")
|
||||
rotation_axis = Vector3(1, 0, 0)
|
||||
rotation_angle = deg_to_rad(90)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# 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
|
||||
class_name ActionRotateX90Cw
|
||||
extends ActionRotateSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Rotate 90 Cw X")
|
||||
rotation_axis = Vector3(1, 0, 0)
|
||||
rotation_angle = deg_to_rad(-90)
|
||||
31
addons/cyclops_level_builder/actions/action_rotate_y_180.gd
Normal file
31
addons/cyclops_level_builder/actions/action_rotate_y_180.gd
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# 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
|
||||
class_name ActionRotateY180
|
||||
extends ActionRotateSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Rotate 180 Y")
|
||||
rotation_axis = Vector3(0, 1, 0)
|
||||
rotation_angle = deg_to_rad(180)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# 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
|
||||
class_name ActionRotateY90Ccw
|
||||
extends ActionRotateSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Rotate 90 Ccw Y")
|
||||
rotation_axis = Vector3(0, 1, 0)
|
||||
rotation_angle = deg_to_rad(90)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# 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
|
||||
class_name ActionRotateY90Cw
|
||||
extends ActionRotateSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Rotate 90 Cw Y")
|
||||
rotation_axis = Vector3(0, 1, 0)
|
||||
rotation_angle = deg_to_rad(-90)
|
||||
31
addons/cyclops_level_builder/actions/action_rotate_z_180.gd
Normal file
31
addons/cyclops_level_builder/actions/action_rotate_z_180.gd
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# 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
|
||||
class_name ActionRotateZ180
|
||||
extends ActionRotateSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Rotate 180 Z")
|
||||
rotation_axis = Vector3(0, 0, 1)
|
||||
rotation_angle = deg_to_rad(180)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# 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
|
||||
class_name ActionRotateZ90Ccw
|
||||
extends ActionRotateSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Rotate 90 Ccw Z")
|
||||
rotation_axis = Vector3(0, 0, 1)
|
||||
rotation_angle = deg_to_rad(90)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# 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
|
||||
class_name ActionRotateZ90Cw
|
||||
extends ActionRotateSelection
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Rotate 90 Cw Z")
|
||||
rotation_axis = Vector3(0, 0, 1)
|
||||
rotation_angle = deg_to_rad(-90)
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
# 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
|
||||
class_name ActionScaleSelection
|
||||
extends CyclopsAction
|
||||
|
||||
var scale:Vector3 = Vector3.ONE
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, name, accellerator)
|
||||
|
||||
func _execute():
|
||||
var blocks:Array[CyclopsBlock] = plugin.get_selected_blocks()
|
||||
if blocks.is_empty():
|
||||
return
|
||||
|
||||
var pivot:Vector3 = calc_pivot_of_blocks(blocks)
|
||||
|
||||
var cmd:CommandTransformVertices = CommandTransformVertices.new()
|
||||
cmd.builder = plugin
|
||||
|
||||
for block in blocks:
|
||||
cmd.add_block(block.get_path())
|
||||
|
||||
var xform:Transform3D = Transform3D.IDENTITY
|
||||
xform = xform.translated_local(pivot)
|
||||
xform = xform.scaled_local(scale)
|
||||
xform = xform.translated_local(-pivot)
|
||||
cmd.transform = xform
|
||||
#print("cform %s" % xform)
|
||||
|
||||
var undo:EditorUndoRedoManager = plugin.get_undo_redo()
|
||||
cmd.add_to_undo_manager(undo)
|
||||
57
addons/cyclops_level_builder/actions/action_snap_to_grid.gd
Normal file
57
addons/cyclops_level_builder/actions/action_snap_to_grid.gd
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# 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
|
||||
class_name ActionSnapToGrid
|
||||
extends CyclopsAction
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder):
|
||||
super._init(plugin, "Snap to grid")
|
||||
|
||||
|
||||
func _execute():
|
||||
var blocks:Array[CyclopsBlock] = plugin.get_selected_blocks()
|
||||
if blocks.is_empty():
|
||||
return
|
||||
|
||||
var pivot:Vector3 = calc_pivot_of_blocks(blocks)
|
||||
|
||||
var cmd:CommandSnapToGrid = CommandSnapToGrid.new()
|
||||
cmd.builder = plugin
|
||||
|
||||
for block in blocks:
|
||||
cmd.add_block(block.get_path())
|
||||
|
||||
|
||||
#cmd.grid_size = pow(2, plugin.get_global_scene().grid_size)
|
||||
#var snap_to_grid_util:SnapToGridUtil = CyclopsAutoload.calc_snap_to_grid_util()
|
||||
#print("snap_to_grid_util %s" % snap_to_grid_util)
|
||||
#cmd.snap_to_grid_util = snap_to_grid_util
|
||||
|
||||
|
||||
#print("cform %s" % xform)
|
||||
|
||||
var undo:EditorUndoRedoManager = plugin.get_undo_redo()
|
||||
cmd.add_to_undo_manager(undo)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
# 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
|
||||
class_name ActionSubtractBlock
|
||||
extends CyclopsAction
|
||||
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Subtract Block")
|
||||
|
||||
func _execute():
|
||||
var blocks:Array[CyclopsBlock] = plugin.get_selected_blocks()
|
||||
if blocks.size() < 2:
|
||||
plugin.log("Not enough objects selected")
|
||||
return
|
||||
|
||||
var active:CyclopsBlock = plugin.get_active_block()
|
||||
if !active:
|
||||
plugin.log("No active object selected")
|
||||
return
|
||||
|
||||
var cmd:CommandSubtractBlock = CommandSubtractBlock.new()
|
||||
cmd.builder = plugin
|
||||
|
||||
for block in blocks:
|
||||
if plugin.is_active_block(block):
|
||||
cmd.block_to_subtract_path = block.get_path()
|
||||
else:
|
||||
cmd.block_paths.append(block.get_path())
|
||||
|
||||
if cmd.block_to_subtract_path.is_empty():
|
||||
return
|
||||
|
||||
if cmd.will_change_anything():
|
||||
var undo:EditorUndoRedoManager = plugin.get_undo_redo()
|
||||
cmd.add_to_undo_manager(undo)
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
# 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
|
||||
class_name ActionToolDuplicate
|
||||
extends CyclopsAction
|
||||
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Duplicate Selected Blocks")
|
||||
|
||||
func _execute():
|
||||
plugin.switch_to_tool(ToolDuplicate.new())
|
||||
53
addons/cyclops_level_builder/actions/cyclops_action.gd
Normal file
53
addons/cyclops_level_builder/actions/cyclops_action.gd
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# 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
|
||||
class_name CyclopsAction
|
||||
extends RefCounted
|
||||
|
||||
var plugin:CyclopsLevelBuilder
|
||||
|
||||
var name:String = ""
|
||||
var accellerator:Key = KEY_NONE
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
self.plugin = plugin
|
||||
self.name= name
|
||||
self.accellerator = accellerator
|
||||
|
||||
func _execute():
|
||||
pass
|
||||
|
||||
func calc_pivot_of_blocks(blocks:Array[CyclopsBlock])->Vector3:
|
||||
var snap_to_grid_util:SnapToGridUtil = CyclopsAutoload.calc_snap_to_grid_util()
|
||||
|
||||
var bounds:AABB = blocks[0].control_mesh.bounds
|
||||
for idx in range(1, blocks.size()):
|
||||
var block:CyclopsBlock = blocks[idx]
|
||||
bounds = bounds.merge(block.control_mesh.bounds)
|
||||
|
||||
var center:Vector3 = bounds.get_center()
|
||||
center = snap_to_grid_util.snap_point(center)
|
||||
|
||||
return center
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
# 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
|
||||
class_name ActionExportAsCyclops
|
||||
extends CyclopsAction
|
||||
|
||||
var wizard:ExporterCyclopsWizard = preload("res://addons/cyclops_level_builder/io/exporter/exporter_cyclops_wizard.tscn").instantiate()
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Export As Cyclops File...")
|
||||
|
||||
func _execute():
|
||||
if !wizard.get_parent():
|
||||
var base_control:Node = plugin.get_editor_interface().get_base_control()
|
||||
base_control.add_child(wizard)
|
||||
|
||||
wizard.plugin = plugin
|
||||
wizard.popup_centered()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
# 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
|
||||
class_name ActionExportAsGltf
|
||||
extends CyclopsAction
|
||||
|
||||
var wizard:ExporterGltfWizard = preload("res://addons/cyclops_level_builder/io/exporter/exporter_gltf_wizard.tscn").instantiate()
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Export As Gltf...")
|
||||
|
||||
func _execute():
|
||||
if !wizard.get_parent():
|
||||
var base_control:Node = plugin.get_editor_interface().get_base_control()
|
||||
base_control.add_child(wizard)
|
||||
|
||||
wizard.plugin = plugin
|
||||
wizard.popup_centered()
|
||||
|
||||
#await base_control.get_tree().process_frame
|
||||
|
||||
# wizard.popup_hide.connect(func(): wizard.queue_free() )
|
||||
|
||||
#wizard.popup_centered()
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
# 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
|
||||
class_name ActionExportAsGodotScene
|
||||
extends CyclopsAction
|
||||
|
||||
var wizard:ExporterGodotSceneWizard = preload("res://addons/cyclops_level_builder/io/exporter/exporter_godot_scene_wizard.tscn").instantiate()
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Export As Godot Scene...")
|
||||
|
||||
func _execute():
|
||||
if !wizard.get_parent():
|
||||
var base_control:Node = plugin.get_editor_interface().get_base_control()
|
||||
base_control.add_child(wizard)
|
||||
|
||||
wizard.plugin = plugin
|
||||
wizard.popup_centered()
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
# 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
|
||||
class_name ActionImportCyclopsFile
|
||||
extends CyclopsAction
|
||||
|
||||
var wizard:ImporterCyclopsFileWizard = preload("res://addons/cyclops_level_builder/io/importer/importer_cyclops_file_wizard.tscn").instantiate()
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Import Cyclops File...")
|
||||
|
||||
func _execute():
|
||||
if !wizard.get_parent():
|
||||
var base_control:Node = plugin.get_editor_interface().get_base_control()
|
||||
base_control.add_child(wizard)
|
||||
|
||||
wizard.plugin = plugin
|
||||
wizard.popup_centered()
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
# 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
|
||||
class_name ActionImportMeshInstance
|
||||
extends CyclopsAction
|
||||
|
||||
func _init(plugin:CyclopsLevelBuilder, name:String = "", accellerator:Key = KEY_NONE):
|
||||
super._init(plugin, "Import Godot MeshInstance...")
|
||||
|
||||
func _execute():
|
||||
var nodes:Array[Node] = plugin.get_editor_interface().get_selection().get_selected_nodes()
|
||||
|
||||
if nodes.is_empty():
|
||||
return
|
||||
|
||||
if !(nodes[-1] is Node3D):
|
||||
return
|
||||
|
||||
var tgt_parent:Node3D = nodes[-1]
|
||||
if tgt_parent is MeshInstance3D:
|
||||
tgt_parent = tgt_parent.get_parent()
|
||||
|
||||
var cmd:CommandImportGodotMeshes = CommandImportGodotMeshes.new()
|
||||
cmd.builder = plugin
|
||||
cmd.target_parent = tgt_parent.get_path()
|
||||
#print("parent ", tgt_parent.get_path())
|
||||
|
||||
for node in nodes:
|
||||
import_branch_recursive(node, cmd)
|
||||
|
||||
if !cmd.will_change_anything():
|
||||
return
|
||||
|
||||
var undo:EditorUndoRedoManager = plugin.get_undo_redo()
|
||||
cmd.add_to_undo_manager(undo)
|
||||
|
||||
func import_branch_recursive(node:Node3D, cmd:CommandImportGodotMeshes):
|
||||
if node is MeshInstance3D:
|
||||
cmd.source_nodes.append(node.get_path())
|
||||
#print("src ", node.get_path())
|
||||
|
||||
for child in node.get_children():
|
||||
import_branch_recursive(child, cmd)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue