Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48fd30c668 | ||
|
|
808e1503fb | ||
|
|
eeb35efa18 | ||
|
|
2da0429cdd | ||
|
|
f3440af264 |
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
# Portals Demo
|
||||||
|
|
||||||
|
Git repos
|
||||||
|
|
||||||
|
- Gitea: https://git.vojtechstruhar.com/Vojta/dp-konzultace
|
||||||
|
- GitHub (mirror): https://github.com/VojtaStruhar/dp-konzultace
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
extends EditorNode3DGizmoPlugin
|
||||||
|
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
print("[gizmo] _init")
|
||||||
|
create_material("main", Color(1,0,1), false, true, false)
|
||||||
|
create_material("secondary", Color(1,0,0))
|
||||||
|
|
||||||
|
|
||||||
|
func _get_gizmo_name() -> String:
|
||||||
|
return "PortalGizmo"
|
||||||
|
|
||||||
|
|
||||||
|
func _has_gizmo(for_node_3d: Node3D) -> bool:
|
||||||
|
var result: bool = for_node_3d is Portal
|
||||||
|
if result: print("[gizmo] _has_gizmo: " + for_node_3d.name)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
func _redraw(gizmo):
|
||||||
|
var portal = gizmo.get_node_3d() as Portal
|
||||||
|
print("[gizmo] _redraw: " + portal.name)
|
||||||
|
|
||||||
|
gizmo.clear() # Always clear the gizmo
|
||||||
|
|
||||||
|
if portal not in EditorInterface.get_selection().get_selected_nodes():
|
||||||
|
return # If not selected, don't draw anything
|
||||||
|
|
||||||
|
|
||||||
|
var lines = PackedVector3Array()
|
||||||
|
|
||||||
|
|
||||||
|
if portal.exit_portal != null:
|
||||||
|
print("[gizmo] Drawing the bezier")
|
||||||
|
# Draw a bezier curve connecting the two portals
|
||||||
|
var exit = portal.exit_portal
|
||||||
|
var D = portal.global_position.distance_to(exit.global_position)
|
||||||
|
|
||||||
|
var p0 = Vector3.ZERO
|
||||||
|
var p3 = portal.to_local(exit.global_position)
|
||||||
|
var p1 = p0 + -portal.transform.basis.z * D * 0.25 # Control point
|
||||||
|
var p2 = p3 + -exit.transform.basis.z * D * 0.25 # Control point
|
||||||
|
|
||||||
|
var RESOLUTION: int = 24
|
||||||
|
|
||||||
|
lines.push_back(p0)
|
||||||
|
|
||||||
|
for i in range(1, RESOLUTION + 1):
|
||||||
|
var t: float = float(i) / RESOLUTION
|
||||||
|
var spline_pos: Vector3 = pow(1 - t, 3) * p0 \
|
||||||
|
+ 3 * pow(1 - t, 2) * t * p1 \
|
||||||
|
+ 3 * (1 - t) * pow(t, 2) * p2 \
|
||||||
|
+ pow(t, 3) * p3
|
||||||
|
|
||||||
|
lines.push_back(spline_pos)
|
||||||
|
|
||||||
|
lines.push_back(p3)
|
||||||
|
print("[gizmo] Bezier lines: " + str(lines.size()))
|
||||||
|
|
||||||
|
gizmo.add_lines(PackedVector3Array([p0, p3, p1, p2]), get_material("secondary", gizmo))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#var handles = PackedVector3Array()
|
||||||
|
#handles.push_back(Vector3(0, 1, 0))
|
||||||
|
#handles.push_back(Vector3(0, 2, 0))
|
||||||
|
|
||||||
|
gizmo.add_lines(lines, get_material("main", gizmo))
|
||||||
|
# Thicker dashed line
|
||||||
|
var l2 = lines.duplicate()
|
||||||
|
for i in range(l2.size()): l2[i].x += 0.01
|
||||||
|
gizmo.add_lines(l2, get_material("main", gizmo))
|
||||||
|
|
||||||
|
#gizmo.add_handles(handles, get_material("handles", gizmo), [])
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://b8vlwx31bxx4b
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[plugin]
|
||||||
|
|
||||||
|
name="Portal Gizmos"
|
||||||
|
description="Plugin providing 3D Gizmos for portals"
|
||||||
|
author="Vojtech Struhar"
|
||||||
|
version="0.1"
|
||||||
|
script="portal_gizmos.gd"
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
@tool
|
||||||
|
extends EditorPlugin
|
||||||
|
|
||||||
|
const GIZMO_PACKED = preload("gizmo.gd")
|
||||||
|
var gizmo = GIZMO_PACKED.new()
|
||||||
|
|
||||||
|
func _enter_tree() -> void:
|
||||||
|
print("[portal_gizmos] Enter")
|
||||||
|
add_node_3d_gizmo_plugin(gizmo)
|
||||||
|
|
||||||
|
func _exit_tree() -> void:
|
||||||
|
print("[portal_gizmos] Exit")
|
||||||
|
remove_node_3d_gizmo_plugin(gizmo)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://c61kmx68labq0
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=13 format=3 uid="uid://27pb62xwsqd8"]
|
[gd_scene load_steps=12 format=3 uid="uid://27pb62xwsqd8"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://b5x7fmpwck335" path="res://hud.tscn" id="1_mmt1i"]
|
[ext_resource type="PackedScene" uid="uid://b5x7fmpwck335" path="res://hud.tscn" id="1_mmt1i"]
|
||||||
[ext_resource type="MeshLibrary" uid="uid://bedqgubx1g1uf" path="res://prototypes.tres" id="2_vdsn8"]
|
[ext_resource type="MeshLibrary" uid="uid://bedqgubx1g1uf" path="res://prototypes.tres" id="2_vdsn8"]
|
||||||
@@ -25,9 +25,6 @@ glow_enabled = true
|
|||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_cgnft"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_cgnft"]
|
||||||
size = Vector3(2, 2, 0.5)
|
size = Vector3(2, 2, 0.5)
|
||||||
|
|
||||||
[sub_resource type="ViewportTexture" id="ViewportTexture_mmt1i"]
|
|
||||||
viewport_path = NodePath("SubViewport")
|
|
||||||
|
|
||||||
[node name="level_3rooms" type="Node3D"]
|
[node name="level_3rooms" type="Node3D"]
|
||||||
|
|
||||||
[node name="HUD" parent="." instance=ExtResource("1_mmt1i")]
|
[node name="HUD" parent="." instance=ExtResource("1_mmt1i")]
|
||||||
@@ -107,20 +104,3 @@ omni_range = 4.0
|
|||||||
[node name="PortalEnvironmentAdapter" type="Node" parent="." node_paths=PackedStringArray("base")]
|
[node name="PortalEnvironmentAdapter" type="Node" parent="." node_paths=PackedStringArray("base")]
|
||||||
script = ExtResource("7_2gewm")
|
script = ExtResource("7_2gewm")
|
||||||
base = NodePath("../WorldEnvironment")
|
base = NodePath("../WorldEnvironment")
|
||||||
|
|
||||||
[node name="Window" type="Window" parent="."]
|
|
||||||
title = "Scene overview"
|
|
||||||
initial_position = 3
|
|
||||||
size = Vector2i(1920, 1080)
|
|
||||||
current_screen = 1
|
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="Window"]
|
|
||||||
offset_right = 40.0
|
|
||||||
offset_bottom = 40.0
|
|
||||||
texture = SubResource("ViewportTexture_mmt1i")
|
|
||||||
|
|
||||||
[node name="SubViewport" type="SubViewport" parent="."]
|
|
||||||
size = Vector2i(1920, 1080)
|
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="SubViewport"]
|
|
||||||
transform = Transform3D(-0.69337, -0.493312, 0.525244, 0, 0.728917, 0.684602, -0.720582, 0.474683, -0.505409, 2.78382, 9.04787, -3.54716)
|
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
[gd_scene load_steps=11 format=3 uid="uid://dfp37ydmk0iqd"]
|
||||||
|
|
||||||
|
[ext_resource type="Material" uid="uid://dm157s57mfhfe" path="res://addons/kenney_prototype_tools/materials/dark/material_02.tres" id="1_7g3li"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c1r8mgwbekvi6" path="res://models/cube-wireframe.glb" id="2_k5v63"]
|
||||||
|
[ext_resource type="ArrayMesh" uid="uid://bqilnvlfws6xh" path="res://portal-mesh.tres" id="3_xriuu"]
|
||||||
|
[ext_resource type="Script" uid="uid://d2bvvjsibau8c" path="res://addons/simple-portal-system/scripts/portal.gd" id="4_b1ttb"]
|
||||||
|
[ext_resource type="Script" uid="uid://bkv7t4hw21byg" path="res://addons/simple-portal-system/scripts/simple_portal_teleport.gd" id="5_r7ouk"]
|
||||||
|
|
||||||
|
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_gkglg"]
|
||||||
|
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
|
||||||
|
ground_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
|
||||||
|
|
||||||
|
[sub_resource type="Sky" id="Sky_7g3li"]
|
||||||
|
sky_material = SubResource("ProceduralSkyMaterial_gkglg")
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id="Environment_k5v63"]
|
||||||
|
background_mode = 2
|
||||||
|
sky = SubResource("Sky_7g3li")
|
||||||
|
tonemap_mode = 2
|
||||||
|
glow_enabled = true
|
||||||
|
|
||||||
|
[sub_resource type="BoxMesh" id="BoxMesh_gkglg"]
|
||||||
|
size = Vector3(40, 1, 40)
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_wgwtu"]
|
||||||
|
size = Vector3(2, 2, 0.5)
|
||||||
|
|
||||||
|
[node name="Hypercube" type="Node3D"]
|
||||||
|
|
||||||
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
|
transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0)
|
||||||
|
shadow_enabled = true
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
|
environment = SubResource("Environment_k5v63")
|
||||||
|
|
||||||
|
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D"]
|
||||||
|
material_override = ExtResource("1_7g3li")
|
||||||
|
mesh = SubResource("BoxMesh_gkglg")
|
||||||
|
|
||||||
|
[node name="cube-wireframe" parent="." instance=ExtResource("2_k5v63")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
|
|
||||||
|
[node name="Portal_red" type="MeshInstance3D" parent="." node_paths=PackedStringArray("exit_portal")]
|
||||||
|
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -1, 1, 0)
|
||||||
|
mesh = ExtResource("3_xriuu")
|
||||||
|
skeleton = NodePath("")
|
||||||
|
script = ExtResource("4_b1ttb")
|
||||||
|
vertical_viewport_resolution = 1080
|
||||||
|
disable_viewport_distance = 32.0
|
||||||
|
fade_out_distance_max = 30.0
|
||||||
|
fade_out_distance_min = 28.0
|
||||||
|
fade_out_color = Color(0, 0, 0, 1)
|
||||||
|
exit_portal = NodePath("")
|
||||||
|
|
||||||
|
[node name="Teleport" type="Area3D" parent="Portal_red"]
|
||||||
|
script = ExtResource("5_r7ouk")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Portal_red/Teleport"]
|
||||||
|
transform = Transform3D(1, 0, 4.72511e-13, 0, 1, 0, -4.72511e-13, 0, 1, 0, 0, -0.250244)
|
||||||
|
shape = SubResource("BoxShape3D_wgwtu")
|
||||||
Binary file not shown.
@@ -0,0 +1,37 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://c1r8mgwbekvi6"
|
||||||
|
path="res://.godot/imported/cube-wireframe.glb-967ab7c5c0b5cb7833d30e3afe2cbbe7.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://models/cube-wireframe.glb"
|
||||||
|
dest_files=["res://.godot/imported/cube-wireframe.glb-967ab7c5c0b5cb7833d30e3afe2cbbe7.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=1
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
@@ -16,3 +16,4 @@ func _ready() -> void:
|
|||||||
for p in get_tree().get_nodes_in_group("portals"):
|
for p in get_tree().get_nodes_in_group("portals"):
|
||||||
if p is Portal:
|
if p is Portal:
|
||||||
p.exit_environment = adapted_env
|
p.exit_environment = adapted_env
|
||||||
|
|
||||||
+4
-1
@@ -19,7 +19,10 @@ config/icon="res://icon.svg"
|
|||||||
|
|
||||||
window/size/viewport_width=1920
|
window/size/viewport_width=1920
|
||||||
window/size/viewport_height=1080
|
window/size/viewport_height=1080
|
||||||
window/subwindows/embed_subwindows=false
|
|
||||||
|
[editor_plugins]
|
||||||
|
|
||||||
|
enabled=PackedStringArray("res://addons/portal_gizmos/plugin.cfg")
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user