2017-04-23 12:10:41 +00:00
|
|
|
/**************************************************************************/
|
2020-04-08 14:47:36 +00:00
|
|
|
/* xr_positional_tracker.h */
|
2017-04-23 12:10:41 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2020-04-08 14:47:36 +00:00
|
|
|
#ifndef XR_POSITIONAL_TRACKER_H
|
|
|
|
#define XR_POSITIONAL_TRACKER_H
|
2017-04-23 12:10:41 +00:00
|
|
|
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/os/thread_safe.h"
|
2019-02-05 10:02:13 +00:00
|
|
|
#include "scene/resources/mesh.h"
|
2021-08-29 06:05:11 +00:00
|
|
|
#include "servers/xr/xr_pose.h"
|
2024-04-13 21:26:46 +00:00
|
|
|
#include "servers/xr/xr_tracker.h"
|
2020-04-08 14:47:36 +00:00
|
|
|
#include "servers/xr_server.h"
|
2017-04-23 12:10:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The positional tracker object as an object that represents the position and orientation of a tracked object like a controller or headset.
|
|
|
|
An AR/VR Interface will registered the trackers it manages with our AR/VR server and update its position and orientation.
|
|
|
|
This is where potentially additional AR/VR interfaces may be active as there are AR/VR SDKs that solely deal with positional tracking.
|
|
|
|
*/
|
|
|
|
|
2024-04-13 21:26:46 +00:00
|
|
|
class XRPositionalTracker : public XRTracker {
|
|
|
|
GDCLASS(XRPositionalTracker, XRTracker);
|
2017-04-23 12:10:41 +00:00
|
|
|
_THREAD_SAFE_CLASS_
|
|
|
|
|
2017-09-10 06:15:11 +00:00
|
|
|
public:
|
|
|
|
enum TrackerHand {
|
|
|
|
TRACKER_HAND_UNKNOWN, /* unknown or not applicable */
|
2020-12-10 10:30:37 +00:00
|
|
|
TRACKER_HAND_LEFT, /* controller is the left hand controller */
|
2024-04-13 21:26:46 +00:00
|
|
|
TRACKER_HAND_RIGHT, /* controller is the right hand controller */
|
|
|
|
TRACKER_HAND_MAX
|
2017-09-10 06:15:11 +00:00
|
|
|
};
|
|
|
|
|
2024-04-13 21:26:46 +00:00
|
|
|
protected:
|
2022-03-05 10:09:21 +00:00
|
|
|
String profile; // this is interface dependent, for OpenXR this will be the interaction profile bound for to the tracker
|
2024-04-13 21:26:46 +00:00
|
|
|
TrackerHand tracker_hand = TRACKER_HAND_UNKNOWN; // if known, the hand this tracker is held in
|
2021-08-29 06:05:11 +00:00
|
|
|
|
2022-05-13 13:04:37 +00:00
|
|
|
HashMap<StringName, Ref<XRPose>> poses;
|
|
|
|
HashMap<StringName, Variant> inputs;
|
2021-08-29 06:05:11 +00:00
|
|
|
|
2017-04-23 12:10:41 +00:00
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2022-03-05 10:09:21 +00:00
|
|
|
void set_tracker_profile(const String &p_profile);
|
|
|
|
String get_tracker_profile() const;
|
2024-04-13 21:26:46 +00:00
|
|
|
|
2020-12-10 11:16:14 +00:00
|
|
|
XRPositionalTracker::TrackerHand get_tracker_hand() const;
|
2024-04-13 21:26:46 +00:00
|
|
|
virtual void set_tracker_hand(const XRPositionalTracker::TrackerHand p_hand);
|
2021-08-29 06:05:11 +00:00
|
|
|
|
|
|
|
bool has_pose(const StringName &p_action_name) const;
|
|
|
|
Ref<XRPose> get_pose(const StringName &p_action_name) const;
|
|
|
|
void invalidate_pose(const StringName &p_action_name);
|
2022-01-19 08:21:06 +00:00
|
|
|
void set_pose(const StringName &p_action_name, const Transform3D &p_transform, const Vector3 &p_linear_velocity, const Vector3 &p_angular_velocity, const XRPose::TrackingConfidence p_tracking_confidence = XRPose::XR_TRACKING_CONFIDENCE_HIGH);
|
2021-08-29 06:05:11 +00:00
|
|
|
|
|
|
|
Variant get_input(const StringName &p_action_name) const;
|
|
|
|
void set_input(const StringName &p_action_name, const Variant &p_value);
|
2017-04-23 12:10:41 +00:00
|
|
|
};
|
|
|
|
|
2020-04-08 14:47:36 +00:00
|
|
|
VARIANT_ENUM_CAST(XRPositionalTracker::TrackerHand);
|
2017-09-10 06:15:11 +00:00
|
|
|
|
2022-01-04 19:26:22 +00:00
|
|
|
#endif // XR_POSITIONAL_TRACKER_H
|