Path: blob/master/modules/openxr/scene/openxr_hand.h
10278 views
/**************************************************************************/1/* openxr_hand.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/3d/node_3d.h"33#include "scene/3d/skeleton_3d.h"3435#include <openxr/openxr.h>3637class OpenXRAPI;38class OpenXRHandTrackingExtension;3940class OpenXRHand : public Node3D {41GDCLASS(OpenXRHand, Node3D);4243public:44enum Hands { // Deprecated, need to change this to OpenXRInterface::Hands.45HAND_LEFT,46HAND_RIGHT,47HAND_MAX48};4950enum MotionRange { // Deprecated, need to change this to OpenXRInterface::HandMotionRange.51MOTION_RANGE_UNOBSTRUCTED,52MOTION_RANGE_CONFORM_TO_CONTROLLER,53MOTION_RANGE_MAX54};5556enum SkeletonRig {57SKELETON_RIG_OPENXR,58SKELETON_RIG_HUMANOID,59SKELETON_RIG_MAX60};6162enum BoneUpdate {63BONE_UPDATE_FULL,64BONE_UPDATE_ROTATION_ONLY,65BONE_UPDATE_MAX66};6768private:69struct JointData {70int bone = -1;71int parent_joint = -1;72};7374OpenXRAPI *openxr_api = nullptr;75OpenXRHandTrackingExtension *hand_tracking_ext = nullptr;7677Hands hand = HAND_LEFT;78MotionRange motion_range = MOTION_RANGE_UNOBSTRUCTED;79NodePath hand_skeleton;80SkeletonRig skeleton_rig = SKELETON_RIG_OPENXR;81BoneUpdate bone_update = BONE_UPDATE_FULL;8283JointData joints[XR_HAND_JOINT_COUNT_EXT];8485void _set_motion_range();8687Skeleton3D *get_skeleton();88void _get_joint_data();89void _update_skeleton();9091protected:92static void _bind_methods();9394public:95OpenXRHand();9697void set_hand(Hands p_hand);98Hands get_hand() const;99100void set_motion_range(MotionRange p_motion_range);101MotionRange get_motion_range() const;102103void set_hand_skeleton(const NodePath &p_hand_skeleton);104NodePath get_hand_skeleton() const;105106void set_skeleton_rig(SkeletonRig p_skeleton_rig);107SkeletonRig get_skeleton_rig() const;108109void set_bone_update(BoneUpdate p_bone_update);110BoneUpdate get_bone_update() const;111112void _notification(int p_what);113};114115VARIANT_ENUM_CAST(OpenXRHand::Hands)116VARIANT_ENUM_CAST(OpenXRHand::MotionRange)117VARIANT_ENUM_CAST(OpenXRHand::SkeletonRig)118VARIANT_ENUM_CAST(OpenXRHand::BoneUpdate)119120121