Skip to content

Commit 0224fdf

Browse files
committed
initial commit
0 parents  commit 0224fdf

File tree

16 files changed

+501
-0
lines changed

16 files changed

+501
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.import/*

autoload/camera_transition.gd

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
extends Node
2+
3+
onready var camera2D: Camera2D = $Camera2D
4+
onready var camera3D: Camera = $Camera
5+
onready var tween: Tween = $Tween
6+
7+
var transitioning: bool = false
8+
9+
func _ready() -> void:
10+
camera2D.current = false
11+
camera3D.current = false
12+
13+
func switch_camera(from, to) -> void:
14+
from.current = false
15+
to.current = true
16+
17+
func transition_camera2D(from: Camera2D, to: Camera2D, duration: float = 1.0) -> void:
18+
if transitioning: return
19+
# Copy the parameters of the first camera
20+
camera2D.zoom = from.zoom
21+
camera2D.offset = from.offset
22+
camera2D.light_mask = from.light_mask
23+
24+
# Move our transition camera to the first camera position
25+
camera2D.global_transform = from.global_transform
26+
27+
# Make our transition camera current
28+
camera2D.current = true
29+
30+
transitioning = true
31+
32+
# Move to the second camera, while also adjusting the parameters to
33+
# match the second camera
34+
tween.remove_all()
35+
tween.interpolate_property(camera2D, "global_transform", camera2D.global_transform,
36+
to.global_transform, duration, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
37+
tween.interpolate_property(camera2D, "zoom", camera2D.zoom,
38+
to.zoom, duration, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
39+
tween.interpolate_property(camera2D, "offset", camera2D.offset,
40+
to.offset, duration, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
41+
tween.start()
42+
43+
# Wait for the tween to complete
44+
yield(tween, "tween_all_completed")
45+
46+
# Make the second camera current
47+
to.current = true
48+
transitioning = false
49+
50+
func transition_camera3D(from: Camera, to: Camera, duration: float = 1.0) -> void:
51+
if transitioning: return
52+
# Copy the parameters of the first camera
53+
camera3D.fov = from.fov
54+
camera3D.cull_mask = from.cull_mask
55+
56+
# Move our transition camera to the first camera position
57+
camera3D.global_transform = from.global_transform
58+
59+
# Make our transition camera current
60+
camera3D.current = true
61+
62+
transitioning = true
63+
64+
# Move to the second camera, while also adjusting the parameters to
65+
# match the second camera
66+
tween.remove_all()
67+
tween.interpolate_property(camera3D, "global_transform", camera3D.global_transform,
68+
to.global_transform, duration, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
69+
tween.interpolate_property(camera3D, "fov", camera3D.fov,
70+
to.fov, duration, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
71+
tween.start()
72+
73+
# Wait for the tween to complete
74+
yield(tween, "tween_all_completed")
75+
76+
# Make the second camera current
77+
to.current = true
78+
transitioning = false

autoload/camera_transition.tscn

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[gd_scene load_steps=2 format=2]
2+
3+
[ext_resource path="res://autoload/camera_transition.gd" type="Script" id=1]
4+
5+
[node name="CameraTransition" type="Node"]
6+
script = ExtResource( 1 )
7+
8+
[node name="Camera2D" type="Camera2D" parent="."]
9+
10+
[node name="Camera" type="Camera" parent="."]
11+
12+
[node name="Tween" type="Tween" parent="."]

default_env.tres

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[gd_resource type="Environment" load_steps=2 format=2]
2+
3+
[sub_resource type="ProceduralSky" id=1]
4+
5+
[resource]
6+
background_mode = 2
7+
background_sky = SubResource( 1 )

icon.png

3.23 KB
Loading

icon.png.import

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://icon.png"
13+
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
process/normal_map_invert_y=false
32+
stream=false
33+
size_limit=0
34+
detect_3d=true
35+
svg/scale=1.0

project.godot

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
; Engine configuration file.
2+
; It's best edited using the editor UI and not directly,
3+
; since the parameters that go here are not all obvious.
4+
;
5+
; Format:
6+
; [section] ; section goes between []
7+
; param=value ; assign values to parameters
8+
9+
config_version=4
10+
11+
[application]
12+
13+
config/name="camera_transition"
14+
run/main_scene="res://scenes/main.tscn"
15+
config/icon="res://icon.png"
16+
17+
[autoload]
18+
19+
CameraTransition="*res://autoload/camera_transition.tscn"
20+
21+
[display]
22+
23+
window/size/width=1920
24+
window/size/height=1080
25+
window/size/test_width=1280
26+
window/size/test_height=720
27+
window/stretch/mode="2d"
28+
window/stretch/aspect="keep"
29+
30+
[gui]
31+
32+
common/drop_mouse_on_gui_input_disabled=true
33+
34+
[physics]
35+
36+
common/enable_pause_aware_picking=true
37+
38+
[rendering]
39+
40+
quality/filters/anisotropic_filter_level=8
41+
quality/filters/msaa=3
42+
environment/default_environment="res://default_env.tres"

scenes/2D_example.tscn

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[gd_scene load_steps=6 format=2]
2+
3+
[ext_resource path="res://scripts/2D_example.gd" type="Script" id=1]
4+
[ext_resource path="res://icon.png" type="Texture" id=2]
5+
6+
[sub_resource type="OpenSimplexNoise" id=2]
7+
seed = 5
8+
octaves = 5
9+
period = 256.0
10+
persistence = 0.415
11+
lacunarity = 2.81
12+
13+
[sub_resource type="NoiseTexture" id=3]
14+
width = 1024
15+
height = 1024
16+
seamless = true
17+
noise = SubResource( 2 )
18+
19+
[sub_resource type="Environment" id=1]
20+
background_mode = 4
21+
tonemap_mode = 4
22+
23+
[node name="2DExample" type="Node2D"]
24+
script = ExtResource( 1 )
25+
26+
[node name="BG" type="Polygon2D" parent="."]
27+
modulate = Color( 0.184314, 0.647059, 0.588235, 1 )
28+
texture = SubResource( 3 )
29+
polygon = PoolVector2Array( -910, -424, 3223, -434, 3156, 1822, -910, 1793 )
30+
31+
[node name="Icon" type="Sprite" parent="."]
32+
position = Vector2( 314, 224 )
33+
texture = ExtResource( 2 )
34+
35+
[node name="Icon3" type="Sprite" parent="."]
36+
modulate = Color( 0.941176, 0, 0, 1 )
37+
position = Vector2( 478, 224 )
38+
texture = ExtResource( 2 )
39+
40+
[node name="Icon2" type="Sprite" parent="."]
41+
position = Vector2( 1651, 813 )
42+
texture = ExtResource( 2 )
43+
44+
[node name="Icon5" type="Sprite" parent="."]
45+
modulate = Color( 0.909804, 0, 1, 1 )
46+
position = Vector2( 1516, 813 )
47+
texture = ExtResource( 2 )
48+
49+
[node name="Icon4" type="Sprite" parent="."]
50+
modulate = Color( 0.278431, 1, 0.141176, 1 )
51+
position = Vector2( 1769, 813 )
52+
texture = ExtResource( 2 )
53+
54+
[node name="Camera2D1" type="Camera2D" parent="."]
55+
position = Vector2( 314, 228 )
56+
current = true
57+
58+
[node name="Camera2D2" type="Camera2D" parent="."]
59+
position = Vector2( 1648, 814 )
60+
61+
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
62+
environment = SubResource( 1 )

scenes/3D_example.tscn

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[gd_scene load_steps=11 format=2]
2+
3+
[ext_resource path="res://scripts/3D_example.gd" type="Script" id=1]
4+
5+
[sub_resource type="CubeMesh" id=1]
6+
7+
[sub_resource type="SpatialMaterial" id=7]
8+
albedo_color = Color( 0.0705882, 0.517647, 0.811765, 1 )
9+
roughness = 0.6
10+
ao_enabled = true
11+
ao_light_affect = 0.0
12+
ao_on_uv2 = false
13+
ao_texture_channel = 0
14+
subsurf_scatter_enabled = true
15+
subsurf_scatter_strength = 0.0
16+
17+
[sub_resource type="CylinderMesh" id=2]
18+
19+
[sub_resource type="SpatialMaterial" id=8]
20+
albedo_color = Color( 0.898039, 0.176471, 0.141176, 1 )
21+
metallic = 0.13
22+
roughness = 0.3
23+
ao_enabled = true
24+
ao_light_affect = 0.0
25+
ao_on_uv2 = false
26+
ao_texture_channel = 0
27+
subsurf_scatter_enabled = true
28+
subsurf_scatter_strength = 0.0
29+
30+
[sub_resource type="PlaneMesh" id=5]
31+
size = Vector2( 50, 50 )
32+
33+
[sub_resource type="SpatialMaterial" id=6]
34+
albedo_color = Color( 0.282353, 0.282353, 0.282353, 1 )
35+
metallic = 0.22
36+
roughness = 0.57
37+
38+
[sub_resource type="CubeMesh" id=9]
39+
size = Vector3( 1, 6, 5 )
40+
41+
[sub_resource type="ProceduralSky" id=3]
42+
43+
[sub_resource type="Environment" id=4]
44+
background_mode = 2
45+
background_sky = SubResource( 3 )
46+
tonemap_mode = 4
47+
ss_reflections_enabled = true
48+
ssao_enabled = true
49+
50+
[node name="3DExample" type="Spatial"]
51+
script = ExtResource( 1 )
52+
53+
[node name="MeshInstance" type="MeshInstance" parent="."]
54+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.84518, 0 )
55+
mesh = SubResource( 1 )
56+
material/0 = SubResource( 7 )
57+
58+
[node name="MeshInstance2" type="MeshInstance" parent="."]
59+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.51597, -1.84518, 0.752246 )
60+
mesh = SubResource( 2 )
61+
material/0 = SubResource( 8 )
62+
63+
[node name="MeshInstance3" type="MeshInstance" parent="."]
64+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.79911, 0 )
65+
mesh = SubResource( 5 )
66+
material/0 = SubResource( 6 )
67+
68+
[node name="Wall" type="MeshInstance" parent="."]
69+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.14242, 0.169752, 7.50346 )
70+
visible = false
71+
mesh = SubResource( 9 )
72+
73+
[node name="Camera1" type="Camera" parent="."]
74+
transform = Transform( 0.93138, 0.11162, -0.346514, 0, 0.951836, 0.306609, 0.364048, -0.28557, 0.886521, -2.28311, 1.85818, 8.48474 )
75+
current = true
76+
77+
[node name="Camera2" type="Camera" parent="."]
78+
transform = Transform( 0.653183, 0, 0.7572, 0, 1, 0, -0.7572, 0, 0.653183, 6.71706, 0, 5.28411 )
79+
fov = 110.0
80+
81+
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
82+
environment = SubResource( 4 )
83+
84+
[node name="DirectionalLight" type="DirectionalLight" parent="WorldEnvironment"]
85+
transform = Transform( 0.830751, 0.310514, -0.461989, 0, 0.829954, 0.557832, 0.556644, -0.46342, 0.689485, 0, 7.0162, 0 )
86+
shadow_enabled = true
87+
shadow_color = Color( 0.537255, 0.537255, 0.537255, 1 )

scenes/hud.tscn

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[gd_scene load_steps=4 format=2]
2+
3+
[ext_resource path="res://visuals/fonts/BebasNeue-Regular.ttf" type="DynamicFontData" id=1]
4+
[ext_resource path="res://scripts/hud.gd" type="Script" id=2]
5+
6+
[sub_resource type="DynamicFont" id=1]
7+
size = 32
8+
use_mipmaps = true
9+
use_filter = true
10+
font_data = ExtResource( 1 )
11+
12+
[node name="HUD" type="Control"]
13+
anchor_right = 1.0
14+
anchor_bottom = 1.0
15+
script = ExtResource( 2 )
16+
17+
[node name="HBoxContainer" type="HBoxContainer" parent="."]
18+
anchor_left = 0.5
19+
anchor_top = 1.0
20+
anchor_right = 0.5
21+
anchor_bottom = 1.0
22+
margin_left = -442.5
23+
margin_top = -115.0
24+
margin_right = 442.5
25+
margin_bottom = -23.0
26+
custom_constants/separation = 15
27+
28+
[node name="2DBtn" type="Button" parent="HBoxContainer"]
29+
margin_right = 209.0
30+
margin_bottom = 92.0
31+
size_flags_horizontal = 3
32+
size_flags_vertical = 3
33+
custom_fonts/font = SubResource( 1 )
34+
text = "2D SCENE"
35+
36+
[node name="3DBtn" type="Button" parent="HBoxContainer"]
37+
margin_left = 224.0
38+
margin_right = 433.0
39+
margin_bottom = 92.0
40+
size_flags_horizontal = 3
41+
size_flags_vertical = 3
42+
custom_fonts/font = SubResource( 1 )
43+
text = "3D SCENE"
44+
45+
[node name="SmoothBtn" type="Button" parent="HBoxContainer"]
46+
margin_left = 448.0
47+
margin_right = 660.0
48+
margin_bottom = 92.0
49+
size_flags_horizontal = 3
50+
size_flags_vertical = 3
51+
custom_fonts/font = SubResource( 1 )
52+
text = "SMOOTH TRANSITION"
53+
54+
[node name="SimpleBtn" type="Button" parent="HBoxContainer"]
55+
margin_left = 675.0
56+
margin_right = 885.0
57+
margin_bottom = 92.0
58+
size_flags_horizontal = 3
59+
size_flags_vertical = 3
60+
custom_fonts/font = SubResource( 1 )
61+
text = "SIMPLE TRANSITION"
62+
63+
[connection signal="pressed" from="HBoxContainer/2DBtn" to="." method="_on_2DBtn_pressed"]
64+
[connection signal="pressed" from="HBoxContainer/3DBtn" to="." method="_on_3DBtn_pressed"]
65+
[connection signal="pressed" from="HBoxContainer/SmoothBtn" to="." method="_on_SmoothBtn_pressed"]
66+
[connection signal="pressed" from="HBoxContainer/SimpleBtn" to="." method="_on_SimpleBtn_pressed"]

0 commit comments

Comments
 (0)