Convert demos to Godot 4 using regular expressions in a script

This commit is contained in:
Aaron Franke
2022-03-26 05:00:50 -05:00
parent 410d783126
commit bbe50fc9da
1095 changed files with 13628 additions and 13557 deletions

View File

@@ -1,13 +1,13 @@
extends Spatial
extends Node3D
func _ready():
# Clear the viewport.
var viewport = $Viewport
$Viewport.set_clear_mode(Viewport.CLEAR_MODE_ONLY_NEXT_FRAME)
var viewport = $SubViewport
$SubViewport.set_clear_mode(SubViewport.CLEAR_MODE_ONLY_NEXT_FRAME)
# Let two frames pass to make sure the vieport is captured.
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_frame")
await get_tree().process_frame
await get_tree().process_frame
# Retrieve the texture and set it to the viewport quad.
$ViewportQuad.material_override.albedo_texture = viewport.get_texture()

View File

@@ -2,118 +2,118 @@
[ext_resource path="res://2D_in_3D.gd" type="Script" id=1]
[ext_resource path="res://pong.gd" type="Script" id=2]
[ext_resource path="res://ball.png" type="Texture" id=3]
[ext_resource path="res://left_pallete.png" type="Texture" id=4]
[ext_resource path="res://right_pallete.png" type="Texture" id=5]
[ext_resource path="res://separator.png" type="Texture" id=6]
[ext_resource path="res://ball.png" type="Texture2D" id=3]
[ext_resource path="res://left_pallete.png" type="Texture2D" id=4]
[ext_resource path="res://right_pallete.png" type="Texture2D" id=5]
[ext_resource path="res://separator.png" type="Texture2D" id=6]
[sub_resource type="PlaneMesh" id=1]
[sub_resource type="SpatialMaterial" id=2]
[sub_resource type="StandardMaterial3D" id=2]
roughness = 0.7
[sub_resource type="CubeMesh" id=3]
[sub_resource type="BoxMesh" id=3]
[sub_resource type="SpatialMaterial" id=4]
albedo_color = Color( 0.652344, 0.652344, 0.652344, 1 )
[sub_resource type="StandardMaterial3D" id=4]
albedo_color = Color(0.652344, 0.652344, 0.652344, 1)
roughness = 0.0
[sub_resource type="CubeMesh" id=5]
size = Vector3( 1.1, 0.8, 0.1 )
[sub_resource type="BoxMesh" id=5]
size = Vector3(1.1, 0.8, 0.1)
[sub_resource type="SpatialMaterial" id=6]
[sub_resource type="StandardMaterial3D" id=6]
[node name="2Din3D" type="Spatial"]
[node name="2Din3D" type="Node3D"]
script = ExtResource( 1 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1, 0 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1, 0)
fov = 74.0
near = 0.1
[node name="Floor" type="MeshInstance" parent="."]
transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, -1, -2 )
[node name="Floor" type="MeshInstance3D" parent="."]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, -1, -2)
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
surface_material_override/0 = SubResource( 2 )
[node name="Pillar1" type="Spatial" parent="."]
transform = Transform( 0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, -3, -0.2, -4 )
[node name="Pillar1" type="Node3D" parent="."]
transform = Transform3D(0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, -3, -0.2, -4)
[node name="PillarBottom" type="MeshInstance" parent="Pillar1"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0 )
[node name="PillarBottom" type="MeshInstance3D" parent="Pillar1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
surface_material_override/0 = SubResource( 4 )
[node name="PillarTop" type="MeshInstance" parent="Pillar1"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.5, 0 )
[node name="PillarTop" type="MeshInstance3D" parent="Pillar1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.5, 0)
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
surface_material_override/0 = SubResource( 4 )
[node name="PillarMiddle" type="MeshInstance" parent="Pillar1"]
transform = Transform( 0.7, 0, 0, 0, 2, 0, 0, 0, 0.7, 0, 2.5, 0 )
[node name="PillarMiddle" type="MeshInstance3D" parent="Pillar1"]
transform = Transform3D(0.7, 0, 0, 0, 2, 0, 0, 0, 0.7, 0, 2.5, 0)
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
surface_material_override/0 = SubResource( 4 )
[node name="Pillar2" type="Spatial" parent="."]
transform = Transform( 0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, 3, -0.2, -4 )
[node name="Pillar2" type="Node3D" parent="."]
transform = Transform3D(0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, 3, -0.2, -4)
[node name="PillarBottom" type="MeshInstance" parent="Pillar2"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0 )
[node name="PillarBottom" type="MeshInstance3D" parent="Pillar2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
surface_material_override/0 = SubResource( 4 )
[node name="PillarTop" type="MeshInstance" parent="Pillar2"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.5, 0 )
[node name="PillarTop" type="MeshInstance3D" parent="Pillar2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.5, 0)
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
surface_material_override/0 = SubResource( 4 )
[node name="PillarMiddle" type="MeshInstance" parent="Pillar2"]
transform = Transform( 0.7, 0, 0, 0, 2, 0, 0, 0, 0.7, 0, 2.5, 0 )
[node name="PillarMiddle" type="MeshInstance3D" parent="Pillar2"]
transform = Transform3D(0.7, 0, 0, 0, 2, 0, 0, 0, 0.7, 0, 2.5, 0)
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
surface_material_override/0 = SubResource( 4 )
[node name="PillarBack" type="MeshInstance" parent="."]
transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 1.2, -4.5 )
[node name="PillarBack" type="MeshInstance3D" parent="."]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 1.2, -4.5)
mesh = SubResource( 5 )
material/0 = SubResource( 4 )
surface_material_override/0 = SubResource( 4 )
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 0.623013, -0.733525, 0.271654, 0.321394, 0.55667, 0.766044, -0.713134, -0.389948, 0.582563, 0, 10, 0 )
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.623013, -0.733525, 0.271654, 0.321394, 0.55667, 0.766044, -0.713134, -0.389948, 0.582563, 0, 10, 0)
shadow_enabled = true
directional_shadow_blend_splits = true
directional_shadow_normal_bias = 0.2
[node name="ViewportQuad" type="MeshInstance" parent="."]
transform = Transform( 2, 0, 0, 0, 0, -1.333, 0, 1, 0, 0, 1.2, -4.25 )
[node name="ViewportQuad" type="MeshInstance3D" parent="."]
transform = Transform3D(2, 0, 0, 0, 0, -1.333, 0, 1, 0, 0, 1.2, -4.25)
material_override = SubResource( 6 )
mesh = SubResource( 1 )
material/0 = null
surface_material_override/0 = null
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 600, 400 )
[node name="SubViewport" type="SubViewport" parent="."]
size = Vector2(600, 400)
hdr = false
usage = 0
render_target_v_flip = true
[node name="Pong" type="Node2D" parent="Viewport"]
[node name="Pong" type="Node2D" parent="SubViewport"]
script = ExtResource( 2 )
[node name="Background" type="Panel" parent="Viewport/Pong"]
margin_right = 600.0
margin_bottom = 400.0
[node name="Background" type="Panel" parent="SubViewport/Pong"]
offset_right = 600.0
offset_bottom = 400.0
[node name="Ball" type="Sprite" parent="Viewport/Pong"]
position = Vector2( 300, 200 )
[node name="Ball" type="Sprite2D" parent="SubViewport/Pong"]
position = Vector2(300, 200)
texture = ExtResource( 3 )
[node name="LeftPaddle" type="Sprite" parent="Viewport/Pong"]
position = Vector2( 20, 200 )
[node name="LeftPaddle" type="Sprite2D" parent="SubViewport/Pong"]
position = Vector2(20, 200)
texture = ExtResource( 4 )
[node name="RightPaddle" type="Sprite" parent="Viewport/Pong"]
position = Vector2( 580, 200 )
[node name="RightPaddle" type="Sprite2D" parent="SubViewport/Pong"]
position = Vector2(580, 200)
texture = ExtResource( 5 )
[node name="Separator" type="Sprite" parent="Viewport/Pong"]
position = Vector2( 298, 200 )
[node name="Separator" type="Sprite2D" parent="SubViewport/Pong"]
position = Vector2(298, 200)
texture = ExtResource( 6 )

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"
type="StreamTexture2D"
path="res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://ball.png"
dest_files=[ "res://.import/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex" ]
dest_files=["res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"]
[params]

View File

@@ -1,6 +1,6 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[sub_resource type="Sky" id=1]
[resource]
background_mode = 2

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
[params]

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/left_pallete.png-bc33611074a0f886142e37c77bd2545a.stex"
type="StreamTexture2D"
path="res://.godot/imported/left_pallete.png-bc33611074a0f886142e37c77bd2545a.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://left_pallete.png"
dest_files=[ "res://.import/left_pallete.png-bc33611074a0f886142e37c77bd2545a.stex" ]
dest_files=["res://.godot/imported/left_pallete.png-bc33611074a0f886142e37c77bd2545a.stex"]
[params]

View File

@@ -10,9 +10,9 @@ var screen_size = Vector2(640, 400)
var direction = Vector2.LEFT
var pad_size = Vector2(8, 32)
onready var ball = $Ball
onready var left_paddle = $LeftPaddle
onready var right_paddle = $RightPaddle
@onready var ball = $Ball
@onready var left_paddle = $LeftPaddle
@onready var right_paddle = $RightPaddle
func _ready():
screen_size = get_viewport_rect().size # Get actual size.

View File

@@ -17,29 +17,29 @@ config/icon="res://icon.png"
[gdnative]
singletons=[ ]
singletons=[]
[input]
left_move_up={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
left_move_down={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
right_move_up={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777232,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
right_move_down={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777234,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
[rendering]

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.stex"
type="StreamTexture2D"
path="res://.godot/imported/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://right_pallete.png"
dest_files=[ "res://.import/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.stex" ]
dest_files=["res://.godot/imported/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.stex"]
[params]

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/separator.png-f981c8489b9148e2e1dc63398273da74.stex"
type="StreamTexture2D"
path="res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://separator.png"
dest_files=[ "res://.import/separator.png-f981c8489b9148e2e1dc63398273da74.stex" ]
dest_files=["res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.stex"]
[params]

View File

@@ -2,13 +2,13 @@ extends Node2D
var viewport_initial_size = Vector2()
onready var viewport = $Viewport
onready var viewport_sprite = $ViewportSprite
@onready var viewport = $SubViewport
@onready var viewport_sprite = $ViewportSprite
func _ready():
$AnimatedSprite.play()
$AnimatedSprite2D.play()
#warning-ignore:return_value_discarded
get_viewport().connect("size_changed", self, "_root_viewport_size_changed")
get_viewport().connect(&"size_changed", self._root_viewport_size_changed)
viewport_initial_size = viewport.size

View File

@@ -1,63 +1,63 @@
[gd_scene load_steps=11 format=2]
[ext_resource path="res://3d_in_2d.gd" type="Script" id=1]
[ext_resource path="res://robot_demo.png" type="Texture" id=2]
[ext_resource path="res://robot_demo.png" type="Texture2D" id=2]
[ext_resource path="res://robot_3d.tscn" type="PackedScene" id=3]
[sub_resource type="ViewportTexture" id=1]
viewport_path = NodePath("Viewport")
viewport_path = NodePath("SubViewport")
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 2 )
region = Rect2( 0, 0, 64, 64 )
region = Rect2(0, 0, 64, 64)
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 2 )
region = Rect2( 64, 0, 64, 64 )
region = Rect2(64, 0, 64, 64)
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 2 )
region = Rect2( 128, 0, 64, 64 )
region = Rect2(128, 0, 64, 64)
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 2 )
region = Rect2( 192, 0, 64, 64 )
region = Rect2(192, 0, 64, 64)
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 2 )
region = Rect2( 256, 0, 64, 64 )
region = Rect2(256, 0, 64, 64)
[sub_resource type="SpriteFrames" id=7]
animations = [ {
"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ],
animations = [{
"frames": [SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 )],
"loop": true,
"name": "default",
"speed": 5.0
} ]
}]
[node name="3Din2D" type="Node2D"]
script = ExtResource( 1 )
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 300, 300 )
[node name="SubViewport" type="SubViewport" parent="."]
size = Vector2(300, 300)
own_world = true
transparent_bg = true
msaa = 2
hdr = false
usage = 3
[node name="Robot3D" parent="Viewport" instance=ExtResource( 3 )]
[node name="Robot3D" parent="SubViewport" instance=ExtResource( 3 )]
[node name="ViewportSprite" type="Sprite" parent="."]
position = Vector2( 650, 300 )
scale = Vector2( 1, -1 )
[node name="ViewportSprite" type="Sprite2D" parent="."]
position = Vector2(650, 300)
scale = Vector2(1, -1)
texture = SubResource( 1 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
position = Vector2( 350, 300 )
scale = Vector2( 3, 3 )
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(350, 300)
scale = Vector2(3, 3)
frames = SubResource( 7 )
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2( 512, 300 )
offset = Vector2(512, 300)
current = true

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
[params]

View File

@@ -23,7 +23,7 @@ window/stretch/aspect="expand"
[gdnative]
singletons=[ ]
singletons=[]
[rendering]

View File

@@ -1,7 +1,7 @@
extends Node
# A simple script to rotate the model.
onready var model = $Model
@onready var model = $Model
func _process(delta):
model.rotate_y(delta * 0.7)

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/robot_demo.png-8502817e0037b3f31eaca3dae49dcfc5.stex"
type="StreamTexture2D"
path="res://.godot/imported/robot_demo.png-8502817e0037b3f31eaca3dae49dcfc5.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://robot_demo.png"
dest_files=[ "res://.import/robot_demo.png-8502817e0037b3f31eaca3dae49dcfc5.stex" ]
dest_files=["res://.godot/imported/robot_demo.png-8502817e0037b3f31eaca3dae49dcfc5.stex"]
[params]

View File

@@ -1,23 +1,23 @@
[gd_scene load_steps=2 format=2]
[sub_resource type="CubeMesh" id=1]
[sub_resource type="BoxMesh" id=1]
[node name="Cubes" type="Spatial"]
[node name="Cubes" type="Node3D"]
[node name="MeshInstance1" type="MeshInstance" parent="."]
[node name="MeshInstance1" type="MeshInstance3D" parent="."]
mesh = SubResource( 1 )
material/0 = null
surface_material_override/0 = null
[node name="MeshInstance2" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, -1 )
[node name="MeshInstance2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, -1)
mesh = SubResource( 1 )
material/0 = null
surface_material_override/0 = null
[node name="Camera3D" type="Camera" parent="."]
transform = Transform( 0.877582, 0.229849, -0.420736, 0, 0.877582, 0.479426, 0.479426, -0.420736, 0.770151, -1.68294, 2.25571, 3.0806 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(0.877582, 0.229849, -0.420736, 0, 0.877582, 0.479426, 0.479426, -0.420736, 0.770151, -1.68294, 2.25571, 3.0806)
fov = 74.0
[node name="OmniLight" type="OmniLight" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3, 2, 1 )
[node name="OmniLight3D" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3, 2, 1)
shadow_enabled = true
shadow_bias = 0.08

View File

@@ -1,6 +1,6 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[sub_resource type="Sky" id=1]
sky_top_color = Color( 0.207843, 0.239216, 0.254902, 1 )
sky_horizon_color = Color( 0.466667, 0.478431, 0.490196, 1 )

View File

@@ -6,16 +6,16 @@ extends Control
# (SSAA), but filtering must be enabled for supersampling to work.
var scale_factor = 1.0
onready var viewport = $ViewportContainer/Viewport
onready var scale_label = $VBoxContainer/Scale
onready var filter_label = $VBoxContainer/Filter
@onready var viewport = $SubViewportContainer/SubViewport
@onready var scale_label = $VBoxContainer/Scale
@onready var filter_label = $VBoxContainer/Filter
func _ready():
viewport.get_texture().flags = Texture.FLAG_FILTER
viewport.get_texture().flags = Texture2D.FLAG_FILTER
# Required to change the 3D viewport's size when the window is resized.
# warning-ignore:return_value_discarded
get_viewport().connect("size_changed", self, "_root_viewport_size_changed")
get_viewport().connect(&"size_changed", self._root_viewport_size_changed)
func _unhandled_input(event):
@@ -26,9 +26,9 @@ func _unhandled_input(event):
if event.is_action_pressed("toggle_filtering"):
# Toggle the Filter flag on the ViewportTexture.
viewport.get_texture().flags ^= Texture.FLAG_FILTER
viewport.get_texture().flags ^= Texture2D.FLAG_FILTER
var filter_enabled = viewport.get_texture().flags & Texture.FLAG_FILTER
var filter_enabled = viewport.get_texture().flags & Texture2D.FLAG_FILTER
filter_label.text = "Filter: %s" % ("Enabled" if filter_enabled else "Disabled")

View File

@@ -1,10 +1,10 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://noto_sans_ui_regular.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://noto_sans_ui_regular.ttf" type="FontData" id=1]
[ext_resource path="res://cubes.tscn" type="PackedScene" id=2]
[ext_resource path="res://hud.gd" type="Script" id=3]
[sub_resource type="DynamicFont" id=1]
[sub_resource type="Font" id=1]
size = 20
font_data = ExtResource( 1 )
@@ -20,7 +20,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="ViewportContainer" type="ViewportContainer" parent="."]
[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
stretch = true
@@ -28,23 +28,23 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Viewport" type="Viewport" parent="ViewportContainer"]
size = Vector2( 1024, 600 )
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
size = Vector2(1024, 600)
handle_input_locally = false
usage = 3
render_target_update_mode = 3
shadow_atlas_size = 4096
[node name="Cubes" parent="ViewportContainer/Viewport" instance=ExtResource( 2 )]
[node name="Cubes" parent="SubViewportContainer/SubViewport" instance=ExtResource( 2 )]
[node name="Help" type="Label" parent="."]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 16.0
margin_top = -106.0
margin_right = 554.0
margin_bottom = -16.0
custom_colors/font_color_shadow = Color( 0, 0, 0, 0.752941 )
offset_left = 16.0
offset_top = -106.0
offset_right = 554.0
offset_bottom = -16.0
custom_colors/font_color_shadow = Color(0, 0, 0, 0.752941)
custom_constants/shadow_offset_x = 2
custom_constants/shadow_offset_y = 2
custom_constants/shadow_as_outline = 0
@@ -57,18 +57,18 @@ __meta__ = {
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_left = 16.0
margin_top = 16.0
margin_right = 124.0
margin_bottom = 76.0
offset_left = 16.0
offset_top = 16.0
offset_right = 124.0
offset_bottom = 76.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Scale" type="Label" parent="VBoxContainer"]
margin_right = 130.0
margin_bottom = 28.0
custom_colors/font_color_shadow = Color( 0, 0, 0, 0.752941 )
offset_right = 130.0
offset_bottom = 28.0
custom_colors/font_color_shadow = Color(0, 0, 0, 0.752941)
custom_constants/shadow_offset_x = 2
custom_constants/shadow_offset_y = 2
custom_constants/shadow_as_outline = 0
@@ -78,10 +78,10 @@ __meta__ = {
}
[node name="Filter" type="Label" parent="VBoxContainer"]
margin_top = 32.0
margin_right = 130.0
margin_bottom = 60.0
custom_colors/font_color_shadow = Color( 0, 0, 0, 0.752941 )
offset_top = 32.0
offset_right = 130.0
offset_bottom = 60.0
custom_colors/font_color_shadow = Color(0, 0, 0, 0.752941)
custom_constants/shadow_offset_x = 2
custom_constants/shadow_offset_y = 2
custom_constants/shadow_as_outline = 0

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
[params]

View File

@@ -10,7 +10,7 @@ config_version=4
[application]
config/name="3D Viewport Scaling"
config/name="3D SubViewport Scaling"
config/description="This demo shows how to scale the 3D viewport rendering without affecting 2D
elements such as the HUD. It also demonstrates how to toggle filtering on a
viewport. This technique can be useful in 2D games as well. For instance, it can
@@ -29,13 +29,13 @@ window/stretch/aspect="expand"
cycle_viewport_resolution={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
toggle_filtering={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777221,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
[rendering]

View File

@@ -1,4 +1,4 @@
extends Spatial
extends Node3D
# Handle the motion of both player cameras as well as communication with the
# SplitScreen shader to achieve the dynamic split screen effet
@@ -19,25 +19,25 @@ extends Spatial
# depending on the distance between players. If false, the thickness will
# be constant and equal to split_line_thickness
export(float) var max_separation = 20.0
export(float) var split_line_thickness = 3.0
export(Color, RGBA) var split_line_color = Color.black
export(bool) var adaptive_split_line_thickness = true
@export var max_separation: float = 20.0
@export var split_line_thickness: float = 3.0
@export var split_line_color: Color, RGBA = Color.BLACK
@export var adaptive_split_line_thickness: bool = true
onready var player1 = $"../Player1"
onready var player2 = $"../Player2"
onready var view = $View
onready var viewport1 = $Viewport1
onready var viewport2 = $Viewport2
onready var camera1 = viewport1.get_node(@"Camera1")
onready var camera2 = viewport2.get_node(@"Camera2")
@onready var player1 = $"../Player1"
@onready var player2 = $"../Player2"
@onready var view = $View
@onready var viewport1 = $Viewport1
@onready var viewport2 = $Viewport2
@onready var camera1 = viewport1.get_node(^"Camera1")
@onready var camera2 = viewport2.get_node(^"Camera2")
func _ready():
_on_size_changed()
_update_splitscreen()
get_viewport().connect("size_changed", self, "_on_size_changed")
get_viewport().connect(&"size_changed", self._on_size_changed)
view.material.set_shader_param("viewport1", viewport1.get_texture())
view.material.set_shader_param("viewport2", viewport2.get_texture())
@@ -55,17 +55,17 @@ func _move_cameras():
position_difference = position_difference.normalized() * distance
camera1.translation.x = player1.translation.x + position_difference.x / 2.0
camera1.translation.z = player1.translation.z + position_difference.z / 2.0
camera1.position.x = player1.position.x + position_difference.x / 2.0
camera1.position.z = player1.position.z + position_difference.z / 2.0
camera2.translation.x = player2.translation.x - position_difference.x / 2.0
camera2.translation.z = player2.translation.z - position_difference.z / 2.0
camera2.position.x = player2.position.x - position_difference.x / 2.0
camera2.position.z = player2.position.z - position_difference.z / 2.0
func _update_splitscreen():
var screen_size = get_viewport().get_visible_rect().size
var player1_position = camera1.unproject_position(player1.translation) / screen_size
var player2_position = camera2.unproject_position(player2.translation) / screen_size
var player1_position = camera1.unproject_position(player1.position) / screen_size
var player2_position = camera2.unproject_position(player2.position) / screen_size
var thickness
if adaptive_split_line_thickness:
@@ -101,7 +101,7 @@ func _on_size_changed():
func _compute_position_difference_in_world():
return player2.translation - player1.translation
return player2.position - player1.position
func _compute_horizontal_length(vec):

View File

@@ -1,6 +1,6 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[sub_resource type="Sky" id=1]
ground_bottom_color = Color( 0.839216, 0.917647, 0.980392, 1 )
ground_horizon_color = Color( 0.839216, 0.917647, 0.980392, 1 )

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
[params]

View File

@@ -1,9 +1,9 @@
extends KinematicBody
extends CharacterBody3D
# Moves the player
export(int, 1, 2) var player_id = 1
export(float) var walk_speed = 20.0
@export var player_id: int, 1, 2 = 1
@export var walk_speed: float = 20.0
func _physics_process(_delta):

View File

@@ -24,61 +24,61 @@ gdscript/warnings/return_value_discarded=false
move_up_player1={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":90,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
]
]
}
move_down_player1={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
]
]
}
move_left_player1={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":81,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":81,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
]
]
}
move_right_player1={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
]
]
}
move_up_player2={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":73,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":73,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777232,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":3,"axis_value":-1.0,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":1,"axis":1,"axis_value":-1.0,"script":null)
]
]
}
move_down_player2={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":75,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":75,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777234,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":3,"axis_value":1.0,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":1,"axis":1,"axis_value":1.0,"script":null)
]
]
}
move_left_player2={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":74,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":74,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777231,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":2,"axis_value":-1.0,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":1,"axis":0,"axis_value":-1.0,"script":null)
]
]
}
move_right_player2={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":76,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":76,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777233,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":2,"axis_value":1.0,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":1,"axis":0,"axis_value":1.0,"script":null)
]
]
}
[rendering]
@@ -88,5 +88,5 @@ quality/intended_usage/framebuffer_allocation=3
vram_compression/import_etc=true
vram_compression/import_etc2=false
quality/shadows/filter_mode=2
environment/default_clear_color=Color( 1, 1, 1, 1 )
environment/default_clear_color=Color(1, 1, 1, 1)
environment/default_environment="res://default_env.tres"

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
tool
extends Spatial
@tool
extends Node3D
# Set a random color to all objects in the "walls" group.
# To use, attach this script to the "Walls" node.
@@ -8,7 +8,7 @@ func _ready():
randomize()
var walls = get_tree().get_nodes_in_group("walls")
for wall in walls:
var material = SpatialMaterial.new()
var material = StandardMaterial3D.new()
material.albedo_color = Color(randf(), randf(), randf())
wall.material_override = material

View File

@@ -1,6 +1,6 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[sub_resource type="Sky" id=1]
[resource]
background_mode = 2

View File

@@ -1,22 +1,22 @@
extends Spatial
extends Node3D
# The size of the quad mesh itself.
var quad_mesh_size
# Used for checking if the mouse is inside the Area
# Used for checking if the mouse is inside the Area3D
var is_mouse_inside = false
# Used for checking if the mouse was pressed inside the Area
# Used for checking if the mouse was pressed inside the Area3D
var is_mouse_held = false
# The last non-empty mouse position. Used when dragging outside of the box.
var last_mouse_pos3D = null
# The last processed input touch/mouse event. To calculate relative movement.
var last_mouse_pos2D = null
onready var node_viewport = $Viewport
onready var node_quad = $Quad
onready var node_area = $Quad/Area
@onready var node_viewport = $SubViewport
@onready var node_quad = $Quad
@onready var node_area = $Quad/Area3D
func _ready():
node_area.connect("mouse_entered", self, "_mouse_entered_area")
node_area.connect(&"mouse_entered", self._mouse_entered_area)
# If the material is NOT set to use billboard settings, then avoid running billboard specific code
if node_quad.get_surface_material(0).params_billboard_mode == 0:
@@ -55,7 +55,7 @@ func _unhandled_input(event):
node_viewport.input(event)
# Handle mouse events inside Area. (Area.input_event had many issues with dragging)
# Handle mouse events inside Area3D. (Area3D.input_event had many issues with dragging)
func handle_mouse(event):
# Get mesh size to detect edges and make conversions. This code only support PlaneMesh and QuadMesh.
quad_mesh_size = node_quad.mesh.size
@@ -64,15 +64,15 @@ func handle_mouse(event):
if event is InputEventMouseButton or event is InputEventScreenTouch:
is_mouse_held = event.pressed
# Find mouse position in Area
# Find mouse position in Area3D
var mouse_pos3D = find_mouse(event.global_position)
# Check if the mouse is outside of bounds, use last position to avoid errors
# NOTE: mouse_exited signal was unrealiable in this situation
is_mouse_inside = mouse_pos3D != null
if is_mouse_inside:
# Convert click_pos from world coordinate space to a coordinate space relative to the Area node.
# NOTE: affine_inverse accounts for the Area node's scale, rotation, and translation in the scene!
# Convert click_pos from world coordinate space to a coordinate space relative to the Area3D node.
# NOTE: affine_inverse accounts for the Area3D node's scale, rotation, and position in the scene!
mouse_pos3D = node_area.global_transform.affine_inverse() * mouse_pos3D
last_mouse_pos3D = mouse_pos3D
else:
@@ -119,16 +119,16 @@ func handle_mouse(event):
func find_mouse(global_position):
var camera = get_viewport().get_camera()
var camera = get_viewport().get_camera_3d()
# From camera center to the mouse position in the Area
# From camera center to the mouse position in the Area3D
var from = camera.project_ray_origin(global_position)
var dist = find_further_distance_to(camera.transform.origin)
var to = from + camera.project_ray_normal(global_position) * dist
# Manually raycasts the are to find the mouse position
var result = get_world().direct_space_state.intersect_ray(from, to, [], node_area.collision_layer,false,true) #for 3.1 changes
var result = get_world_3d().direct_space_state.intersect_ray(from, to, [], node_area.collision_layer,false,true) #for 3.1 changes
if result.size() > 0:
return result.position
@@ -161,10 +161,10 @@ func rotate_area_to_billboard():
# Try to match the area with the material's billboard setting, if enabled
if billboard_mode > 0:
# Get the camera
var camera = get_viewport().get_camera()
var camera = get_viewport().get_camera_3d()
# Look in the same direction as the camera
var look = camera.to_global(Vector3(0, 0, -100)) - camera.global_transform.origin
look = node_area.translation + look
look = node_area.position + look
# Y-Billboard: Lock Y rotation, but gives bad results if the camera is tilted.
if billboard_mode == 2:

View File

@@ -6,37 +6,37 @@
length = 6.0
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Camera:transform")
tracks/0/path = NodePath("Camera3D:transform")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 2, 4, 6 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"times": PackedFloat32Array(0, 2, 4, 6),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [ Transform( 0.994592, 0, 0.103856, 0, 1, 0, -0.103856, 0, 0.994592, 0.465682, 0, 1.78523 ), Transform( 0.962984, 0, -0.269557, 0, 1, 0, 0.269557, 0, 0.962984, -0.462237, 0, 2.41934 ), Transform( 0.806599, 0, -0.591098, 0, 1, 0, 0.591098, 0, 0.806599, -1.59502, 0, 2.05358 ), Transform( 0.994592, 0, 0.103856, 0, 1, 0, -0.103856, 0, 0.994592, 0.465682, 0, 1.78523 ) ]
"values": [Transform3D(0.994592, 0, 0.103856, 0, 1, 0, -0.103856, 0, 0.994592, 0.465682, 0, 1.78523), Transform3D(0.962984, 0, -0.269557, 0, 1, 0, 0.269557, 0, 0.962984, -0.462237, 0, 2.41934), Transform3D(0.806599, 0, -0.591098, 0, 1, 0, 0.591098, 0, 0.806599, -1.59502, 0, 2.05358), Transform3D(0.994592, 0, 0.103856, 0, 1, 0, -0.103856, 0, 0.994592, 0.465682, 0, 1.78523)]
}
[sub_resource type="PlaneMesh" id=2]
[sub_resource type="CubeMesh" id=3]
[sub_resource type="BoxMesh" id=3]
[sub_resource type="SpatialMaterial" id=4]
albedo_color = Color( 0.722656, 0.791992, 1, 1 )
[sub_resource type="StandardMaterial3D" id=4]
albedo_color = Color(0.722656, 0.791992, 1, 1)
roughness = 0.0
[node name="GUIin3D" type="Spatial"]
[node name="GUIin3D" type="Node3D"]
[node name="GUIPanel3D" parent="." instance=ExtResource( 1 )]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 0, 3 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 0, 3)
fov = 74.0
near = 0.1
[node name="OmniLight" type="OmniLight" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.38866, 1.2413, 2.72141 )
[node name="OmniLight3D" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.38866, 1.2413, 2.72141)
shadow_enabled = true
omni_range = 10.0
@@ -45,39 +45,39 @@ autoplay = "Move_camera"
playback_speed = 0.25
anims/Move_camera = SubResource( 1 )
[node name="Background" type="Spatial" parent="."]
[node name="Background" type="Node3D" parent="."]
[node name="Wall" type="MeshInstance" parent="Background"]
transform = Transform( 4, 0, 0, 0, -1.74846e-07, -4, 0, 4, -1.74846e-07, -2.60819, 0.589247, -2.08943 )
[node name="Wall" type="MeshInstance3D" parent="Background"]
transform = Transform3D(4, 0, 0, 0, -1.74846e-07, -4, 0, 4, -1.74846e-07, -2.60819, 0.589247, -2.08943)
mesh = SubResource( 2 )
material/0 = null
surface_material_override/0 = null
[node name="Wall2" type="MeshInstance" parent="Background"]
transform = Transform( 4, 0, 0, 0, -1.74846e-07, -4, 0, 4, -1.74846e-07, 5.08055, 0.589247, -2.08943 )
[node name="Wall2" type="MeshInstance3D" parent="Background"]
transform = Transform3D(4, 0, 0, 0, -1.74846e-07, -4, 0, 4, -1.74846e-07, 5.08055, 0.589247, -2.08943)
mesh = SubResource( 2 )
material/0 = null
surface_material_override/0 = null
[node name="Wall3" type="MeshInstance" parent="Background"]
transform = Transform( -1.74846e-07, -4, 0, -1.74846e-07, 7.64274e-15, -4, 4, -1.74846e-07, -1.74846e-07, 9.04446, 0.589247, 1.62058 )
[node name="Wall3" type="MeshInstance3D" parent="Background"]
transform = Transform3D(-1.74846e-07, -4, 0, -1.74846e-07, 7.64274e-15, -4, 4, -1.74846e-07, -1.74846e-07, 9.04446, 0.589247, 1.62058)
mesh = SubResource( 2 )
material/0 = null
surface_material_override/0 = null
[node name="Floor" type="MeshInstance" parent="Background"]
transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, -2.60819, -2.68765, 1.46502 )
[node name="Floor" type="MeshInstance3D" parent="Background"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, -2.60819, -2.68765, 1.46502)
mesh = SubResource( 2 )
material/0 = null
surface_material_override/0 = null
[node name="Floor2" type="MeshInstance" parent="Background"]
transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, 5.08055, -2.68765, 1.46502 )
[node name="Floor2" type="MeshInstance3D" parent="Background"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 5.08055, -2.68765, 1.46502)
mesh = SubResource( 2 )
material/0 = null
surface_material_override/0 = null
[node name="Cube" type="MeshInstance" parent="Background"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.25901, -0.598608, 0.374871 )
[node name="Cube" type="MeshInstance3D" parent="Background"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.25901, -0.598608, 0.374871)
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
surface_material_override/0 = SubResource( 4 )
[node name="Cube2" type="MeshInstance" parent="Background"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.88761, 2.01326, 0.374871 )
[node name="Cube2" type="MeshInstance3D" parent="Background"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.88761, 2.01326, 0.374871)
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
surface_material_override/0 = SubResource( 4 )

View File

@@ -1,111 +1,111 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://gui_3d.gd" type="Script" id=1]
[ext_resource path="res://icon.png" type="Texture" id=2]
[ext_resource path="res://icon.png" type="Texture2D" id=2]
[sub_resource type="QuadMesh" id=1]
size = Vector2( 3, 2 )
size = Vector2(3, 2)
[sub_resource type="ViewportTexture" id=2]
viewport_path = NodePath("Viewport")
viewport_path = NodePath("SubViewport")
[sub_resource type="SpatialMaterial" id=3]
[sub_resource type="StandardMaterial3D" id=3]
resource_local_to_scene = true
flags_transparent = true
flags_unshaded = true
flags_albedo_tex_force_srgb = true
albedo_texture = SubResource( 2 )
[sub_resource type="BoxShape" id=4]
extents = Vector3( 1.5, 1, 0.05 )
[sub_resource type="BoxShape3D" id=4]
extents = Vector3(1.5, 1, 0.05)
[node name="GUIPanel3D" type="Spatial"]
[node name="GUIPanel3D" type="Node3D"]
script = ExtResource( 1 )
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 280, 180 )
[node name="SubViewport" type="SubViewport" parent="."]
size = Vector2(280, 180)
hdr = false
usage = 0
render_target_v_flip = true
render_target_update_mode = 3
[node name="GUI" type="Control" parent="Viewport"]
margin_right = 280.0
margin_bottom = 180.0
[node name="GUI" type="Control" parent="SubViewport"]
offset_right = 280.0
offset_bottom = 180.0
mouse_filter = 1
[node name="Panel" type="Panel" parent="Viewport/GUI"]
[node name="Panel" type="Panel" parent="SubViewport/GUI"]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="Label" type="Label" parent="Viewport/GUI/Panel"]
margin_left = 44.0
margin_top = 27.0
margin_right = 121.0
margin_bottom = 41.0
[node name="Label" type="Label" parent="SubViewport/GUI/Panel"]
offset_left = 44.0
offset_top = 27.0
offset_right = 121.0
offset_bottom = 41.0
text = "Hello world!"
[node name="Button" type="Button" parent="Viewport/GUI/Panel"]
margin_left = 14.0
margin_top = 46.0
margin_right = 154.0
margin_bottom = 74.0
[node name="Button" type="Button" parent="SubViewport/GUI/Panel"]
offset_left = 14.0
offset_top = 46.0
offset_right = 154.0
offset_bottom = 74.0
text = "A button!"
[node name="TextEdit" type="LineEdit" parent="Viewport/GUI/Panel"]
margin_left = 14.0
margin_top = 87.0
margin_right = 154.0
margin_bottom = 111.0
[node name="TextEdit" type="LineEdit" parent="SubViewport/GUI/Panel"]
offset_left = 14.0
offset_top = 87.0
offset_right = 154.0
offset_bottom = 111.0
[node name="HSlider" type="HSlider" parent="Viewport/GUI/Panel"]
margin_left = 14.0
margin_top = 118.0
margin_right = 154.0
margin_bottom = 143.0
[node name="HSlider" type="HSlider" parent="SubViewport/GUI/Panel"]
offset_left = 14.0
offset_top = 118.0
offset_right = 154.0
offset_bottom = 143.0
ticks_on_borders = true
[node name="ColorRect" type="ColorRect" parent="Viewport/GUI/Panel"]
margin_left = 180.0
margin_top = 26.0
margin_right = 244.0
margin_bottom = 90.0
color = Color( 1, 0, 0, 1 )
[node name="ColorRect" type="ColorRect" parent="SubViewport/GUI/Panel"]
offset_left = 180.0
offset_top = 26.0
offset_right = 244.0
offset_bottom = 90.0
color = Color(1, 0, 0, 1)
[node name="TextureRect" type="TextureRect" parent="Viewport/GUI/Panel"]
[node name="TextureRect" type="TextureRect" parent="SubViewport/GUI/Panel"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = 52.0
margin_top = -52.0
margin_right = 92.0
margin_bottom = -12.0
offset_left = 52.0
offset_top = -52.0
offset_right = 92.0
offset_bottom = -12.0
texture = ExtResource( 2 )
expand = true
[node name="VSlider" type="VSlider" parent="Viewport/GUI/Panel"]
margin_left = 260.0
margin_top = 26.0
margin_right = 276.0
margin_bottom = 166.0
[node name="VSlider" type="VSlider" parent="SubViewport/GUI/Panel"]
offset_left = 260.0
offset_top = 26.0
offset_right = 276.0
offset_bottom = 166.0
[node name="OptionButton" type="OptionButton" parent="Viewport/GUI/Panel"]
margin_left = 170.0
margin_top = 111.0
margin_right = 252.0
margin_bottom = 165.0
[node name="OptionButton" type="OptionButton" parent="SubViewport/GUI/Panel"]
offset_left = 170.0
offset_top = 111.0
offset_right = 252.0
offset_bottom = 165.0
text = "Item 0"
items = [ "Item 0", null, false, 0, null, "Item 1", null, false, 1, null, "Item 2", null, false, 2, null ]
items = ["Item 0", null, false, 0, null, "Item 1", null, false, 1, null, "Item 2", null, false, 2, null]
selected = 0
[node name="Quad" type="MeshInstance" parent="."]
[node name="Quad" type="MeshInstance3D" parent="."]
mesh = SubResource( 1 )
material/0 = SubResource( 3 )
surface_material_override/0 = SubResource( 3 )
[node name="Area" type="Area" parent="Quad"]
[node name="Area3D" type="Area3D" parent="Quad"]
collision_layer = 2
input_capture_on_drag = true
[node name="CollisionShape" type="CollisionShape" parent="Quad/Area"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Quad/Area3D"]
shape = SubResource( 4 )

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
[params]

View File

@@ -18,7 +18,7 @@ config/icon="res://icon.png"
[gdnative]
singletons=[ ]
singletons=[]
[layer_names]

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
[params]

View File

@@ -1,8 +1,8 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/mountains.png-03f302fbd9195711fc86ea8f28ca435e.stex"
type="StreamTexture2D"
path="res://.godot/imported/mountains.png-03f302fbd9195711fc86ea8f28ca435e.stex"
metadata={
"vram_texture": false
}
@@ -10,7 +10,7 @@ metadata={
[deps]
source_file="res://mountains.png"
dest_files=[ "res://.import/mountains.png-03f302fbd9195711fc86ea8f28ca435e.stex" ]
dest_files=["res://.godot/imported/mountains.png-03f302fbd9195711fc86ea8f28ca435e.stex"]
[params]

View File

@@ -27,7 +27,7 @@ window/stretch/aspect="keep"
[gdnative]
singletons=[ ]
singletons=[]
[rendering]

View File

@@ -1,11 +1,11 @@
extends Node
onready var captured_image = $CapturedImage
@onready var captured_image = $CapturedImage
func _on_CaptureButton_pressed():
get_viewport().set_clear_mode(Viewport.CLEAR_MODE_ONLY_NEXT_FRAME)
get_viewport().set_clear_mode(SubViewport.CLEAR_MODE_ONLY_NEXT_FRAME)
# Wait until the frame has finished before getting the texture.
yield(VisualServer, "frame_post_draw")
await RenderingServer.frame_post_draw
# Retrieve the captured image.
var img = get_viewport().get_texture().get_data()

View File

@@ -1,18 +1,18 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://screen_capture.gd" type="Script" id=1]
[ext_resource path="res://mountains.png" type="Texture" id=2]
[ext_resource path="res://mountains.png" type="Texture2D" id=2]
[node name="ScreenCapture" type="Control"]
margin_right = 40.0
margin_bottom = 40.0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource( 1 )
[node name="Background" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = 986.0
margin_bottom = 560.0
offset_right = 986.0
offset_bottom = 560.0
grow_horizontal = 0
grow_vertical = 0
texture = ExtResource( 2 )
@@ -21,19 +21,19 @@ expand = true
[node name="CapturedImage" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = 2013.0
margin_bottom = 1162.0
offset_right = 2013.0
offset_bottom = 1162.0
grow_horizontal = 0
grow_vertical = 0
rect_scale = Vector2( 0.5, 0.5 )
rect_scale = Vector2(0.5, 0.5)
expand = true
stretch_mode = 4
[node name="CaptureButton" type="Button" parent="."]
margin_left = 48.0
margin_top = 53.0
margin_right = 188.0
margin_bottom = 113.0
offset_left = 48.0
offset_top = 53.0
offset_right = 188.0
offset_bottom = 113.0
text = "Capture screen"
[connection signal="pressed" from="CaptureButton" to="." method="_on_CaptureButton_pressed"]