Skip to content
This repository was archived by the owner on Jan 21, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions OQ_Toolkit/OQ_ARVRController/Q_recog_tracked_obj_dev.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[gd_scene load_steps=11 format=2]

[ext_resource path="res://OQ_Toolkit/OQ_ARVRController/scripts/tracked_obj_dev.gd" type="Script" id=1]
[ext_resource path="res://OQ_Toolkit/OQ_UI2D/OQ_UI2DLabel.tscn" type="PackedScene" id=3]
[ext_resource path="res://OQ_Toolkit/OQ_UI2D/OQ_UI2DCanvas.tscn" type="PackedScene" id=4]
[ext_resource path="res://OQ_Toolkit/OQ_Helpers/OQ_VisibilityToggle.tscn" type="PackedScene" id=5]

[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.027451, 0.298039, 0, 1 )

[sub_resource type="StyleBoxFlat" id=2]
bg_color = Color( 0.0470588, 0.756863, 0.00784314, 1 )

[sub_resource type="StyleBoxFlat" id=3]
bg_color = Color( 0.380392, 0, 0, 1 )

[sub_resource type="StyleBoxFlat" id=4]
bg_color = Color( 1, 0, 0, 1 )

[sub_resource type="StyleBoxFlat" id=5]
bg_color = Color( 0, 0.0980392, 0.32549, 1 )

[sub_resource type="StyleBoxFlat" id=6]
bg_color = Color( 0.0196078, 0, 0.745098, 1 )

[node name="Q_recog_tracked_dev" type="Position3D"]
script = ExtResource( 1 )

[node name="OQ_VisibilityToggle" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.675199, 0, 0, 0, 0.647651, 0.190897, 0, -0.190897, 0.647652, 0, 0.176689, -0.0791197 )

[node name="OQ_UI2DCanvas" parent="OQ_VisibilityToggle" instance=ExtResource( 4 )]
editor_live_update = true
transparent = true

[node name="Control" type="ReferenceRect" parent="OQ_VisibilityToggle/OQ_UI2DCanvas"]
margin_right = 240.0
margin_bottom = 135.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="add" type="Button" parent="OQ_VisibilityToggle/OQ_UI2DCanvas/Control"]
anchor_right = 0.375
anchor_bottom = 0.32
margin_right = -3.05176e-05
margin_bottom = -3.05176e-05
custom_styles/hover = SubResource( 1 )
custom_styles/normal = SubResource( 2 )
text = "ADD"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="delete" type="Button" parent="OQ_VisibilityToggle/OQ_UI2DCanvas/Control"]
anchor_left = 0.625
anchor_right = 1.003
anchor_bottom = 0.32
margin_left = 6.10352e-05
margin_right = -0.0720215
margin_bottom = -4.57764e-05
custom_styles/hover = SubResource( 3 )
custom_styles/normal = SubResource( 4 )
text = "DELETE"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="cancel" type="Button" parent="OQ_VisibilityToggle/OQ_UI2DCanvas/Control"]
anchor_left = 0.375
anchor_right = 0.625
anchor_bottom = 0.32
margin_left = -3.05176e-05
margin_bottom = -1.52588e-05
custom_styles/hover = SubResource( 5 )
custom_styles/normal = SubResource( 6 )
text = "CANCEL"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="OQ_UILabel" parent="OQ_VisibilityToggle" instance=ExtResource( 3 )]
transform = Transform( 1, 0, 5.96046e-08, 0, 1, -1.19209e-07, 0, 2.98023e-08, 1, -0.0621135, -0.0274144, 7.45058e-09 )
text = "state"
font_size_multiplier = 0.5
background_color = Color( 0, 0, 0, 0 )
transparent = true

[node name="OQ_UILabel2" parent="OQ_VisibilityToggle" instance=ExtResource( 3 )]
transform = Transform( 1, 0, 1.19209e-07, 0, 1, -5.96046e-08, 0, 2.98023e-08, 1, 0.0576556, -0.0274144, 7.45058e-09 )
text = "result"
font_size_multiplier = 0.5
background_color = Color( 0, 0, 0, 0 )
transparent = true
[connection signal="pressed" from="OQ_VisibilityToggle/OQ_UI2DCanvas/Control/add" to="." method="_on_add_pressed"]
[connection signal="pressed" from="OQ_VisibilityToggle/OQ_UI2DCanvas/Control/delete" to="." method="_on_delete_pressed"]
[connection signal="pressed" from="OQ_VisibilityToggle/OQ_UI2DCanvas/Control/cancel" to="." method="_on_cancel_pressed"]
21 changes: 21 additions & 0 deletions OQ_Toolkit/OQ_ARVRController/Q_recog_tracked_obj_game.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://OQ_Toolkit/OQ_ARVRController/scripts/tracked_obj_game.gd" type="Script" id=3]

[sub_resource type="SphereMesh" id=1]
radius = 0.01
height = 0.02

[sub_resource type="SpatialMaterial" id=2]
emission_enabled = true
emission = Color( 1, 0, 0, 1 )
emission_energy = 1.0
emission_operator = 0
emission_on_uv2 = false

[node name="Q_recog_tracked_game" type="Position3D"]
script = ExtResource( 3 )

[node name="MeshInstance" type="MeshInstance" parent="."]
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
64 changes: 64 additions & 0 deletions OQ_Toolkit/OQ_ARVRController/scripts/action_manager.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
extends Node

var actions_list = {"template_1":funcref(self,"action_a"),
"template_2":funcref(self,"action_b"),
"template_3":funcref(self,"action_c")}
# this is the actions list , _key_ is the name of the action ,
# which can be set in dev mode , needs to be manually set here later , names must match
# the _value_ is a reference to a function by name ,
var projectile = []
# preload associated projectiles in projectile list as per function order
var action_stack=[["null",0]]

func recognise_action(result,controller):
if result[0]!="no match":
action_stack.push_back([result[0],controller])
# vr.log_info("stack is "+str(action_stack) +" "+ str(action_stack.size()))
vr.log_info("recognize action")
for i in range(1,action_stack.size()):
if action_stack[i][0] == action_stack[i-1][0] and action_stack[i][1]+action_stack[i-1][1] == 3:
execute_action(action_stack[i])
# vr.log_info("combination")
# vr.log_info("stack is "+str(action_stack))
# vr.log_info("found same name " + str(action_stack[i][0]) + " with controllers " + str(action_stack[i][1]) +" and "+str(action_stack[i+1][1]))
# vr.log_info("popping")
action_stack.pop_back()
action_stack.pop_back()
# vr.log_info("popped")
# vr.log_info(" left "+str(action_stack))
else:
if action_stack[i][1] == vr.leftController.controller_id:
# vr.log_info("single left")
# vr.log_info("stack is "+str(action_stack))
execute_action(action_stack[i])
# vr.log_info("popping")
action_stack.pop_back()
# vr.log_info(" left "+str(action_stack))
# vr.log_info("popped")
elif action_stack[i][1] == vr.rightController.controller_id:
# vr.log_info("single right")
# vr.log_info("stack is "+str(action_stack))
execute_action(action_stack[i])
# vr.log_info("popping")
action_stack.pop_back()
# vr.log_info(" left "+str(action_stack))
# vr.log_info("popped")

func execute_action(action):
if !actions_list.empty():
if actions_list.has(str(action[0])):
actions_list[str(action[0])].call_func(action[1])
# calls relevant action , by finding name and passes contoller id / ids
else:
vr.log_info("actions list or projectiles is empty")


func action_a(controller):
vr.log_info("template 1")
pass
func action_b(controller):
vr.log_info("template 2")
pass
func action_c(controller):
vr.log_info("template 3")
pass
Loading