123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- #ifndef ARVR_SERVER_H
- #define ARVR_SERVER_H
- #include "core/os/os.h"
- #include "core/os/thread_safe.h"
- #include "core/reference.h"
- #include "core/rid.h"
- #include "core/variant.h"
- class ARVRInterface;
- class ARVRPositionalTracker;
- class ARVRServer : public Object {
- GDCLASS(ARVRServer, Object);
- _THREAD_SAFE_CLASS_
- public:
- enum TrackerType {
- TRACKER_CONTROLLER = 0x01,
- TRACKER_BASESTATION = 0x02,
- TRACKER_ANCHOR = 0x04,
- TRACKER_UNKNOWN = 0x80,
- TRACKER_ANY_KNOWN = 0x7f,
- TRACKER_ANY = 0xff
- };
- enum RotationMode {
- RESET_FULL_ROTATION = 0,
- RESET_BUT_KEEP_TILT = 1,
- DONT_RESET_ROTATION = 2,
- };
- private:
- Vector<Ref<ARVRInterface> > interfaces;
- Vector<ARVRPositionalTracker *> trackers;
- Ref<ARVRInterface> primary_interface;
- real_t world_scale;
- Transform world_origin;
- Transform reference_frame;
- uint64_t last_process_usec;
- uint64_t last_commit_usec;
- uint64_t last_frame_usec;
- protected:
- static ARVRServer *singleton;
- static void _bind_methods();
- public:
- static ARVRServer *get_singleton();
-
- real_t get_world_scale() const;
- void set_world_scale(real_t p_world_scale);
-
- Transform get_world_origin() const;
- void set_world_origin(const Transform p_world_origin);
-
- Transform get_reference_frame() const;
- void center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height);
-
- Transform get_hmd_transform();
-
- void add_interface(const Ref<ARVRInterface> &p_interface);
- void remove_interface(const Ref<ARVRInterface> &p_interface);
- int get_interface_count() const;
- Ref<ARVRInterface> get_interface(int p_index) const;
- Ref<ARVRInterface> find_interface(const String &p_name) const;
- Array get_interfaces() const;
-
- Ref<ARVRInterface> get_primary_interface() const;
- void set_primary_interface(const Ref<ARVRInterface> &p_primary_interface);
- void clear_primary_interface_if(const Ref<ARVRInterface> &p_primary_interface);
-
- bool is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const;
- int get_free_tracker_id_for_type(TrackerType p_tracker_type);
- void add_tracker(ARVRPositionalTracker *p_tracker);
- void remove_tracker(ARVRPositionalTracker *p_tracker);
- int get_tracker_count() const;
- ARVRPositionalTracker *get_tracker(int p_index) const;
- ARVRPositionalTracker *find_by_type_and_id(TrackerType p_tracker_type, int p_tracker_id) const;
- uint64_t get_last_process_usec();
- uint64_t get_last_commit_usec();
- uint64_t get_last_frame_usec();
- void _process();
- void _mark_commit();
- ARVRServer();
- ~ARVRServer();
- };
- #define ARVR ARVRServer
- VARIANT_ENUM_CAST(ARVRServer::TrackerType);
- VARIANT_ENUM_CAST(ARVRServer::RotationMode);
- #endif
|