Compare commits

..

25 Commits

Author SHA1 Message Date
Nitwel
fd8d624437
Merge pull request #171 from Nitwel/imp2
Some checks failed
Validate with hassfest / validate (push) Has been cancelled
HACS Action / HACS Action (push) Has been cancelled
Add door meshes, improve entity settings, disable hand when holding controllers
2024-05-30 14:43:03 +02:00
Nitwel
111a7c2558 properly disable hands on controllers 2024-05-30 14:37:30 +02:00
Nitwel
ad9245a922 fix camera 2024-05-29 22:48:01 +02:00
Nitwel
4a4d359773 add media player settings 2024-05-29 18:26:31 +02:00
Nitwel
85ebcd3edd change mesh resolution 2024-05-29 18:01:49 +02:00
Nitwel
cd38985510 generate mesh for doors 2024-05-29 17:58:46 +02:00
Nitwel
f3e2d2e9ff disable minimap lighting and wait for vertex-lighting feature 2024-05-29 10:18:31 +02:00
Nitwel
0fee21ccdb add lights to mini view 2024-05-28 19:03:40 +02:00
Nitwel
cfbd73bb21
Merge pull request #170 from Nitwel/imp2
Allow for using joystick to move objects towards/away
2024-05-28 18:37:21 +02:00
Nitwel
f9a4d8ad6b also allow for rotation 2024-05-28 18:36:13 +02:00
Nitwel
9aacf22850
Merge pull request #169 from Nitwel/imp2
Add Report a Bug button
2024-05-28 15:50:40 +02:00
Nitwel
6d49a74359
Merge pull request #167 from Nitwel/imp2
add linux binaries for godot openxrvendors
2024-05-28 11:58:12 +02:00
Nitwel
48c0a84242
Merge pull request #166 from Nitwel/imp2
Add settings for camera and line_chart
2024-05-27 18:26:42 +02:00
Nitwel
cd96865711
Merge pull request #163 from Nitwel/imp2
Add ambient occlusion shader to mini view
2024-05-27 11:21:49 +02:00
Nitwel
231f64f4f5
Merge pull request #160 from Nitwel/imp2
Add basic room importing (Quest), fix delete button, add entity settings and color_wheel component
2024-05-26 16:35:11 +02:00
Nitwel
2d049c6109 sort manifest 2024-05-25 13:57:45 +02:00
Nitwel
5f414434d8
Merge pull request #158 from Nitwel/imp2
Add Grid dot system
2024-05-23 14:19:00 +02:00
Nitwel
39bf59d78f
Merge pull request #157 from Nitwel/imp2
Add Mipmaps for text, improve and restructure code, upgrade to Godot 4.3
2024-05-22 18:40:28 +02:00
Nitwel
2dcc9e546d rename folders 2024-05-19 12:59:45 +02:00
Nitwel
5f4b128231 add hacs workflows 2024-05-19 12:44:06 +02:00
Nitwel
93e36f8f28 update hacs and manifest.json 2024-05-19 12:34:18 +02:00
Nitwel
a433fc0845 add hacs file 2024-05-19 11:58:44 +02:00
Nitwel
a824bb3f0b
Merge pull request #152 from Nitwel/imp2
Improve cursor and add cursor themes
2024-05-10 13:16:46 +02:00
Nitwel
ccebdb5209
Merge pull request #151 from Nitwel/imp2
Fix dot, graph, history and improve camera
2024-05-10 13:15:52 +02:00
Nitwel
875424b413
Merge pull request #149 from Nitwel/imp2
Update to Godot 4.3, add Sound Effects, fix bugs
2024-05-09 18:27:36 +02:00
37 changed files with 642 additions and 62 deletions

14
.github/workflows/hassfest.yml vendored Normal file
View File

@ -0,0 +1,14 @@
name: Validate with hassfest
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
validate:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "home-assistant/actions/hassfest@master"

17
.github/workflows/validate-hacs.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: HACS Action
on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
jobs:
hacs:
name: HACS Action
runs-on: "ubuntu-latest"
steps:
- name: HACS Action
uses: "hacs/action@main"
with:
category: "integration"

View File

@ -5,7 +5,7 @@ const Entity = preload ("../entity.gd")
@export var view_width = 0.15
@onready var view = $View
@onready var http_request = $HTTPRequest
@onready var http_request: HTTPRequest = $HTTPRequest
@onready var mesh = $MeshInstance3D
@onready var refresh_timer = $RefreshTimer
@onready var settings = $Settings
@ -33,6 +33,7 @@ func _ready():
)
R.effect(func(_arg):
print("Cam active: ", cam_active.value)
if cam_active.value:
refresh_timer.start()
else:
@ -69,6 +70,10 @@ func set_state(stateInfo):
refresh_timer.timeout.connect(load_image.bind(url))
func load_image(url: String):
if http_request.get_http_client_status() != HTTPClient.STATUS_DISCONNECTED:
print("HTTP client is busy, skipping")
return
http_request.request("http://192.168.33.33:8123" + url)
var result = await http_request.request_completed
@ -115,6 +120,8 @@ func load_image(url: String):
view.pixel_size = pixel_size
mesh.visible = false
print("Loaded image: ", url)
func get_options():
return {
"cam_active": cam_active.value,

View File

@ -7,7 +7,7 @@
[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="4_t8xp5"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="5_opf0y"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_smnuk"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ikxbe"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("2_wwobq")
@ -22,7 +22,7 @@ shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02
[sub_resource type="QuadMesh" id="QuadMesh_jill0"]
[sub_resource type="QuadMesh" id="QuadMesh_qfg01"]
size = Vector2(0.3, 0.2)
[sub_resource type="BoxShape3D" id="BoxShape3D_ctomk"]
@ -34,8 +34,8 @@ collision_mask = 0
script = ExtResource("1_1ixy6")
[node name="Panel" parent="." instance=ExtResource("1_myvk1")]
material_override = SubResource("ShaderMaterial_smnuk")
mesh = SubResource("QuadMesh_jill0")
material_override = SubResource("ShaderMaterial_ikxbe")
mesh = SubResource("QuadMesh_qfg01")
skeleton = NodePath("../..")
size = Vector2(0.3, 0.2)
@ -82,6 +82,7 @@ horizontal_alignment = 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.06, -0.01, 0)
label = "videocam_off"
icon = true
toggleable = true
[node name="FPSLabel" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, -0.05, 0)

View File

@ -6,7 +6,7 @@
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="3_2gpr3"]
[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="4_upyp3"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_t0vpw"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_00j7x"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("2_m4moa")
@ -21,7 +21,7 @@ shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02
[sub_resource type="QuadMesh" id="QuadMesh_s453u"]
[sub_resource type="QuadMesh" id="QuadMesh_3236q"]
size = Vector2(0.3, 0.25)
[sub_resource type="BoxShape3D" id="BoxShape3D_bu024"]
@ -34,8 +34,8 @@ script = ExtResource("1_gw2gi")
[node name="Panel" parent="." instance=ExtResource("1_78ups")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -7.45058e-09, 0)
material_override = SubResource("ShaderMaterial_t0vpw")
mesh = SubResource("QuadMesh_s453u")
material_override = SubResource("ShaderMaterial_00j7x")
mesh = SubResource("QuadMesh_3236q")
skeleton = NodePath("../..")
size = Vector2(0.3, 0.25)

View File

@ -7,7 +7,7 @@
[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="5_ecnnd"]
[ext_resource type="PackedScene" uid="uid://wgnowarejk5y" path="res://content/ui/components/select/select.tscn" id="6_egqee"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_3ewpv"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_pqb3y"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("3_vjmg5")
@ -22,7 +22,7 @@ shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02
[sub_resource type="QuadMesh" id="QuadMesh_t2fh8"]
[sub_resource type="QuadMesh" id="QuadMesh_b6qk4"]
size = Vector2(0.3, 0.2)
[sub_resource type="BoxShape3D" id="BoxShape3D_53oq0"]
@ -34,8 +34,8 @@ collision_mask = 0
script = ExtResource("1_xxfkt")
[node name="Panel" parent="." instance=ExtResource("2_4g761")]
material_override = SubResource("ShaderMaterial_3ewpv")
mesh = SubResource("QuadMesh_t2fh8")
material_override = SubResource("ShaderMaterial_pqb3y")
mesh = SubResource("QuadMesh_b6qk4")
skeleton = NodePath("../..")
size = Vector2(0.3, 0.2)

View File

@ -12,14 +12,40 @@ const Entity = preload ("../entity.gd")
@onready var artist = $PlayingInfo/Artist
@onready var http_request = $PlayingInfo/HTTPRequest
@onready var slider = $Slider
@onready var settings = $Settings
var playing = false
var volume = 50
var show_volume = R.state(true)
var show_image = R.state(true)
# Called when the node enters the scene tree for the first time.
func _ready():
super()
remove_child(settings)
R.effect(func(_arg):
if show_settings.value:
add_child(settings)
elif settings.is_inside_tree():
remove_child(settings)
camera_follower.reset()
App.house.save_all_entities()
)
R.effect(func(_arg):
if show_volume.value:
add_child(slider)
else:
remove_child(slider)
)
R.effect(func(_arg):
logo.visible=show_image.value
)
icon.value = "pause_circle"
var stateInfo = await HomeApi.get_state(entity_id)
@ -94,3 +120,13 @@ func load_image(url: String):
var texture = ImageTexture.create_from_image(image)
logo.texture = texture
logo.pixel_size = pixel_size
func get_options():
return {
"show_volume": show_volume.value,
"show_image": show_image.value
}
func set_options(options):
if options.has("show_volume"): show_volume.value = options["show_volume"]
if options.has("show_image"): show_image.value = options["show_image"]

View File

@ -1,10 +1,12 @@
[gd_scene load_steps=7 format=3 uid="uid://dyktdg7ggiwl4"]
[gd_scene load_steps=9 format=3 uid="uid://dyktdg7ggiwl4"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_8opk3"]
[ext_resource type="Script" path="res://content/entities/media_player/media_player.gd" id="1_ame17"]
[ext_resource type="Script" path="res://content/functions/camera_follower.gd" id="3_24ewx"]
[ext_resource type="Script" path="res://content/functions/movable.gd" id="3_bguto"]
[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="4_w73hw"]
[ext_resource type="FontVariation" uid="uid://sshfnckriqxn" path="res://assets/icons/icons.tres" id="5_koe28"]
[ext_resource type="PackedScene" uid="uid://cm070pgl3s7gm" path="res://content/entities/media_player/settings.tscn" id="6_iuvm7"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vi3eg"]
size = Vector3(0.23, 0.142768, 0.01)
@ -13,6 +15,14 @@ size = Vector3(0.23, 0.142768, 0.01)
collision_mask = 0
script = ExtResource("1_ame17")
[node name="Movable" type="Node" parent="."]
script = ExtResource("3_bguto")
resizable = true
[node name="CameraFollower" type="Node" parent="." node_paths=PackedStringArray("focus_point")]
script = ExtResource("3_24ewx")
focus_point = NodePath("../Settings")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0364514, -0.01)
shape = SubResource("BoxShape3D_vi3eg")
@ -56,10 +66,6 @@ pixel_size = 0.001
[node name="HTTPRequest" type="HTTPRequest" parent="PlayingInfo"]
[node name="Movable" type="Node" parent="."]
script = ExtResource("3_bguto")
resizable = true
[node name="Slider" parent="." instance=ExtResource("4_w73hw")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0562844, 0)
max = 100.0
@ -74,3 +80,6 @@ text = "volume_up"
font = ExtResource("5_koe28")
font_size = 18
outline_size = 4
[node name="Settings" parent="." instance=ExtResource("6_iuvm7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.27, 0, 0)

View File

@ -0,0 +1,30 @@
extends StaticBody3D
const MediaPlayer = preload ("./media_player.gd")
@onready var close_button: Button3D = $Close
@onready var id_input: Input3D = $IDInput
@onready var volume_button: Button3D = $VolumeButton
@onready var image_button: Button3D = $ImageButton
var media_player: MediaPlayer
func _ready():
media_player = get_parent()
close_button.on_button_up.connect(func():
media_player.show_settings.value=false
)
id_input.text = media_player.entity_id
R.effect(func(_arg):
volume_button.label="check" if media_player.show_volume.value else "close"
)
R.effect(func(_arg):
image_button.label="check" if media_player.show_image.value else "close"
)
R.bind(volume_button, "active", media_player.show_volume, volume_button.on_toggled)
R.bind(image_button, "active", media_player.show_image, image_button.on_toggled)

View File

@ -0,0 +1,102 @@
[gd_scene load_steps=9 format=3 uid="uid://cm070pgl3s7gm"]
[ext_resource type="Script" path="res://content/entities/media_player/settings.gd" id="1_03bil"]
[ext_resource type="PackedScene" uid="uid://dnam3fe36gg62" path="res://content/ui/components/panel/panel.tscn" id="2_kt6qc"]
[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_abcrk"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="4_u2igx"]
[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="5_1jm5m"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ncmoa"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("3_abcrk")
shader_parameter/color = Color(1, 1, 1, 0.3)
shader_parameter/border_color = Color(1, 1, 1, 1)
shader_parameter/edge_color = Color(0, 0, 0, 1)
shader_parameter/size = Vector2(7.5, 5)
shader_parameter/border_size = 0.01
shader_parameter/border_fade_in = 0.05
shader_parameter/border_fade_out = 0.0
shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02
[sub_resource type="QuadMesh" id="QuadMesh_qm2qb"]
size = Vector2(0.3, 0.2)
[sub_resource type="BoxShape3D" id="BoxShape3D_53oq0"]
size = Vector3(0.3, 0.2, 0.02)
[node name="Settings" type="StaticBody3D"]
script = ExtResource("1_03bil")
[node name="Panel" parent="." instance=ExtResource("2_kt6qc")]
material_override = SubResource("ShaderMaterial_ncmoa")
mesh = SubResource("QuadMesh_qm2qb")
skeleton = NodePath("../..")
size = Vector2(0.3, 0.2)
[node name="Name" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, 0.07, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "Media Player Settings"
font_size = 20
outline_size = 0
horizontal_alignment = 0
[node name="Close" parent="." instance=ExtResource("4_u2igx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.12, 0.07, 0)
label = "close"
icon = true
[node name="IDLabel" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, 0.03, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "ID:"
font_size = 18
outline_size = 0
horizontal_alignment = 0
[node name="IDInput" parent="." instance=ExtResource("5_1jm5m")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0.03, 0)
disabled = true
[node name="VideoLabel" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, -0.02, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "Show Volume:"
font_size = 18
outline_size = 0
horizontal_alignment = 0
[node name="VolumeButton" parent="." instance=ExtResource("4_u2igx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.02, 0)
label = "close"
icon = true
toggleable = true
[node name="VideoLabel2" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, -0.07, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "Show Image:"
font_size = 18
outline_size = 0
horizontal_alignment = 0
[node name="ImageButton" parent="." instance=ExtResource("4_u2igx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.07, 0)
label = "close"
icon = true
toggleable = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.01)
shape = SubResource("BoxShape3D_53oq0")

View File

@ -43,7 +43,7 @@ func _on_action_value(event: EventAction):
if event.name != "primary"||event.initiator != initiator:
return
relative_transform = relative_transform.translated(Vector3(0, 0, -event.value.y * 0.05))
relative_transform = relative_transform.translated(Vector3(0, 0, -event.value.y * 0.05)).rotated_local(Vector3(0, 1, 0), event.value.x * 0.05)
func _on_grab_down(event: EventPointer):
if disabled:

View File

@ -125,9 +125,9 @@ func _setup_hand():
auto_hand.hand_active_changed.connect(func(hand: int, active: bool):
if hand != 0: return
hand_active=active
hand_active=active&&_is_hand_simulated() == false
$IndexTip/TouchArea/CollisionShape3D.disabled=!active
$IndexTip/TouchArea/CollisionShape3D.disabled=!hand_active
hand_mesh.visible=active
)
@ -155,6 +155,17 @@ func _setup_hand():
pointer = Pointer.new(initiator, ray)
add_child(pointer)
func _is_hand_simulated():
var hand_trackers = XRServer.get_trackers(XRServer.TRACKER_HAND)
for tracker in hand_trackers.values():
if tracker.hand != XRPositionalTracker.TrackerHand.TRACKER_HAND_LEFT:
continue
return tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_CONTROLLER
return false
func _get_entity(node: Node):
if node is Entity:
return node

View File

@ -56,9 +56,9 @@ func _setup_hand():
auto_hand.hand_active_changed.connect(func(hand: int, active: bool):
if hand != 1: return
hand_active=active
hand_active=active&&_is_hand_simulated() == false
$IndexTip/TouchArea/CollisionShape3D.disabled=!active
$IndexTip/TouchArea/CollisionShape3D.disabled=!hand_active
hand_mesh.visible=active
)
@ -84,3 +84,14 @@ func _physics_process(_delta):
elif !grab_close&&grabbed:
pointer.released(Initiator.EventType.GRIP)
grabbed = false
func _is_hand_simulated():
var hand_trackers = XRServer.get_trackers(XRServer.TRACKER_HAND)
for tracker in hand_trackers.values():
if tracker.hand != XRPositionalTracker.TrackerHand.TRACKER_HAND_RIGHT:
continue
return tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_CONTROLLER
return false

View File

@ -29,6 +29,9 @@ mesh = SubResource("BoxMesh_ir3co")
[node name="AutoHandtracker" parent="." instance=ExtResource("3_pjmb2")]
visible = false
applymiddlefingerfix = null
applyscaling = null
coincidewristorknuckle = null
visiblehandtrackskeleton = false
enableautotracker = false

View File

@ -1,6 +1,7 @@
extends StaticBody3D
const Entity = preload ("res://content/entities/entity.gd")
const Light = preload ("res://content/entities/light/light.gd")
const TOUCH_LONG = 400.0
@ -9,6 +10,7 @@ const TOUCH_LONG = 400.0
@onready var collision = $CollisionShape3D
@onready var area = $Area3D/CollisionShape3D2
@onready var snap_sound = $SnapSound
# @onready var light: OmniLight3D = $OmniLight3D
@onready var label = $Label3D
var active = R.state(false)
var disabled = null
@ -17,6 +19,16 @@ var moved_ran = false
var touch_ran = false
func _ready():
# Wait until https://github.com/godotengine/godot/pull/83360 is merged for faster vertex lighting
# if entity is Light:
# R.effect(func(_arg):
# light.light_energy=1 if entity.active.value else 0
# light.light_color=entity.color.value
# )
# else:
# remove_child(light)
# light.queue_free()
R.effect(func(_arg):
label.text=entity.icon.value
label.modulate=entity.icon_color.value

View File

@ -1,6 +1,8 @@
extends Node3D
const ConstructRoomMesh = preload ("res://lib/utils/mesh/construct_room_mesh.gd")
const ConstructDoorMesh = preload ("res://lib/utils/mesh/construct_door_mesh.gd")
const RoomMaterial = preload ("res://content/system/house/room/states/room.tres")
@onready var wall_corners = $Ceiling/WallCorners
@onready var wall_edges = $Ceiling/WallEdges
@ -10,6 +12,7 @@ const ConstructRoomMesh = preload ("res://lib/utils/mesh/construct_room_mesh.gd"
@onready var room_floor = $Floor
@onready var room_ceiling = $Ceiling
@onready var doors = $Doors
@onready var state_machine: StateMachine = $StateMachine
@ -84,3 +87,29 @@ static func generate_ceiling_mesh(room: Dictionary):
var corners = room.corners
return ConstructRoomMesh.generate_ceiling_mesh(corners)
func generate_doors_mesh():
for door in Store.house.state.doors:
if door.room1 != name:
continue
var door_mesh = MeshInstance3D.new()
doors.add_child(door_mesh)
if Geometry2D.is_polygon_clockwise([
Vector2(door.room1_position1.x, door.room1_position1.z),
Vector2(door.room2_position1.x, door.room2_position1.z),
Vector2(door.room2_position2.x, door.room2_position2.z),
Vector2(door.room1_position2.x, door.room1_position2.z)
]):
door_mesh.mesh = ConstructDoorMesh.generate_door_mesh(door.room1_position2, door.room2_position2, door.room2_position1, door.room1_position1)
else:
door_mesh.mesh = ConstructDoorMesh.generate_door_mesh(door.room1_position1, door.room2_position1, door.room2_position2, door.room1_position2)
door_mesh.material_override = RoomMaterial
func clear_doors_mesh():
for door in doors.get_children():
doors.remove_child(door)
door.queue_free()

View File

@ -1,24 +1,14 @@
[gd_scene load_steps=12 format=3 uid="uid://bswgmclohuqui"]
[gd_scene load_steps=9 format=3 uid="uid://bswgmclohuqui"]
[ext_resource type="Script" path="res://content/system/house/room/room.gd" id="1_fccq0"]
[ext_resource type="Script" path="res://content/functions/clickable.gd" id="1_ugebq"]
[ext_resource type="Material" uid="uid://xehjkoeofqc" path="res://content/system/house/room/room_next.tres" id="3_4q8ik"]
[ext_resource type="Shader" path="res://content/system/house/room/room.gdshader" id="3_lwge0"]
[ext_resource type="Material" uid="uid://d0i5oae6evn08" path="res://content/system/house/room/states/room.tres" id="3_fmi1g"]
[ext_resource type="Script" path="res://lib/utils/state_machine/state_machine.gd" id="4_nbbo6"]
[ext_resource type="Script" path="res://content/system/house/room/states/view.gd" id="6_g066t"]
[ext_resource type="Script" path="res://content/system/house/room/states/edit.gd" id="7_ap14h"]
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_08sv0"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_rqpss"]
render_priority = -100
next_pass = ExtResource("3_4q8ik")
shader = ExtResource("3_lwge0")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_1hn7n"]
render_priority = -100
shader = ExtResource("3_lwge0")
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_ap613"]
plane = Plane(0, -1, 0, 0)
@ -36,10 +26,10 @@ shape = SubResource("WorldBoundaryShape3D_08sv0")
script = ExtResource("1_ugebq")
[node name="WallMesh" type="MeshInstance3D" parent="."]
material_override = SubResource("ShaderMaterial_rqpss")
material_override = ExtResource("3_fmi1g")
[node name="CeilingMesh" type="MeshInstance3D" parent="."]
material_override = SubResource("ShaderMaterial_1hn7n")
material_override = ExtResource("3_fmi1g")
[node name="WallCollision" type="StaticBody3D" parent="."]
collision_layer = 24
@ -76,4 +66,6 @@ script = ExtResource("6_g066t")
[node name="Edit" type="Node" parent="StateMachine"]
script = ExtResource("7_ap14h")
[node name="Doors" type="Node3D" parent="."]
[node name="Entities" type="Node3D" parent="."]

View File

@ -0,0 +1,9 @@
[gd_resource type="ShaderMaterial" load_steps=3 format=3 uid="uid://d0i5oae6evn08"]
[ext_resource type="Material" uid="uid://xehjkoeofqc" path="res://content/system/house/room/room_next.tres" id="1_irw15"]
[ext_resource type="Shader" path="res://content/system/house/room/room.gdshader" id="2_hhffe"]
[resource]
render_priority = -100
next_pass = ExtResource("1_irw15")
shader = ExtResource("2_hhffe")

View File

@ -30,6 +30,8 @@ func _on_enter():
wall_collisions.backface_collision = true
room.wall_collision.shape = wall_collisions
room.generate_doors_mesh()
func _on_leave():
room.room_ceiling.get_node("CollisionShape3D").disabled = true
room.room_floor.get_node("CollisionShape3D").disabled = true
@ -37,3 +39,5 @@ func _on_leave():
room.wall_collision.shape = null
room.wall_mesh.mesh = null
room.ceiling_mesh.mesh = null
room.clear_doors_mesh()

View File

@ -5,3 +5,8 @@
[resource]
render_priority = 0
shader = ExtResource("1_sbr3e")
shader_parameter/data = null
shader_parameter/data_size = null
shader_parameter/alpha = 0.3
shader_parameter/roughness = 0.85
shader_parameter/edge_color = Color(0, 0, 0, 1)

View File

@ -1,6 +1,7 @@
extends Node3D
const ConstructRoomMesh = preload ("res://lib/utils/mesh/construct_room_mesh.gd")
const ConstructDoorMesh = preload ("res://lib/utils/mesh/construct_door_mesh.gd")
const wall_material = preload ("./mini_wall.tres")
const humidity_gradient = preload ("./humid_gradient.tres")
const temperature_gradient = preload ("./temp_gradient.tres")
@ -78,6 +79,28 @@ func _ready():
walls_mesh.material_override=wall_material
floor_mesh.material_override=wall_material
walls_mesh.set_layer_mask_value(2, true)
floor_mesh.set_layer_mask_value(2, true)
for door in Store.house.state.doors:
var door_mesh=MeshInstance3D.new()
model.add_child(door_mesh)
if Geometry2D.is_polygon_clockwise([
Vector2(door.room1_position1.x, door.room1_position1.z),
Vector2(door.room2_position1.x, door.room2_position1.z),
Vector2(door.room2_position2.x, door.room2_position2.z),
Vector2(door.room1_position2.x, door.room1_position2.z)
]):
door_mesh.mesh=ConstructDoorMesh.generate_door_mesh(door.room1_position2, door.room2_position2, door.room2_position1, door.room1_position1)
else:
door_mesh.mesh=ConstructDoorMesh.generate_door_mesh(door.room1_position1, door.room2_position1, door.room2_position2, door.room1_position2)
door_mesh.material_override=wall_material
door_mesh.set_layer_mask_value(2, true)
)
# Update Size

View File

@ -0,0 +1,163 @@
## Generate a door mesh between two rooms based on their upper left and right corners
static func generate_door_mesh(room1_pos1: Vector3, room2_pos1: Vector3, room2_pos2: Vector3, room1_pos2: Vector3):
var st = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.set_custom_format(0, SurfaceTool.CUSTOM_RG_FLOAT)
var points = [room1_pos1, room2_pos1, room2_pos2, room1_pos2, Vector3(room1_pos1.x, 0, room1_pos1.z), Vector3(room2_pos1.x, 0, room2_pos1.z), Vector3(room2_pos2.x, 0, room2_pos2.z), Vector3(room1_pos2.x, 0, room1_pos2.z)]
# Add top face
add_quad(st, points, 0, 1, 2, 3)
# Add bottom face
add_quad(st, points, 5, 4, 7, 6)
# Add side faces
add_quad(st, points, 0, 4, 5, 1)
add_quad(st, points, 2, 6, 7, 3)
st.deindex()
st.generate_normals()
st.generate_tangents()
return st.commit()
static func generate_door_mesh_grid(room1_pos1: Vector3, room2_pos1: Vector3, room2_pos2: Vector3, room1_pos2: Vector3, grid:=0.1):
var st = SurfaceTool.new()
var room1_pos1_bottom = Vector3(room1_pos1.x, 0, room1_pos1.z)
var room2_pos1_bottom = Vector3(room2_pos1.x, 0, room2_pos1.z)
var room2_pos2_bottom = Vector3(room2_pos2.x, 0, room2_pos2.z)
var room1_pos2_bottom = Vector3(room1_pos2.x, 0, room1_pos2.z)
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.set_custom_format(0, SurfaceTool.CUSTOM_RG_FLOAT)
# Add top
add_quad_grid(st, room1_pos1, room1_pos2, room2_pos2, room2_pos1, false, grid)
# Add bottom
add_quad_grid(st, room1_pos1_bottom, room1_pos2_bottom, room2_pos2_bottom, room2_pos1_bottom, true, grid)
# Add side faces
add_quad_grid(st, room1_pos1, room1_pos1_bottom, room2_pos1_bottom, room2_pos1, true, grid)
add_quad_grid(st, room1_pos2, room1_pos2_bottom, room2_pos2_bottom, room2_pos2, false, grid)
st.deindex()
st.generate_normals()
st.generate_tangents()
return st.commit()
static func add_quad(st: SurfaceTool, points, index1: int, index2: int, index3: int, index4: int):
st.set_uv(Vector2(0.0, 0.0))
st.set_custom(0, Color(2.0, 2.0, 0, 0))
st.add_vertex(points[index1])
st.set_uv(Vector2(1.0, 1.0))
st.set_custom(0, Color(2.0, 2.0, 0, 0))
st.add_vertex(points[index3])
st.set_uv(Vector2(1.0, 0.0))
st.set_custom(0, Color(2.0, 2.0, 0, 0))
st.add_vertex(points[index2])
st.set_uv(Vector2(0.0, 0.0))
st.set_custom(0, Color(2.0, 2.0, 0, 0))
st.add_vertex(points[index1])
st.set_uv(Vector2(0.0, 1.0))
st.set_custom(0, Color(2.0, 2.0, 0, 0))
st.add_vertex(points[index4])
st.set_uv(Vector2(1.0, 1.0))
st.set_custom(0, Color(2.0, 2.0, 0, 0))
st.add_vertex(points[index3])
static func add_quad_grid(st: SurfaceTool, p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3, flipped: bool=false, grid:=1.0):
var d1 = (p2 - p1).normalized()
var d2 = (p4 - p1).normalized()
var n1 = d1.cross(d2).normalized()
var transform_local = Transform3D(d1, n1, d2, p1)
var lp1 = transform_local.affine_inverse() * p1
var lp2 = transform_local.affine_inverse() * p2
var lp3 = transform_local.affine_inverse() * p3
var lp4 = transform_local.affine_inverse() * p4
lp1 = Vector2(lp1.x, lp1.z)
lp2 = Vector2(lp2.x, lp2.z)
lp3 = Vector2(lp3.x, lp3.z)
lp4 = Vector2(lp4.x, lp4.z)
var points = PackedVector2Array()
# Generate edges
var edge_points = [lp1, lp2, lp3, lp4]
for i in range(4):
var delta: Vector2 = edge_points[(i + 1) % 4] - edge_points[i]
var steps = ceil(delta.length() / grid)
for j in range(steps):
var p = edge_points[i] + delta.normalized() * j * grid
points.push_back(p)
var edges = PackedInt32Array()
for k in range(points.size()):
edges.append(k)
edges.append((k + 1) % points.size())
# Generate points
var rect = Rect2()
rect = rect.expand(lp1)
rect = rect.expand(lp2)
rect = rect.expand(lp3)
rect = rect.expand(lp4)
var ls = rect.position
var ld1 = rect.size.x
var ld2 = rect.size.y
var steps = Vector2(ld1 / grid, ld2 / grid).ceil() + Vector2(2, 2)
for i in range(steps.x):
for j in range(steps.y):
var p = Vector2(i, j) * grid + ls - Vector2(0.5, 0.5) * grid
points.push_back(p)
# Triangulate
var cdt: ConstrainedTriangulation = ConstrainedTriangulation.new()
cdt.init(true, true, 0.01)
cdt.insert_vertices(points)
cdt.insert_edges(edges)
cdt.erase_outer_triangles()
points = cdt.get_all_vertices()
var triangles: PackedInt32Array = cdt.get_all_triangles()
var points3D = PackedVector3Array()
for i in range(points.size()):
var pos3D = transform_local * Vector3(points[i].x, 0, points[i].y)
points3D.push_back(pos3D)
if flipped:
for i in range(triangles.size() / 3):
var temp = triangles[i * 3]
triangles[i * 3] = triangles[i * 3 + 1]
triangles[i * 3 + 1] = temp
for i in range(triangles.size()):
st.set_uv(Vector2(0.5, 0.5))
st.set_custom(0, Color(1.0, 1.0, 0, 0))
st.add_vertex(points3D[triangles[i]])

View File

@ -138,7 +138,7 @@ static func generate_ceiling_mesh(corners):
return _create_mesh_2d(points, triangles)
static func generate_wall_mesh_with_doors_grid(corners, height, doors, grid:=0.1):
static func generate_wall_mesh_with_doors_grid(corners, height, doors, grid:=0.2):
if corners.size() < 3:
return null
@ -241,7 +241,7 @@ static func generate_wall_mesh_with_doors_grid(corners, height, doors, grid:=0.1
return mesh
static func generate_wall_mesh_grid(corners, height, grid: Vector2=Vector2(0.1, 0.1)):
static func generate_wall_mesh_grid(corners, height, grid: Vector2=Vector2(0.2, 0.2)):
if corners.size() < 3:
return null
@ -289,7 +289,7 @@ static func generate_wall_mesh_grid(corners, height, grid: Vector2=Vector2(0.1,
return mesh
static func generate_ceiling_mesh_grid(corners, grid: Vector2=Vector2(0.1, 0.1)):
static func generate_ceiling_mesh_grid(corners, grid: Vector2=Vector2(0.2, 0.2)):
var points: PackedVector2Array = PackedVector2Array()
var edges: PackedInt32Array = PackedInt32Array()
var triangles: PackedInt32Array

View File

@ -46,7 +46,8 @@ enabled=PackedStringArray("res://addons/godot-xr-tools/plugin.cfg")
folder_colors={
"res://assets/": "blue",
"res://content/": "teal",
"res://lib/": "yellow"
"res://lib/": "yellow",
"res://test/": "purple"
}
[filesystem]

View File

@ -0,0 +1,15 @@
@tool
extends Node3D
const ConstructDoorMesh = preload ("res://lib/utils/mesh/construct_door_mesh.gd")
@onready var door_mesh = $DoorMesh
@onready var door_mesh_grid = $DoorMeshGrid
@onready var room1_pos1 = $Room1Pos1
@onready var room1_pos2 = $Room1Pos2
@onready var room2_pos1 = $Room2Pos1
@onready var room2_pos2 = $Room2Pos2
func _ready():
door_mesh.mesh = ConstructDoorMesh.generate_door_mesh(room1_pos1.position, room2_pos1.position, room2_pos2.position, room1_pos2.position)
door_mesh_grid.mesh = ConstructDoorMesh.generate_door_mesh_grid(room1_pos1.position, room2_pos1.position, room2_pos2.position, room1_pos2.position)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,20 @@
{
"domain": "immersive_home",
"name": "ImmersiveHome",
"codeowners": [
"@nitwel"
],
"config_flow": true,
"dependencies": [
"http",
"websocket_api"
],
"documentation": "https://docs.immersive-home.org",
"homekit": {},
"iot_class": "local_push",
"issue_tracker": "https://github.com/Nitwel/Immersive-Home/issues",
"requirements": [],
"ssdp": [],
"version": "0.0.1",
"zeroconf": []
}

8
hacs.json Normal file
View File

@ -0,0 +1,8 @@
{
"name": "Immersive Home",
"content_in_root": false,
"zip_release": true,
"filename": "Integration.zip",
"render_readme": true,
"hide_default_branch": true
}

View File

@ -1,14 +0,0 @@
{
"domain": "immersive_home",
"name": "ImmersiveHome",
"codeowners": ["@nitwel"],
"config_flow": true,
"dependencies": ["http", "websocket_api"],
"documentation": "https://www.home-assistant.io/integrations/immersive_home",
"homekit": {},
"iot_class": "local_push",
"requirements": [],
"ssdp": [],
"zeroconf": [],
"version": "0.0.1"
}