summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/arvr_nodes.cpp28
-rw-r--r--scene/3d/arvr_nodes.h7
2 files changed, 35 insertions, 0 deletions
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index 17b698c1b8..e5346c4c53 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -233,6 +233,13 @@ void ARVRController::_notification(int p_what) {
} else {
button_states = 0;
};
+
+ // check for an updated mesh
+ Ref<Mesh> trackerMesh = tracker->get_mesh();
+ if (mesh != trackerMesh) {
+ mesh = trackerMesh;
+ emit_signal("mesh_updated", mesh);
+ }
};
}; break;
default:
@@ -258,8 +265,11 @@ void ARVRController::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &ARVRController::set_rumble);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rumble", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_rumble", "get_rumble");
+ ClassDB::bind_method(D_METHOD("get_mesh"), &ARVRController::get_mesh);
+
ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::INT, "button")));
ADD_SIGNAL(MethodInfo("button_release", PropertyInfo(Variant::INT, "button")));
+ ADD_SIGNAL(MethodInfo("mesh_updated", PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh")));
};
void ARVRController::set_controller_id(int p_controller_id) {
@@ -341,6 +351,10 @@ void ARVRController::set_rumble(real_t p_rumble) {
};
};
+Ref<Mesh> ARVRController::get_mesh() const {
+ return mesh;
+}
+
bool ARVRController::get_is_active() const {
return is_active;
};
@@ -423,6 +437,13 @@ void ARVRAnchor::_notification(int p_what) {
// apply our reference frame and set our transform
set_transform(arvr_server->get_reference_frame() * transform);
+
+ // check for an updated mesh
+ Ref<Mesh> trackerMesh = tracker->get_mesh();
+ if (mesh != trackerMesh) {
+ mesh = trackerMesh;
+ emit_signal("mesh_updated", mesh);
+ }
};
}; break;
default:
@@ -441,6 +462,9 @@ void ARVRAnchor::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_size"), &ARVRAnchor::get_size);
ClassDB::bind_method(D_METHOD("get_plane"), &ARVRAnchor::get_plane);
+
+ ClassDB::bind_method(D_METHOD("get_mesh"), &ARVRAnchor::get_mesh);
+ ADD_SIGNAL(MethodInfo("mesh_updated", PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh")));
};
void ARVRAnchor::set_anchor_id(int p_anchor_id) {
@@ -501,6 +525,10 @@ Plane ARVRAnchor::get_plane() const {
return plane;
};
+Ref<Mesh> ARVRAnchor::get_mesh() const {
+ return mesh;
+}
+
ARVRAnchor::ARVRAnchor() {
anchor_id = 0;
is_active = true;
diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h
index 523bc112c1..0833e18d48 100644
--- a/scene/3d/arvr_nodes.h
+++ b/scene/3d/arvr_nodes.h
@@ -33,6 +33,7 @@
#include "scene/3d/camera.h"
#include "scene/3d/spatial.h"
+#include "scene/resources/mesh.h"
#include "servers/arvr/arvr_positional_tracker.h"
/**
@@ -75,6 +76,7 @@ private:
int controller_id;
bool is_active;
int button_states;
+ Ref<Mesh> mesh;
protected:
void _notification(int p_what);
@@ -95,6 +97,8 @@ public:
bool get_is_active() const;
ARVRPositionalTracker::TrackerHand get_hand() const;
+ Ref<Mesh> get_mesh(void) const;
+
String get_configuration_warning() const;
ARVRController();
@@ -113,6 +117,7 @@ private:
int anchor_id;
bool is_active;
Vector3 size;
+ Ref<Mesh> mesh;
protected:
void _notification(int p_what);
@@ -128,6 +133,8 @@ public:
Plane get_plane() const;
+ Ref<Mesh> get_mesh(void) const;
+
String get_configuration_warning() const;
ARVRAnchor();