Path: blob/master/servers/xr/xr_positional_tracker.h
10277 views
/**************************************************************************/1/* xr_positional_tracker.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 "core/os/thread_safe.h"33#include "servers/xr/xr_pose.h"34#include "servers/xr/xr_tracker.h"35#include "servers/xr_server.h"3637/**38The positional tracker object as an object that represents the position and orientation of a tracked object like a controller or headset.39An AR/VR Interface will registered the trackers it manages with our AR/VR server and update its position and orientation.40This is where potentially additional AR/VR interfaces may be active as there are AR/VR SDKs that solely deal with positional tracking.41*/4243class XRPositionalTracker : public XRTracker {44GDCLASS(XRPositionalTracker, XRTracker);45_THREAD_SAFE_CLASS_4647public:48enum TrackerHand {49TRACKER_HAND_UNKNOWN, /* unknown or not applicable */50TRACKER_HAND_LEFT, /* controller is the left hand controller */51TRACKER_HAND_RIGHT, /* controller is the right hand controller */52TRACKER_HAND_MAX53};5455protected:56String profile; // this is interface dependent, for OpenXR this will be the interaction profile bound for to the tracker57TrackerHand tracker_hand = TRACKER_HAND_UNKNOWN; // if known, the hand this tracker is held in5859HashMap<StringName, Ref<XRPose>> poses;60HashMap<StringName, Variant> inputs;6162static void _bind_methods();6364public:65void set_tracker_profile(const String &p_profile);66String get_tracker_profile() const;6768XRPositionalTracker::TrackerHand get_tracker_hand() const;69virtual void set_tracker_hand(const XRPositionalTracker::TrackerHand p_hand);7071bool has_pose(const StringName &p_action_name) const;72Ref<XRPose> get_pose(const StringName &p_action_name) const;73void invalidate_pose(const StringName &p_action_name);74void 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);7576Variant get_input(const StringName &p_action_name) const;77void set_input(const StringName &p_action_name, const Variant &p_value);78};7980VARIANT_ENUM_CAST(XRPositionalTracker::TrackerHand);818283