mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-25 00:30:25 +01:00
resolution independent overlays
This commit is contained in:
parent
5468ffbe63
commit
a3778bea0f
3 changed files with 48 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://addons/openvr_overlay/overlay_instance.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/godot-openvr/OpenVROverlay.gdns" type="Script" id=3]
|
||||
|
@ -11,21 +11,24 @@ border_width_right = 24
|
|||
border_width_bottom = 24
|
||||
border_color = Color( 0, 0.784314, 1, 0.611765 )
|
||||
|
||||
[sub_resource type="ViewportTexture" id=2]
|
||||
viewport_path = NodePath("OverlayViewport")
|
||||
|
||||
[node name="OverlayInstance" type="Spatial"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="OverlayViewport" type="Viewport" parent="."]
|
||||
size = Vector2( 100, 100 )
|
||||
size = Vector2( 2048, 2048 )
|
||||
transparent_bg = true
|
||||
handle_input_locally = false
|
||||
msaa = 3
|
||||
hdr = false
|
||||
disable_3d = true
|
||||
keep_3d_linear = true
|
||||
usage = 0
|
||||
render_target_update_mode = 3
|
||||
script = ExtResource( 3 )
|
||||
overlay_width_in_meters = 0.4
|
||||
shadow_atlas_quad_0 = 0
|
||||
shadow_atlas_quad_1 = 0
|
||||
shadow_atlas_quad_2 = 0
|
||||
shadow_atlas_quad_3 = 0
|
||||
|
||||
[node name="Container" type="Control" parent="OverlayViewport"]
|
||||
anchor_right = 1.0
|
||||
|
@ -37,3 +40,34 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
|
||||
[node name="VROverlayViewport" type="Viewport" parent="."]
|
||||
size = Vector2( 100, 100 )
|
||||
transparent_bg = true
|
||||
handle_input_locally = false
|
||||
msaa = 2
|
||||
hdr = false
|
||||
disable_3d = true
|
||||
usage = 0
|
||||
render_target_update_mode = 3
|
||||
shadow_atlas_quad_0 = 0
|
||||
shadow_atlas_quad_1 = 0
|
||||
shadow_atlas_quad_2 = 0
|
||||
shadow_atlas_quad_3 = 0
|
||||
script = ExtResource( 3 )
|
||||
overlay_width_in_meters = 0.4
|
||||
|
||||
[node name="AspectRatioContainer" type="AspectRatioContainer" parent="VROverlayViewport"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="VROverlayViewport/AspectRatioContainer"]
|
||||
margin_right = 100.0
|
||||
margin_bottom = 100.0
|
||||
texture = SubResource( 2 )
|
||||
expand = true
|
||||
stretch_mode = 5
|
||||
flip_v = true
|
||||
|
|
|
@ -24,7 +24,8 @@ func get_canvas_pos() -> Vector2:
|
|||
_i.tracker_nodes[_i.active_controller].translation)
|
||||
var pos = Vector2(controller_local_pos.x, controller_local_pos.y)
|
||||
|
||||
var overlay_size = OverlayInit.ovr_interface.get_render_targetsize()
|
||||
# var overlay_size = OverlayInit.ovr_interface.get_render_targetsize()
|
||||
var overlay_size = Vector2(2048, 2048)
|
||||
# scale to pixels
|
||||
pos *= overlay_size.x
|
||||
pos /= _i.get_parent().width_meters
|
||||
|
|
|
@ -38,7 +38,7 @@ func _ready() -> void:
|
|||
ARVRServer.connect("tracker_added", self, "_tracker_changed")
|
||||
ARVRServer.connect("tracker_removed", self, "_tracker_changed")
|
||||
|
||||
$OverlayViewport.size = OverlayInit.ovr_interface.get_render_targetsize()
|
||||
$VROverlayViewport.size = OverlayInit.ovr_interface.get_render_targetsize()
|
||||
set_notify_transform(true)
|
||||
|
||||
load_settings()
|
||||
|
@ -122,11 +122,11 @@ func update_offset():
|
|||
|
||||
match current_target:
|
||||
"head":
|
||||
$OverlayViewport.track_relative_to_device(0, global_transform)
|
||||
$VROverlayViewport.track_relative_to_device(0, global_transform)
|
||||
"world":
|
||||
$OverlayViewport.overlay_position_absolute(global_transform)
|
||||
$VROverlayViewport.overlay_position_absolute(global_transform)
|
||||
_:
|
||||
$OverlayViewport.track_relative_to_device(_tracker_id, global_transform)
|
||||
$VROverlayViewport.track_relative_to_device(_tracker_id, global_transform)
|
||||
|
||||
|
||||
func update_current_target():
|
||||
|
@ -142,7 +142,7 @@ func update_current_target():
|
|||
|
||||
func set_overlay_visible(state: bool):
|
||||
overlay_visible = state
|
||||
$OverlayViewport.overlay_visible = state
|
||||
$VROverlayViewport.overlay_visible = state
|
||||
Settings.s.overlays[name].visible = state
|
||||
emit_signal("overlay_visibility_changed", state)
|
||||
save_settings()
|
||||
|
@ -178,7 +178,7 @@ func set_offset(offset_target: String, pos: Vector3, rot: Quat) -> void:
|
|||
|
||||
func set_width_in_meters(width: float) -> void:
|
||||
width_meters = width
|
||||
$OverlayViewport.overlay_width_in_meters = width_meters
|
||||
$VROverlayViewport.overlay_width_in_meters = width_meters
|
||||
emit_signal("width_changed")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue