Merge pull request #23 from Nitwel/testing

Add basic wall setup
This commit is contained in:
Nitwel 2023-11-18 18:54:45 +01:00 committed by GitHub
commit 17d8f77d78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 369 additions and 38 deletions

10
.drone.yml Normal file
View File

@ -0,0 +1,10 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: greeting
image: golang:1.12
commands:
- ls

2
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,2 @@
github: [Nitwel]
custom: ["https://paypal.me/nitwel"]

74
Dockerfile Normal file
View File

@ -0,0 +1,74 @@
# Barichello godot CI image, modified to work with Godot 4.
FROM ubuntu:kinetic
LABEL author="https://github.com/aBARICHELLO/godot-ci/graphs/contributors"
USER root
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
git \
git-lfs \
python3 \
python3-openssl \
unzip \
wget \
zip \
adb \
openjdk-11-jdk-headless \
rsync \
# Added for https://github.com/godotengine/godot/issues/55317 - remove to shrink binaries later.
libxcursor-dev \
libxinerama-dev \
libxrandr-dev \
libxi6 \
libgl1 \
# End Bugfix Extras
&& rm -rf /var/lib/apt/lists/*
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
RUN wget -P /opt/butler/ https://gitlab.com/barichello/godot-ci/-/raw/master/getbutler.sh
RUN bash /opt/butler/getbutler.sh
RUN /opt/butler/bin/butler -V
ENV PATH="/opt/butler/bin:${PATH}"
# Download and setup android-sdk
ENV ANDROID_HOME="/usr/lib/android-sdk"
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip \
&& unzip commandlinetools-linux-*_latest.zip -d cmdline-tools \
&& mv cmdline-tools $ANDROID_HOME/ \
&& rm -f commandlinetools-linux-*_latest.zip
ENV PATH="${ANDROID_HOME}/cmdline-tools/cmdline-tools/bin:${PATH}"
RUN yes | sdkmanager --licenses \
&& sdkmanager "platform-tools" "build-tools;30.0.3" "platforms;android-29" "cmdline-tools;latest" "cmake;3.10.2.4988404" "ndk;21.4.7075529"
# Adding android keystore and settings
RUN keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 \
&& mv debug.keystore /root/debug.keystore
ARG GODOT_VERSION="4.1.3"
ARG RELEASE_NAME="stable"
RUN wget https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-${RELEASE_NAME}_export_templates.tpz
RUN wget https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-${RELEASE_NAME}_linux.x86_64.zip
RUN mkdir ~/.cache \
&& mkdir -p ~/.config/godot \
&& mkdir -p ~/.local/share/godot/export_templates/${GODOT_VERSION}.${RELEASE_NAME} \
&& unzip Godot_v${GODOT_VERSION}-${RELEASE_NAME}_linux.x86_64.zip \
&& mv Godot_v${GODOT_VERSION}-${RELEASE_NAME}_linux.x86_64 /usr/local/bin/godot \
&& unzip Godot_v${GODOT_VERSION}-${RELEASE_NAME}_export_templates.tpz \
&& mv templates/* ~/.local/share/godot/export_templates/${GODOT_VERSION}.${RELEASE_NAME} \
&& rm -f Godot_v${GODOT_VERSION}-${RELEASE_NAME}_export_templates.tpz Godot_v${GODOT_VERSION}-${RELEASE_NAME}_linux.x86_64.zip
RUN godot -e --quit --display-driver headless
RUN echo 'export/android/android_sdk_path = "/usr/lib/android-sdk"' >> ~/.config/godot/editor_settings-4.tres
RUN echo 'export/android/debug_keystore = "/root/debug.keystore"' >> ~/.config/godot/editor_settings-4.tres
RUN echo 'export/android/debug_keystore_user = "androiddebugkey"' >> ~/.config/godot/editor_settings-4.tres
RUN echo 'export/android/debug_keystore_pass = "android"' >> ~/.config/godot/editor_settings-4.tres
RUN echo 'export/android/force_system_user = false' >> ~/.config/godot/editor_settings-4.tres
RUN echo 'export/android/timestamping_authority_url = ""' >> ~/.config/godot/editor_settings-4.tres
RUN echo 'export/android/shutdown_adb_on_exit = true' >> ~/.config/godot/editor_settings-4.tres

View File

@ -33,7 +33,7 @@ script = ExtResource("1_uvrd4")
[node name="XROrigin3D" type="XROrigin3D" parent="."]
[node name="XRCamera3D" type="XRCamera3D" parent="XROrigin3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.798091, 0.311748)
transform = Transform3D(1, 2.47971e-10, 3.49246e-10, 9.47986e-12, 1, 2.08834e-08, 0, 4.54747e-13, 1, -7.27596e-12, 0.798091, 0.311748)
[node name="XRControllerLeft" type="XRController3D" parent="XROrigin3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.469893, 0.597213, -0.251112)
@ -59,12 +59,12 @@ script = ExtResource("1_tsqxc")
ray = NodePath("RayCast3D")
[node name="RayCast3D" type="RayCast3D" parent="XROrigin3D/XRControllerRight/Raycast"]
transform = Transform3D(-2.58078e-11, 4.3714e-08, 1, 1, -4.37117e-08, 9.27469e-12, 4.37112e-08, 1, -4.3714e-08, 0, 0, 0)
transform = Transform3D(-4.62364e-10, 4.3714e-08, 0.999998, 0.999999, -4.37194e-08, 9.2768e-12, 4.37103e-08, 0.999999, -4.3714e-08, -0.000467122, 0.00228411, -0.0016689)
target_position = Vector3(0, -5, 0)
[node name="Decal" type="Decal" parent="XROrigin3D/XRControllerRight/Raycast"]
transform = Transform3D(0.999999, -0.000567105, -2.5179e-05, -2.51789e-05, 4.39886e-08, -0.999999, 0.000567105, 1, 2.97064e-08, -0.000775784, -1.09076e-05, -2.46767)
size = Vector3(0.02, 5, 0.02)
size = Vector3(0.02, 4.91995, 0.02)
texture_albedo = ExtResource("4_wcfej")
upper_fade = 0.000985425
lower_fade = 0.000919435
@ -84,3 +84,4 @@ xr_origin = NodePath("../XROrigin3D")
[node name="House" parent="." instance=ExtResource("8_qkrg7")]
transform = Transform3D(0.404247, 0.000180645, 0.914648, 0.00017221, 0.999999, -0.000273614, -0.914648, 0.00026812, 0.404247, -0.343479, 0.000110551, 1.91547)
visible = false

View File

@ -94,6 +94,7 @@ func _call_fn(collider: Object, fn_name: String, node: Node3D = null, event = nu
if result != null && result is Dictionary:
result.merge(event, true)
event = result
if result != null && result is bool && result == false:
# Stop the event from bubbling up

View File

@ -10,7 +10,9 @@ transform = Transform3D(1, -1.39637e-11, 0, 9.47975e-12, 1, 0, 0, 0, 1, 0, 0, 0)
[node name="scene" parent="." instance=ExtResource("1_mu2l0")]
transform = Transform3D(0.01, 7.86411e-14, 0, -2.05335e-13, 0.01, 7.10543e-15, 0, 0, 0.01, 0, 0, 0)
visible = false
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(0.999999, -0.000592284, 0.000541925, -0.000592284, -1, -7.3062e-08, 0.000541926, -2.47913e-07, -0.999999, 2.38683, 1.18178, -1.05161)
visible = false
mesh = SubResource("PlaneMesh_b3o5e")

View File

@ -3,6 +3,7 @@ class_name Button3D
@export var toggleable: bool = false
@export var disabled: bool = false
@export var initial_active: bool = false
var active: bool = false :
set(value):
print("set active", value)
@ -16,16 +17,15 @@ var active: bool = false :
animation_player.play("down")
else:
animation_player.play_backwards("down")
get:
return active
return active
@onready var animation_player: AnimationPlayer = $AnimationPlayer
func _ready():
if initial_active:
active = true
func _on_click(_event):
if disabled:
return false

View File

@ -13,6 +13,31 @@ size = Vector3(0.05, 0.02, 0.05)
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_o4j7g"]
points = PackedVector3Array(-0.025, -0.01, -0.025, -0.025, 0.01, -0.025, 0.025, -0.01, -0.025, -0.025, -0.01, 0.025, -0.025, 0.01, 0.025, 0.025, 0.01, -0.025, 0.025, -0.01, 0.025, 0.025, 0.01, 0.025)
[sub_resource type="Animation" id="Animation_gvfrg"]
length = 0.001
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position:y")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("MeshInstance3D:position:y")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
[sub_resource type="Animation" id="Animation_iu2ed"]
resource_name = "down"
length = 0.2
@ -50,31 +75,6 @@ tracks/2/keys = {
"times": PackedFloat32Array(0, 0.2)
}
[sub_resource type="Animation" id="Animation_gvfrg"]
length = 0.001
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position:y")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("MeshInstance3D:position:y")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_sbgno"]
_data = {
"RESET": SubResource("Animation_gvfrg"),

View File

@ -4,6 +4,7 @@ extends Node3D
@onready var nav_edit: Button3D = $Navigation/Edit
@onready var menu_edit: Node3D = $Content/EditMenu
@onready var nav_room = $Navigation/Room
@onready var menu_room: Node3D = $Content/RoomMenu
@onready var nav_automate = $Navigation/Automate
@onready var nav_settings = $Navigation/Settings
@ -36,13 +37,16 @@ func select_menu(menu: Menu):
selected_menu = menu
for child in $Content.get_children():
if child.is_visible():
child.hide()
$Content.remove_child(child)
var menu_node = enum_to_menu(menu)
var nav_node = enum_to_nav(menu)
if nav_node != null:
nav_node.disabled = true
if menu_node != null:
menu_node.show()
$Content.add_child(menu_node)
for child in $Navigation.get_children():
if child.active && child != nav_node:
@ -69,7 +73,7 @@ func enum_to_menu(menu: Menu):
Menu.EDIT:
return menu_edit
Menu.ROOM:
return null
return menu_room
Menu.AUTOMATE:
return null
Menu.SETTINGS:

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://c3kdssrmv84kv"]
[gd_scene load_steps=12 format=3 uid="uid://c3kdssrmv84kv"]
[ext_resource type="Script" path="res://content/ui/menu/menu.gd" id="1_ng4u3"]
[ext_resource type="PackedScene" uid="uid://crrb0l3ekuotj" path="res://content/ui/menu/edit/edit_menu.tscn" id="4_r2raj"]
@ -9,6 +9,7 @@
[ext_resource type="Texture2D" uid="uid://jodf3dm654j3" path="res://assets/icons/view_in_ar_white_24dp.svg" id="7_wvovx"]
[ext_resource type="Texture2D" uid="uid://dch6rwihrl3i2" path="res://assets/icons/schema_white_24dp.svg" id="8_3d082"]
[ext_resource type="Texture2D" uid="uid://dyh0ax51xqp8n" path="res://assets/icons/settings_white_24dp.svg" id="9_mel13"]
[ext_resource type="PackedScene" uid="uid://c01gkeldvjwtr" path="res://content/ui/menu/room/room_menu.tscn" id="10_u4i1x"]
[sub_resource type="BoxMesh" id="BoxMesh_08du6"]
size = Vector3(0.3, 0.01, 0.3)
@ -22,6 +23,7 @@ mesh = SubResource("BoxMesh_08du6")
[node name="ImmersiveHomePanels" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-10, 0, 0.01, 0, 0.01, 0, -0.01, 0, -4.37114e-10, 0.32, 0, -0.0500001)
visible = false
mesh = ExtResource("7_f4u4o")
[node name="Navigation" type="Node3D" parent="."]
@ -39,6 +41,7 @@ texture = ExtResource("5_8o1rb")
[node name="Edit" parent="Navigation" instance=ExtResource("5_w4i01")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0, 0.09)
toggleable = true
initial_active = true
[node name="Sprite3D" type="Sprite3D" parent="Navigation/Edit"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.012, 0)
@ -79,3 +82,5 @@ texture = ExtResource("9_mel13")
[node name="Content" type="Node3D" parent="."]
[node name="EditMenu" parent="Content" instance=ExtResource("4_r2raj")]
[node name="RoomMenu" parent="Content" instance=ExtResource("10_u4i1x")]

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:77753eec248c2d0593cfa5e5a86aa8be8ee13c5f96680226d8428f732f5f2098
size 150

View File

@ -0,0 +1,136 @@
extends Node3D
const wall_corner_scene = preload("res://content/ui/menu/room/wall_corner.tscn")
const wall_edge_scene = preload("res://content/ui/menu/room/wall_edge.tscn")
@onready var teleport_root = $TeleportRoot
@onready var wall_corners = $TeleportRoot/WallCorners
@onready var wall_edges = $TeleportRoot/WallEdges
@onready var wall_mesh = $TeleportRoot/WallMesh
@onready var toggle_edit_button = $Interface/ToggleEdit
var moving = null
var ground_plane = Plane(Vector3.UP, Vector3.ZERO)
var edit_enabled = false
func _ready():
remove_child(teleport_root)
get_tree().get_root().get_node("Main").add_child.call_deferred(teleport_root)
teleport_root.get_node("Ground/Clickable").on_click.connect(func(event):
if !edit_enabled:
return
add_corner(event.ray.get_collision_point())
)
toggle_edit_button.get_node("Clickable").on_click.connect(func(event):
edit_enabled = event.active
if edit_enabled == false:
wall_corners.visible = false
wall_edges.visible = false
generate_mesh()
wall_mesh.visible = true
else:
wall_corners.visible = true
wall_edges.visible = true
wall_mesh.visible = false
)
func generate_mesh():
var st = SurfaceTool.new()
var wall_up = Vector3.UP * 3
st.begin(Mesh.PRIMITIVE_TRIANGLE_STRIP)
for i in range(wall_corners.get_child_count()):
var corner = get_corner(i)
print(corner.position, " ", corner.position + wall_up)
st.add_vertex(corner.position)
st.add_vertex(corner.position + wall_up)
var first_corner = get_corner(0)
st.add_vertex(first_corner.position)
st.add_vertex(first_corner.position + wall_up)
st.index()
st.generate_normals()
st.generate_tangents()
var mesh = st.commit()
wall_mesh.mesh = mesh
func add_corner(position: Vector3):
var corner = wall_corner_scene.instantiate()
corner.position = position
corner.get_node("Clickable").on_grab_down.connect(func(event):
if !edit_enabled:
return
moving = event.target
)
corner.get_node("Clickable").on_grab_move.connect(func(event):
if moving == null:
return
var direction = (event.ray.to_global(event.ray.target_position) - event.ray.global_position).normalized()
var new_position = ground_plane.intersects_ray(event.ray.global_position, direction)
if new_position == null:
return
moving.position = new_position
var moving_index = moving.get_index()
get_edge(moving_index).transform = corners_to_edge_transform(new_position, get_corner(moving_index + 1).position)
get_edge(moving_index - 1).transform = corners_to_edge_transform(get_corner(moving_index - 1).position, new_position)
)
corner.get_node("Clickable").on_grab_up.connect(func(_event):
moving = null
)
wall_corners.add_child(corner)
var num_corners = wall_corners.get_child_count()
var edge
if num_corners > 1:
edge = add_edge(wall_corners.get_child(num_corners - 2).position, position)
if num_corners > 2:
if num_corners != wall_edges.get_child_count():
add_edge(position, wall_corners.get_child(0).position)
else:
wall_edges.move_child(edge, num_corners - 2)
get_edge(-1).transform = corners_to_edge_transform(position, get_corner(0).position)
func get_corner(index: int) -> MeshInstance3D:
return wall_corners.get_child(index % wall_corners.get_child_count())
func get_edge(index: int) -> MeshInstance3D:
return wall_edges.get_child(index % wall_edges.get_child_count())
func add_edge(from_pos: Vector3, to_pos: Vector3):
var edge: MeshInstance3D = wall_edge_scene.instantiate()
edge.transform = corners_to_edge_transform(from_pos, to_pos)
wall_edges.add_child(edge)
return edge
func corners_to_edge_transform(from_pos: Vector3, to_pos: Vector3) -> Transform3D:
var diff = to_pos - from_pos
var direction = diff.normalized()
var edge_position = from_pos + diff / 2
var edge_basis = Basis(Vector3.UP, diff, direction.cross(Vector3.UP))
var edge_transform = Transform3D(edge_basis, edge_position)
return edge_transform

View File

@ -0,0 +1,53 @@
[gd_scene load_steps=8 format=3 uid="uid://c01gkeldvjwtr"]
[ext_resource type="Script" path="res://content/ui/menu/room/room_menu.gd" id="1_ch4jb"]
[ext_resource type="Script" path="res://content/functions/clickable.gd" id="2_elugy"]
[ext_resource type="Material" uid="uid://bbx6fv7jq50tr" path="res://content/ui/menu/room/walls.tres" id="3_fke3j"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="3_whl7a"]
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_08sv0"]
[sub_resource type="ArrayMesh" id="ArrayMesh_7dibq"]
[sub_resource type="BoxMesh" id="BoxMesh_e37nn"]
size = Vector3(0.3, 0.01, 0.3)
[node name="RoomMenu" type="Node3D"]
script = ExtResource("1_ch4jb")
[node name="TeleportRoot" type="Node3D" parent="."]
[node name="Ground" type="StaticBody3D" parent="TeleportRoot"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="TeleportRoot/Ground"]
shape = SubResource("WorldBoundaryShape3D_08sv0")
[node name="Clickable" type="Node" parent="TeleportRoot/Ground"]
script = ExtResource("2_elugy")
[node name="WallCorners" type="Node3D" parent="TeleportRoot"]
[node name="WallEdges" type="Node3D" parent="TeleportRoot"]
[node name="WallMesh" type="MeshInstance3D" parent="TeleportRoot"]
material_override = ExtResource("3_fke3j")
mesh = SubResource("ArrayMesh_7dibq")
[node name="Background" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.15, 0, 0.15)
mesh = SubResource("BoxMesh_e37nn")
[node name="Interface" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.01, 0)
[node name="ToggleEdit" parent="Interface" instance=ExtResource("3_whl7a")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.05, 0, 0.05)
toggleable = true
[node name="Clickable" type="Node" parent="Interface/ToggleEdit"]
script = ExtResource("2_elugy")
[node name="Label3D" type="Label3D" parent="Interface"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.17, -1.86265e-09, 0.05)
pixel_size = 0.001
text = "Edit Room"

View File

@ -0,0 +1,26 @@
[gd_scene load_steps=5 format=3 uid="uid://eht83kc5wtiw"]
[ext_resource type="Script" path="res://content/functions/clickable.gd" id="1_e5awq"]
[sub_resource type="SphereShape3D" id="SphereShape3D_86rci"]
radius = 0.05
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_i1w3w"]
transparency = 1
albedo_color = Color(1, 1, 1, 0.270588)
[sub_resource type="SphereMesh" id="SphereMesh_7586u"]
material = SubResource("StandardMaterial3D_i1w3w")
radius = 0.05
height = 0.1
[node name="WallCorner" type="StaticBody3D"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_86rci")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("SphereMesh_7586u")
[node name="Clickable" type="Node" parent="."]
script = ExtResource("1_e5awq")

View File

@ -0,0 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://cfcabpcbp577o"]
[ext_resource type="Material" uid="uid://j12e5wwthtaa" path="res://content/ui/menu/room/edge.tres" id="1_b21dw"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_a2dct"]
material = ExtResource("1_b21dw")
radius = 0.01
height = 1.0
[node name="MeshInstance3D" type="MeshInstance3D"]
mesh = SubResource("CapsuleMesh_a2dct")

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a84837d131d1a1676286c56bc80fc1dde59dc234ca68dc089b86d19c2aefc5a7
size 101