Add bones list to digit and improve properties

This commit is contained in:
rodolpheh 2023-11-16 21:52:33 +00:00
parent 1dc4d054a6
commit 4ae392a7db
6 changed files with 63 additions and 17 deletions

View File

@ -33,6 +33,8 @@ void UltraleapDigit::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_is_extended"), &UltraleapDigit::get_is_extended);
ClassDB::bind_method(D_METHOD("set_is_extended", "is_extended"), &UltraleapDigit::set_is_extended);
ClassDB::bind_method(D_METHOD("get_bones"), &UltraleapDigit::get_bones);
ClassDB::add_property(
"UltraleapDigit",
PropertyInfo(
@ -102,6 +104,19 @@ void UltraleapDigit::_bind_methods() {
"set_is_extended",
"get_is_extended"
);
ClassDB::add_property(
"UltraleapDigit",
PropertyInfo(
Variant::ARRAY,
"bones",
PROPERTY_HINT_ARRAY_TYPE,
"UltraleapBone",
PROPERTY_USAGE_READ_ONLY | PROPERTY_USAGE_EDITOR
),
"",
"get_bones"
);
}
void UltraleapDigit::fill_digit_data(Ref<UltraleapDigit> ul_digit, LEAP_DIGIT* digit, FingerType type) {

View File

@ -2,7 +2,7 @@
#define ULTRALEAP_DIGIT_H
#include <godot_cpp/classes/global_constants.hpp>
#include <godot_cpp/classes/ref.hpp>
#include <godot_cpp/core/binder_common.hpp>
#include <godot_cpp/core/object.hpp>
@ -53,6 +53,19 @@ public:
bool get_is_extended() { return is_extended; }
void set_is_extended(bool value) { is_extended = value; }
Array get_bones() {
if (bones == Variant::NIL) {
bones = Array();
}
if (bones.size() == 0) {
bones.append(metacarpal_ref);
bones.append(proximal_ref);
bones.append(intermediate_ref);
bones.append(distal_ref);
}
return bones;
}
static void fill_digit_data(Ref<UltraleapDigit> ul_digit, LEAP_DIGIT* digit, FingerType type);
protected:
static void _bind_methods();
@ -62,6 +75,7 @@ private:
Ref<UltraleapBone> proximal_ref;
Ref<UltraleapBone> intermediate_ref;
Ref<UltraleapBone> distal_ref;
Array bones;
};
VARIANT_ENUM_CAST(UltraleapDigit::FingerType);

View File

@ -53,7 +53,6 @@ void UltraleapHand::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_palm", "palm"), &UltraleapHand::set_palm);
ClassDB::bind_method(D_METHOD("get_palm"), &UltraleapHand::get_palm);
ClassDB::bind_method(D_METHOD("set_digits", "digits"), &UltraleapHand::set_digits);
ClassDB::bind_method(D_METHOD("get_digits"), &UltraleapHand::get_digits);
ClassDB::add_property(
@ -216,18 +215,16 @@ void UltraleapHand::_bind_methods() {
"UltraleapHand",
PropertyInfo(
Variant::ARRAY,
"digits"
"digits",
PROPERTY_HINT_ARRAY_TYPE,
"UltraleapDigit",
PROPERTY_USAGE_READ_ONLY | PROPERTY_USAGE_EDITOR
),
"set_digits",
"",
"get_digits"
);
};
void UltraleapHand::set_digits(Array digits) {
for (int i = 0; i < digits.size(); i++) {
}
}
void UltraleapHand::fill_hand_data(Ref<UltraleapHand> ul_hand, LEAP_HAND* hand) {
// For now we just check if the arm ref is not set
if (ul_hand->arm_ref == NULL) {

View File

@ -74,7 +74,9 @@ public:
void set_palm(Ref<UltraleapPalm> value) { palm_ref = value; }
Array get_digits() {
Array digits_array = Array();
if (digits_array == Variant::NIL) {
digits_array = Array();
}
if (digits_array.size() == 0) {
digits_array.append(thumb);
digits_array.append(index);
@ -84,7 +86,6 @@ public:
}
return digits_array;
}
void set_digits(Array digits);
static void fill_hand_data(Ref<UltraleapHand> ul_hand, LEAP_HAND* hand);
protected:
@ -93,7 +94,7 @@ protected:
private:
Ref<UltraleapBone> arm_ref;
Ref<UltraleapPalm> palm_ref;
Array digits_array = Array();
Array digits_array;
Ref<UltraleapDigit> thumb;
Ref<UltraleapDigit> index;

View File

@ -88,13 +88,13 @@ void UltraleapHandTracking::_bind_methods() {
//ClassDB::bind_method(D_METHOD("set_last_frame", "last_frame"), &UltraleapHandTracking::set_last_frame);
ClassDB::bind_method(D_METHOD("get_last_frame"), &UltraleapHandTracking::get_last_frame);
ClassDB::bind_method(D_METHOD("set_tracking_mode", "tracking_mode"), &UltraleapHandTracking::set_tracking_mode, DEFVAL(0));
ClassDB::bind_method(D_METHOD("set_tracking_mode", "tracking_mode"), &UltraleapHandTracking::set_tracking_mode);
ClassDB::bind_method(D_METHOD("get_tracking_mode"), &UltraleapHandTracking::get_tracking_mode);
ClassDB::bind_method(D_METHOD("get_left_image"), &UltraleapHandTracking::get_left_image);
ClassDB::bind_method(D_METHOD("get_right_image"), &UltraleapHandTracking::get_right_image);
ClassDB::bind_method(D_METHOD("set_devices", "devices"), &UltraleapHandTracking::set_devices);
//ClassDB::bind_method(D_METHOD("set_devices", "devices"), &UltraleapHandTracking::set_devices);
ClassDB::bind_method(D_METHOD("get_devices"), &UltraleapHandTracking::get_devices);
ClassDB::bind_method(D_METHOD("set_service_ip", "service_ip"), &UltraleapHandTracking::set_service_ip);
@ -137,19 +137,38 @@ void UltraleapHandTracking::_bind_methods() {
"get_tracking_mode"
);
ClassDB::add_property_group(
"UltraleapHandTracking",
"Devices",
"devices"
);
ClassDB::add_property(
"UltraleapHandTracking",
PropertyInfo(
Variant::ARRAY,
"devices",
"devices_list",
PROPERTY_HINT_ARRAY_TYPE,
"UltraleapDevice",
PROPERTY_USAGE_READ_ONLY | PROPERTY_USAGE_EDITOR
),
"set_devices",
"",
"get_devices"
);
ClassDB::add_property(
"UltraleapHandTracking",
PropertyInfo(
Variant::OBJECT,
"devices_primary_device",
PROPERTY_HINT_RESOURCE_TYPE,
"UltraleapDevice",
PROPERTY_USAGE_READ_ONLY | PROPERTY_USAGE_EDITOR
),
"set_primary_device",
"get_primary_device"
);
ClassDB::add_property_group(
"UltraleapHandTracking",
"Connection",

View File

@ -112,7 +112,7 @@ private:
bool opened = false; /* Indicate an opened connection */
bool connected = false; /* We have confirmed connection */
Ref<UltraleapDevice> primary_device = NULL;
Ref<UltraleapDevice> primary_device;
typedef struct {
StringName signal;
Variant arg;