Skip to content

Commit

Permalink
Merge pull request #11 from Steveplays28/picture-in-picture
Browse files Browse the repository at this point in the history
Picture in picture
  • Loading branch information
Steveplays28 authored Jun 10, 2022
2 parents 80236ef + e569120 commit 1cec3bf
Show file tree
Hide file tree
Showing 97 changed files with 6,882 additions and 92 deletions.
7 changes: 7 additions & 0 deletions addons/change_node/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="Change node"
description="Changes a node to an instance of a scene, while keeping position, rotation, and scale."
author="Steveplays28"
version="1.0"
script="plugin.gd"
68 changes: 68 additions & 0 deletions addons/change_node/plugin.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
tool
extends EditorPlugin

var changed_node_paths:Array = []
var removed_nodes:Dictionary = {}

func _enter_tree():
add_tool_menu_item("Change nodes", self, "show_file_dialog")

func _exit_tree():
remove_tool_menu_item("Change nodes")

func show_file_dialog(args):
var nodes = get_editor_interface().get_selection().get_selected_nodes()
if nodes.size() <= 0:
return

var file_dialog:FileDialog = FileDialog.new()
file_dialog.connect("file_selected", self, "file_dialog_file_selected")
file_dialog.mode = FileDialog.MODE_OPEN_FILE
file_dialog.access = FileDialog.ACCESS_RESOURCES
file_dialog.filters = PoolStringArray(["*.tscn, *.scn ; Scene files","*.res ; Resource files"])

add_child(file_dialog)
file_dialog.popup_centered(OS.get_window_safe_area().size / 2)

func file_dialog_file_selected(path:String):
changed_node_paths.append(path)

var undo_redo:UndoRedo = get_undo_redo()
undo_redo.create_action("Change nodes")
undo_redo.add_do_method(self, "do_change_nodes")
undo_redo.add_undo_method(self, "undo_change_nodes")
undo_redo.commit_action()

func do_change_nodes():
var selected_nodes = get_editor_interface().get_selection().get_selected_nodes()

var new_node_path:String = changed_node_paths[changed_node_paths.size() - 1]
var loaded_node = load(new_node_path)
var instanced_node = loaded_node.instance()

for selected_node in selected_nodes:
if (selected_node is Spatial && instanced_node is Spatial):
var selected_spatial:Spatial = selected_node as Spatial

var copied_translation:Vector3 = selected_spatial.transform.origin
var copied_rotation_degrees:Vector3 = selected_node.rotation_degrees
var copied_scale:Vector3 = selected_node.scale

selected_node.get_parent().add_child(instanced_node)
instanced_node.owner = selected_node.get_parent()

var new_spatial:Spatial = instanced_node as Spatial
new_spatial.get_parent().move_child(new_spatial, selected_spatial.get_index())
new_spatial.transform.origin = copied_translation
new_spatial.rotation_degrees = copied_rotation_degrees
new_spatial.scale = copied_scale

removed_nodes[selected_node] = selected_node.get_parent()
selected_node.get_parent().remove_child(selected_node)

func undo_change_nodes():
if removed_nodes.size() > 0:
var last_removed_node:Node = removed_nodes.keys()[removed_nodes.size() - 1]
removed_nodes[last_removed_node].add_child(last_removed_node)
last_removed_node.owner = last_removed_node.get_parent()
removed_nodes.erase(last_removed_node)
17 changes: 10 additions & 7 deletions main_environment.tres
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
[gd_resource type="Environment" load_steps=2 format=2]
[gd_resource type="Environment" load_steps=3 format=2]

[sub_resource type="ProceduralSky" id=1]
sky_top_color = Color( 0.211765, 0.313726, 0.552941, 1 )
sky_horizon_color = Color( 0.545098, 0.686275, 0.811765, 1 )
sky_curve = 0.13
sun_latitude = 45.0
[ext_resource path="res://resources/skyboxes/Epic_BlueSunset_EquiRect_flat.png" type="Texture" id=1]

[sub_resource type="PanoramaSky" id=1]
panorama = ExtResource( 1 )

[resource]
resource_local_to_scene = true
background_mode = 2
background_sky = SubResource( 1 )
background_sky_orientation = Basis( -1, 0, -1.50996e-07, 0, 1, 0, 1.50996e-07, 0, -1 )
ambient_light_color = Color( 1, 1, 1, 1 )
tonemap_mode = 3
glow_bloom = 0.25
ssao_enabled = true
glow_enabled = true
glow_blend_mode = 0
glow_bicubic_upscale = true
24 changes: 24 additions & 0 deletions prefabs/brick_wall1.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://resources/materials/brick.material" type="Material" id=2]

[sub_resource type="ArrayMesh" id=1]
resource_name = "brick_wall1_Cube"
surfaces/0 = {
"aabb": AABB( -1, -1, -1, 2.00001, 2.00001, 2 ),
"array_data": PoolByteArray( 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 191, 127, 127, 129, 63, 146, 36, 146, 36, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 191, 0, 127, 129, 63, 121, 57, 210, 58, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 191, 127, 0, 127, 127, 70, 56, 158, 53, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 191, 0, 129, 127, 63, 48, 57, 209, 58, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 191, 127, 127, 129, 63, 146, 36, 12, 53, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 191, 127, 0, 127, 127, 70, 56, 48, 57, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 127, 63, 12, 53, 121, 57, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 127, 129, 63, 121, 57, 130, 58, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 127, 0, 127, 127, 115, 55, 158, 53, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 63, 0, 129, 127, 63, 48, 57, 132, 58, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 127, 63, 12, 53, 219, 59, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 63, 127, 0, 127, 127, 115, 55, 48, 57, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 191, 129, 0, 0, 63, 211, 47, 158, 53, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 191, 127, 127, 129, 63, 12, 53, 146, 36, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 191, 0, 127, 129, 63, 219, 59, 210, 58, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 191, 129, 0, 0, 63, 211, 47, 48, 57, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 191, 0, 129, 127, 63, 158, 53, 209, 58, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 191, 127, 127, 129, 63, 12, 53, 12, 53, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 63, 129, 0, 0, 63, 192, 50, 158, 53, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 127, 63, 146, 36, 121, 57, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 63, 0, 127, 129, 63, 219, 59, 130, 58, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 63, 129, 0, 0, 63, 192, 50, 48, 57, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 63, 0, 129, 127, 63, 158, 53, 132, 58, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 127, 63, 146, 36, 219, 59 ),
"array_index_data": PoolByteArray( 1, 0, 20, 0, 14, 0, 1, 0, 7, 0, 20, 0, 10, 0, 19, 0, 6, 0, 10, 0, 23, 0, 19, 0, 21, 0, 12, 0, 18, 0, 21, 0, 15, 0, 12, 0, 16, 0, 9, 0, 3, 0, 16, 0, 22, 0, 9, 0, 5, 0, 8, 0, 2, 0, 5, 0, 11, 0, 8, 0, 17, 0, 0, 0, 13, 0, 17, 0, 4, 0, 0, 0 ),
"blend_shape_data": [ ],
"format": 2194711,
"index_count": 36,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 24
}

[node name="BrickWall1" type="Spatial"]

[node name="Cube" type="MeshInstance" parent="."]
transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 1, 0, 10, 0 )
mesh = SubResource( 1 )
material/0 = ExtResource( 2 )
94 changes: 94 additions & 0 deletions prefabs/cctv_camera1.tscn

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions prefabs/concrete_floor.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://resources/materials/concrete.material" type="Material" id=1]

[sub_resource type="BoxShape" id=12]

[sub_resource type="CubeMesh" id=13]

[node name="ConcreteFloor1" type="StaticBody"]

[node name="CollisionShape" type="CollisionShape" parent="."]
shape = SubResource( 12 )

[node name="MeshInstance" type="MeshInstance" parent="CollisionShape"]
mesh = SubResource( 13 )
skeleton = NodePath("../../../Floor2")
material/0 = ExtResource( 1 )
24 changes: 24 additions & 0 deletions prefabs/glass_wall1.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://resources/materials/glass.material" type="Material" id=1]

[sub_resource type="ArrayMesh" id=1]
resource_name = "brick_wall1_Cube"
surfaces/0 = {
"aabb": AABB( -1, -1, -1, 2.00001, 2.00001, 2 ),
"array_data": PoolByteArray( 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 191, 127, 127, 129, 63, 146, 36, 146, 36, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 191, 0, 127, 129, 63, 121, 57, 210, 58, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 191, 127, 0, 127, 127, 70, 56, 158, 53, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 191, 0, 129, 127, 63, 48, 57, 209, 58, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 191, 127, 127, 129, 63, 146, 36, 12, 53, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 191, 127, 0, 127, 127, 70, 56, 48, 57, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 127, 63, 12, 53, 121, 57, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 127, 129, 63, 121, 57, 130, 58, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 127, 0, 127, 127, 115, 55, 158, 53, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 63, 0, 129, 127, 63, 48, 57, 132, 58, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 127, 63, 12, 53, 219, 59, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 63, 127, 0, 127, 127, 115, 55, 48, 57, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 191, 129, 0, 0, 63, 211, 47, 158, 53, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 191, 127, 127, 129, 63, 12, 53, 146, 36, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 191, 0, 127, 129, 63, 219, 59, 210, 58, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 191, 129, 0, 0, 63, 211, 47, 48, 57, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 191, 0, 129, 127, 63, 158, 53, 209, 58, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 191, 127, 127, 129, 63, 12, 53, 12, 53, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 63, 129, 0, 0, 63, 192, 50, 158, 53, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 127, 63, 146, 36, 121, 57, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 128, 63, 0, 127, 129, 63, 219, 59, 130, 58, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 63, 129, 0, 0, 63, 192, 50, 48, 57, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 63, 0, 129, 127, 63, 158, 53, 132, 58, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 127, 63, 146, 36, 219, 59 ),
"array_index_data": PoolByteArray( 1, 0, 20, 0, 14, 0, 1, 0, 7, 0, 20, 0, 10, 0, 19, 0, 6, 0, 10, 0, 23, 0, 19, 0, 21, 0, 12, 0, 18, 0, 21, 0, 15, 0, 12, 0, 16, 0, 9, 0, 3, 0, 16, 0, 22, 0, 9, 0, 5, 0, 8, 0, 2, 0, 5, 0, 11, 0, 8, 0, 17, 0, 0, 0, 13, 0, 17, 0, 4, 0, 0, 0 ),
"blend_shape_data": [ ],
"format": 2194711,
"index_count": 36,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 24
}

[node name="GlassWall1" type="Spatial"]

[node name="Cube" type="MeshInstance" parent="."]
transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 1, 0, 10, 0 )
mesh = SubResource( 1 )
material/0 = ExtResource( 1 )
32 changes: 1 addition & 31 deletions prefabs/gun1.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=2]
[gd_scene load_steps=15 format=2]

[ext_resource path="res://resources/models/gun1/gun1.glb" type="PackedScene" id=1]
[ext_resource path="res://scripts/Weapon.cs" type="Script" id=2]
Expand Down Expand Up @@ -31,26 +31,6 @@ vertex_color_use_as_albedo = true
material = SubResource( 15 )
size = Vector2( 2, 2 )

[sub_resource type="SpatialMaterial" id=36]
flags_transparent = true
vertex_color_use_as_albedo = true

[sub_resource type="Gradient" id=34]
offsets = PoolRealArray( 0, 0.35, 0.5, 0.75, 1 )
colors = PoolColorArray( 0, 0, 0, 1, 0, 0, 0, 1, 0.0980392, 0.0980392, 0.0980392, 1, 0.196078, 0.196078, 0.196078, 1, 1, 1, 1, 0 )

[sub_resource type="GradientTexture" id=35]
gradient = SubResource( 34 )

[sub_resource type="ParticlesMaterial" id=32]
gravity = Vector3( 0, 1, 0 )
scale = 0.1
color_ramp = SubResource( 35 )

[sub_resource type="SphereMesh" id=33]
radius = 0.5
height = 1.0

[sub_resource type="AnimationNodeTimeScale" id=30]

[sub_resource type="AnimationNodeAnimation" id=22]
Expand Down Expand Up @@ -93,16 +73,6 @@ visibility_aabb = AABB( -7.5, -7.5, -7.5, 15, 15, 15 )
process_material = SubResource( 25 )
draw_pass_1 = SubResource( 26 )

[node name="SmokeTrail" type="Particles" parent="Muzzle" index="1"]
material_override = SubResource( 36 )
emitting = false
amount = 50
lifetime = 1.5
one_shot = true
local_coords = false
process_material = SubResource( 32 )
draw_pass_1 = SubResource( 33 )

[node name="AnimationTree" type="AnimationTree" parent="." index="4"]
tree_root = SubResource( 29 )
anim_player = NodePath("../AnimationPlayer")
Expand Down
16 changes: 16 additions & 0 deletions prefabs/level_prototyping/prototype_cube.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://resources/materials/purple.tres" type="Material" id=1]

[sub_resource type="BoxShape" id=12]

[sub_resource type="CubeMesh" id=13]

[node name="PrototypeCube1" type="StaticBody"]

[node name="CollisionShape" type="CollisionShape" parent="."]
shape = SubResource( 12 )

[node name="MeshInstance" type="MeshInstance" parent="CollisionShape"]
mesh = SubResource( 13 )
material/0 = ExtResource( 1 )
5 changes: 5 additions & 0 deletions prefabs/metal_plating1.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://resources/models/metal_plating1/metal_plating1.glb" type="PackedScene" id=1]

[node name="MetalPlating1" instance=ExtResource( 1 )]
47 changes: 47 additions & 0 deletions prefabs/player.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[gd_scene load_steps=7 format=2]

[ext_resource path="res://resources/materials/physics/zero_friction.tres" type="PhysicsMaterial" id=1]
[ext_resource path="res://prefabs/gun1.tscn" type="PackedScene" id=2]
[ext_resource path="res://scripts/PlayerController.cs" type="Script" id=4]
[ext_resource path="res://resources/materials/white.tres" type="Material" id=5]

[sub_resource type="BoxShape" id=2]
extents = Vector3( 1, 2, 1 )

[sub_resource type="CubeMesh" id=3]

[node name="Player" type="RigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0 )
mass = 80.0
physics_material_override = ExtResource( 1 )
gravity_scale = 1.5
continuous_cd = true
contacts_reported = 1
contact_monitor = true
can_sleep = false
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
linear_damp = 0.0
script = ExtResource( 4 )
sensitivity = Vector2( 0.12, 0.12 )
accelerationMultiplier = 10.0
deccelerationMultiplier = 0.5

[node name="CollisionShape" type="CollisionShape" parent="."]
shape = SubResource( 2 )

[node name="MeshInstance" type="MeshInstance" parent="CollisionShape"]
transform = Transform( 1, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0 )
mesh = SubResource( 3 )
material/0 = ExtResource( 5 )

[node name="Camera" type="Camera" parent="CollisionShape"]
fov = 90.0

[node name="Gun1" parent="CollisionShape/Camera" instance=ExtResource( 2 )]
transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 1.5, -0.5, 0.5 )
PlayerNodePath = NodePath("../../..")
CameraNodePath = NodePath("..")
HorizontalRotationNodePath = NodePath("../..")
AimDownSightPosition = Vector3( 0, -0.4, -0.5 )
5 changes: 5 additions & 0 deletions prefabs/steel_beam1.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://resources/models/steel_beam1/steel_beam1.glb" type="PackedScene" id=1]

[node name="SteelBeam1" instance=ExtResource( 1 )]
9 changes: 9 additions & 0 deletions prefabs/window1.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://resources/models/window1/window1.glb" type="PackedScene" id=1]
[ext_resource path="res://resources/materials/glass.material" type="Material" id=2]

[node name="Window1" instance=ExtResource( 1 )]

[node name="Glass" parent="." index="1"]
material/0 = ExtResource( 2 )
4 changes: 4 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ settings/fps/force_fps=120

window/vsync/vsync_via_compositor=true

[editor_plugins]

enabled=PoolStringArray( "res://addons/change_node/plugin.cfg" )

[input]

escape={
Expand Down
Binary file added resources/materials/brick.material
Binary file not shown.
Binary file added resources/materials/cctv_camera1.material
Binary file not shown.
Binary file added resources/materials/concrete.material
Binary file not shown.
Binary file added resources/materials/glass.material
Binary file not shown.
Binary file added resources/materials/iron.material
Binary file not shown.
5 changes: 5 additions & 0 deletions resources/materials/purple.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[gd_resource type="SpatialMaterial" format=2]

[resource]
albedo_color = Color( 0.392157, 0.392157, 1, 1 )
roughness = 0.5
Binary file added resources/materials/steel.material
Binary file not shown.
Binary file added resources/models/brick_wall1/brick_wall1.glb
Binary file not shown.
Loading

0 comments on commit 1cec3bf

Please sign in to comment.