Skip to content

Commit a759afe

Browse files
update example
1 parent 12a0c59 commit a759afe

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

demo/example.gd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
extends Node
22

33
func _ready() -> void:
4-
print(%OrbbecDevices.get_devices_ips())
5-
%OrbbecPointCloud.set_device_from_ip("10.10.30.182")
4+
var ips = %OrbbecDevices.get_devices_ips()
5+
ips.sort()
6+
print(ips)
7+
%OrbbecPointCloud.set_device_from_ip(ips[0])
68
%OrbbecPointCloud.start_stream()

demo/example.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ script = ExtResource("1_jdh55")
1414
unique_name_in_owner = true
1515

1616
[node name="OrbbecPointCloud" type="OrbbecPointCloud" parent="."]
17+
thinning = 0.0
1718
unique_name_in_owner = true
1819

1920
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]

demo/multi_mesh_instance_3d.gd

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
extends MultiMeshInstance3D
22

33
var points: PackedVector3Array
4+
var raw_points: PackedFloat32Array
45
var redraw:bool = false
56

67
func _ready():
78
multimesh = MultiMesh.new()
89
multimesh.transform_format = MultiMesh.TRANSFORM_3D
9-
10+
1011
var pmesh := PointMesh.new()
1112
var material := StandardMaterial3D.new()
1213
material.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
@@ -19,14 +20,10 @@ func _ready():
1920
func _process(_delta):
2021
if redraw:
2122
multimesh.instance_count = len(points)
22-
# TODO: there is a way to set a whole PackedFloat32Array as the multimesh's buffer.
23-
# This may be faster than iterating and creating a transform3D.
24-
# see https://docs.godotengine.org/en/stable/classes/class_renderingserver.html#class-renderingserver-method-multimesh-set-buffer
25-
# it references rendering server but it works in gdscript too. We could even generate the packed array in C++ directly.
26-
for i in multimesh.instance_count:
27-
multimesh.set_instance_transform(i, Transform3D(Basis(), points[i]))
23+
multimesh.buffer = raw_points
2824
redraw = false
2925

30-
func _on_orbbec_point_cloud_frame(new_point_cloud_frame: PackedVector3Array) -> void:
26+
func _on_orbbec_point_cloud_frame(new_point_cloud_frame: PackedVector3Array, raw_buffer: PackedFloat32Array) -> void:
3127
points = new_point_cloud_frame
28+
raw_points = raw_buffer
3229
redraw = true

0 commit comments

Comments
 (0)