add more structure
This commit is contained in:
parent
a4d0e8f33b
commit
36c7517cb8
6 changed files with 26 additions and 28 deletions
Binary file not shown.
|
@ -11,6 +11,7 @@ size = Vector2(6, 2)
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="."]
|
[node name="Camera3D" type="Camera3D" parent="."]
|
||||||
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0.355791, -1.59348)
|
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0.355791, -1.59348)
|
||||||
|
current = true
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
transform = Transform3D(-0.878275, 0.266876, -0.396749, -7.71365e-11, 0.829749, 0.558137, 0.478155, 0.490197, -0.728748, 0, 0.631436, 0)
|
transform = Transform3D(-0.878275, 0.266876, -0.396749, -7.71365e-11, 0.829749, 0.558137, 0.478155, 0.490197, -0.728748, 0, 0.631436, 0)
|
||||||
|
@ -38,8 +39,9 @@ tracker_name = "RB2"
|
||||||
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0)
|
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0)
|
||||||
|
|
||||||
[node name="Floor" type="MeshInstance3D" parent="Root"]
|
[node name="Floor" type="MeshInstance3D" parent="Root"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.704947, 0)
|
||||||
mesh = SubResource("PlaneMesh_24d08")
|
mesh = SubResource("PlaneMesh_24d08")
|
||||||
|
|
||||||
[node name="Wall" type="MeshInstance3D" parent="Root"]
|
[node name="Wall" type="MeshInstance3D" parent="Root"]
|
||||||
transform = Transform3D(-1, 8.74228e-08, -3.82137e-15, 0, -4.37114e-08, -1, -8.74228e-08, -1, 4.37114e-08, 0, 0.93633, 1.06259)
|
transform = Transform3D(-1, 8.74228e-08, -3.82137e-15, 0, -4.37114e-08, -1, -8.74228e-08, -1, 4.37114e-08, 0, 0.268571, 1.06259)
|
||||||
mesh = SubResource("PlaneMesh_24d08")
|
mesh = SubResource("PlaneMesh_24d08")
|
||||||
|
|
|
@ -10,10 +10,10 @@ size = Vector2(6, 2)
|
||||||
[node name="Node3D" type="Node3D"]
|
[node name="Node3D" type="Node3D"]
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="."]
|
[node name="Camera3D" type="Camera3D" parent="."]
|
||||||
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0.355791, -1.59348)
|
transform = Transform3D(1, 0, -1.74846e-07, 0, 1, 0, 1.74846e-07, 0, 1, 0, 0.933082, 2.80616)
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
transform = Transform3D(-0.878275, 0.266876, -0.396749, -7.71365e-11, 0.829749, 0.558137, 0.478155, 0.490197, -0.728748, 0, 0.631436, 0)
|
transform = Transform3D(-0.999686, -0.0139775, 0.0207795, 0.0125216, 0.439603, 0.898105, -0.021688, 0.898083, -0.43929, 0, 1.59521, 0)
|
||||||
shadow_enabled = true
|
shadow_enabled = true
|
||||||
|
|
||||||
[node name="Root" type="Node3D" parent="."]
|
[node name="Root" type="Node3D" parent="."]
|
||||||
|
@ -25,10 +25,6 @@ tracker_receivers = [NodePath("../SpinTracker/Offset0/Tracker0"), NodePath("../S
|
||||||
[node name="Floor" type="MeshInstance3D" parent="Root"]
|
[node name="Floor" type="MeshInstance3D" parent="Root"]
|
||||||
mesh = SubResource("PlaneMesh_24d08")
|
mesh = SubResource("PlaneMesh_24d08")
|
||||||
|
|
||||||
[node name="Wall" type="MeshInstance3D" parent="Root"]
|
|
||||||
transform = Transform3D(-1, 8.74228e-08, -3.82137e-15, 0, -4.37114e-08, -1, -8.74228e-08, -1, 4.37114e-08, 0, 0.93633, 1.06259)
|
|
||||||
mesh = SubResource("PlaneMesh_24d08")
|
|
||||||
|
|
||||||
[node name="SpinTracker" type="Node3D" parent="Root"]
|
[node name="SpinTracker" type="Node3D" parent="Root"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.764802, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.764802, 0)
|
||||||
|
|
||||||
|
@ -45,7 +41,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.759683, 0)
|
||||||
text = "Y-Axis"
|
text = "Y-Axis"
|
||||||
|
|
||||||
[node name="Offset2" type="Node3D" parent="Root/SpinTracker"]
|
[node name="Offset2" type="Node3D" parent="Root/SpinTracker"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 0)
|
||||||
|
|
||||||
[node name="Tracker2" type="Node3D" parent="Root/SpinTracker/Offset2"]
|
[node name="Tracker2" type="Node3D" parent="Root/SpinTracker/Offset2"]
|
||||||
script = ExtResource("2_170dk")
|
script = ExtResource("2_170dk")
|
||||||
|
@ -60,7 +56,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.764205, 0)
|
||||||
text = "Z-Axis"
|
text = "Z-Axis"
|
||||||
|
|
||||||
[node name="Offset0" type="Node3D" parent="Root/SpinTracker"]
|
[node name="Offset0" type="Node3D" parent="Root/SpinTracker"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0, 0)
|
||||||
|
|
||||||
[node name="Tracker0" type="Node3D" parent="Root/SpinTracker/Offset0"]
|
[node name="Tracker0" type="Node3D" parent="Root/SpinTracker/Offset0"]
|
||||||
script = ExtResource("2_170dk")
|
script = ExtResource("2_170dk")
|
||||||
|
|
|
@ -16,7 +16,7 @@ var messages : Dictionary[int,String] = {}
|
||||||
signal connected(s:StreamPeerTCP)
|
signal connected(s:StreamPeerTCP)
|
||||||
signal data(data:Array)
|
signal data(data:Array)
|
||||||
signal disconnected
|
signal disconnected
|
||||||
signal error
|
signal error(msg:String)
|
||||||
|
|
||||||
|
|
||||||
@onready var _stream: StreamPeerTCP = StreamPeerTCP.new()
|
@onready var _stream: StreamPeerTCP = StreamPeerTCP.new()
|
||||||
|
@ -40,45 +40,44 @@ func _ready() -> void:
|
||||||
error.connect(self._on_error)
|
error.connect(self._on_error)
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
|
# store old state
|
||||||
var old_status = _stream.get_status()
|
var old_status = _stream.get_status()
|
||||||
|
# poll
|
||||||
_stream.poll()
|
_stream.poll()
|
||||||
|
# receive all errors
|
||||||
var new_status = _stream.get_status()
|
var new_status = _stream.get_status()
|
||||||
|
# process if something changed
|
||||||
if old_status != new_status:
|
if old_status != new_status:
|
||||||
match new_status:
|
match new_status:
|
||||||
_stream.STATUS_NONE:
|
_stream.STATUS_NONE:
|
||||||
emit_signal("disconnected")
|
emit_signal("disconnected")
|
||||||
_stream.STATUS_CONNECTING:
|
_stream.STATUS_CONNECTING:
|
||||||
print("Connecting.")
|
pass
|
||||||
_stream.STATUS_CONNECTED:
|
_stream.STATUS_CONNECTED:
|
||||||
print("Connected.")
|
|
||||||
_stream.poll()
|
|
||||||
emit_signal("connected",_stream)
|
emit_signal("connected",_stream)
|
||||||
_stream.STATUS_ERROR:
|
_stream.STATUS_ERROR:
|
||||||
print("Error with socket stream.")
|
emit_signal("error","error with socket stream from {0}:{1}".format([_stream.get_connected_host(),_stream.get_connected_port()]))
|
||||||
emit_signal("error")
|
|
||||||
|
|
||||||
if new_status == _stream.STATUS_CONNECTED:
|
if new_status == _stream.STATUS_CONNECTED:
|
||||||
var available_bytes: int = _stream.get_available_bytes()
|
var available_bytes: int = _stream.get_available_bytes()
|
||||||
if available_bytes > 0:
|
if available_bytes > 0:
|
||||||
var res = _stream.get_partial_data(available_bytes)
|
var res = _stream.get_partial_data(available_bytes)
|
||||||
if res[0] != OK:
|
if res[0] != OK:
|
||||||
emit_signal("error")
|
emit_signal("error","error receiving data {0}".format([res[0]]))
|
||||||
else:
|
else:
|
||||||
emit_signal("data", res[1])
|
emit_signal("data", res[1])
|
||||||
|
|
||||||
func connect_to_host(host: String, port: int) -> void:
|
func connect_to_host(host: String, port: int) -> void:
|
||||||
print("Connecting to %s:%d" % [host, port])
|
|
||||||
if _stream.connect_to_host(host, port) != OK:
|
if _stream.connect_to_host(host, port) != OK:
|
||||||
print("Error connecting to host.")
|
emit_signal("error","error connecting to host '{0}:{1}'".format([host,port]))
|
||||||
emit_signal("error")
|
|
||||||
|
|
||||||
func send(data: PackedByteArray) -> bool:
|
func send(data: PackedByteArray) -> bool:
|
||||||
if _stream.get_status() != _stream.STATUS_CONNECTED:
|
if _stream.get_status() != _stream.STATUS_CONNECTED:
|
||||||
print("Error: Stream is not currently connected.")
|
emit_signal("error","stream not connected!")
|
||||||
return false
|
return false
|
||||||
var error: int = _stream.put_data(data)
|
var res: int = _stream.put_data(data)
|
||||||
if error != OK:
|
if res != OK:
|
||||||
print("Error writing to stream: ", error)
|
emit_signal("error","error writing to stream {0}!".format([res]))
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
@ -99,10 +98,10 @@ func _on_connected(s : StreamPeerTCP):
|
||||||
print("Connected to",s.get_connected_host()) # Replace with function body.
|
print("Connected to",s.get_connected_host()) # Replace with function body.
|
||||||
|
|
||||||
func _on_disconnected():
|
func _on_disconnected():
|
||||||
print("Disconnected") # Replace with function body.
|
push_warning("Disconnected") # Replace with function body.
|
||||||
|
|
||||||
func _on_error():
|
func _on_error(msg:String):
|
||||||
print("Error") # Replace with function body.
|
push_warning(msg) # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
static func marshall_block(data : PackedByteArray,session : VRPN) -> void:
|
static func marshall_block(data : PackedByteArray,session : VRPN) -> void:
|
||||||
|
@ -122,7 +121,7 @@ static func marshall_block(data : PackedByteArray,session : VRPN) -> void:
|
||||||
var length := header.get_32() as int # length of message
|
var length := header.get_32() as int # length of message
|
||||||
var time_sec := header.get_32() as int # datetime sec
|
var time_sec := header.get_32() as int # datetime sec
|
||||||
var time_msec := header.get_32() as int # datetime micro sec
|
var time_msec := header.get_32() as int # datetime micro sec
|
||||||
var sender_id := header.get_32() as int # sender id
|
var sender_id := header.get_32() as int # sender id (tracker or interfaces)
|
||||||
var message_type := header.get_32() as int # type of message (payload)
|
var message_type := header.get_32() as int # type of message (payload)
|
||||||
var sequence_num := header.get_32() as int # inofficial sequence number (padding)
|
var sequence_num := header.get_32() as int # inofficial sequence number (padding)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ class_name VRPN_Receiver
|
||||||
@export var tracker_use_position : bool = true
|
@export var tracker_use_position : bool = true
|
||||||
@export var tracker_use_rotation : bool = true
|
@export var tracker_use_rotation : bool = true
|
||||||
|
|
||||||
|
|
||||||
func _on_pos_quat(tracker_data : Dictionary):
|
func _on_pos_quat(tracker_data : Dictionary):
|
||||||
|
|
||||||
if tracker_data['tracker'] == tracker_name and tracker_data['sensor'] == tracker_sensor:
|
if tracker_data['tracker'] == tracker_name and tracker_data['sensor'] == tracker_sensor:
|
||||||
|
|
|
@ -68,7 +68,7 @@ vrpn_Tracker_Spin Tracker2 1 200.0 0.0 0.0 1.0 0.3
|
||||||
# int number_of_buttons
|
# int number_of_buttons
|
||||||
# float rate_at_which_the_buttons_toggle (transitions/second)
|
# float rate_at_which_the_buttons_toggle (transitions/second)
|
||||||
|
|
||||||
#vrpn_Button_Example Button0 2 2.0
|
vrpn_Button_Example Button0 2 2.0
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Example Dial server. This is a "device" that reports constant rotations for
|
# Example Dial server. This is a "device" that reports constant rotations for
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue