2017-04-23 12:10:41 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* arvr_nodes.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2017-04-23 12:10:41 +00:00
|
|
|
/*************************************************************************/
|
2020-01-01 10:16:22 +00:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2017-04-23 12:10:41 +00:00
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef ARVR_NODES_H
|
|
|
|
#define ARVR_NODES_H
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
#include "scene/3d/camera_3d.h"
|
|
|
|
#include "scene/3d/node_3d.h"
|
2019-02-05 10:02:13 +00:00
|
|
|
#include "scene/resources/mesh.h"
|
2017-09-10 06:15:11 +00:00
|
|
|
#include "servers/arvr/arvr_positional_tracker.h"
|
2017-04-23 12:10:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
@author Bastiaan Olij <mux213@gmail.com>
|
|
|
|
**/
|
|
|
|
|
|
|
|
/*
|
2017-08-03 08:58:05 +00:00
|
|
|
ARVRCamera is a subclass of camera which will register itself with its parent ARVROrigin and as a result is automatically positioned
|
2017-04-23 12:10:41 +00:00
|
|
|
*/
|
2020-03-26 21:49:16 +00:00
|
|
|
class ARVRCamera : public Camera3D {
|
2017-04-23 12:10:41 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
GDCLASS(ARVRCamera, Camera3D);
|
2017-04-23 12:10:41 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
|
|
|
public:
|
|
|
|
String get_configuration_warning() const;
|
|
|
|
|
2017-09-29 11:36:27 +00:00
|
|
|
virtual Vector3 project_local_ray_normal(const Point2 &p_pos) const;
|
|
|
|
virtual Point2 unproject_position(const Vector3 &p_pos) const;
|
2019-11-09 23:12:18 +00:00
|
|
|
virtual Vector3 project_position(const Point2 &p_point, float p_z_depth) const;
|
2017-09-29 11:36:27 +00:00
|
|
|
virtual Vector<Plane> get_frustum() const;
|
|
|
|
|
2017-04-23 12:10:41 +00:00
|
|
|
ARVRCamera();
|
|
|
|
~ARVRCamera();
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2018-10-25 00:19:21 +00:00
|
|
|
ARVRController is a helper node that automatically updates its position based on tracker data.
|
2017-04-23 12:10:41 +00:00
|
|
|
|
2017-08-03 08:58:05 +00:00
|
|
|
It must be a child node of our ARVROrigin node
|
2017-04-23 12:10:41 +00:00
|
|
|
*/
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
class ARVRController : public Node3D {
|
2017-04-23 12:10:41 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
GDCLASS(ARVRController, Node3D);
|
2017-04-23 12:10:41 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int controller_id;
|
|
|
|
bool is_active;
|
|
|
|
int button_states;
|
2019-02-05 10:02:13 +00:00
|
|
|
Ref<Mesh> mesh;
|
2017-04-23 12:10:41 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void set_controller_id(int p_controller_id);
|
|
|
|
int get_controller_id(void) const;
|
|
|
|
String get_controller_name(void) const;
|
|
|
|
|
|
|
|
int get_joystick_id() const;
|
2020-03-07 01:22:18 +00:00
|
|
|
bool is_button_pressed(int p_button) const;
|
2017-04-23 12:10:41 +00:00
|
|
|
float get_joystick_axis(int p_axis) const;
|
|
|
|
|
2017-11-01 10:46:37 +00:00
|
|
|
real_t get_rumble() const;
|
|
|
|
void set_rumble(real_t p_rumble);
|
|
|
|
|
2017-04-23 12:10:41 +00:00
|
|
|
bool get_is_active() const;
|
2017-09-10 06:15:11 +00:00
|
|
|
ARVRPositionalTracker::TrackerHand get_hand() const;
|
2017-04-23 12:10:41 +00:00
|
|
|
|
2019-02-05 10:02:13 +00:00
|
|
|
Ref<Mesh> get_mesh(void) const;
|
|
|
|
|
2017-04-23 12:10:41 +00:00
|
|
|
String get_configuration_warning() const;
|
|
|
|
|
|
|
|
ARVRController();
|
|
|
|
~ARVRController();
|
|
|
|
};
|
|
|
|
|
2017-08-03 08:58:05 +00:00
|
|
|
/*
|
2018-10-25 00:19:21 +00:00
|
|
|
ARVRAnchor is a helper node that automatically updates its position based on anchor data, it represents a real world location.
|
2017-08-03 08:58:05 +00:00
|
|
|
It must be a child node of our ARVROrigin node
|
|
|
|
*/
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
class ARVRAnchor : public Node3D {
|
|
|
|
GDCLASS(ARVRAnchor, Node3D);
|
2017-08-03 08:58:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int anchor_id;
|
|
|
|
bool is_active;
|
|
|
|
Vector3 size;
|
2019-02-05 10:02:13 +00:00
|
|
|
Ref<Mesh> mesh;
|
2017-08-03 08:58:05 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void set_anchor_id(int p_anchor_id);
|
|
|
|
int get_anchor_id(void) const;
|
|
|
|
String get_anchor_name(void) const;
|
|
|
|
|
|
|
|
bool get_is_active() const;
|
|
|
|
Vector3 get_size() const;
|
|
|
|
|
2017-09-29 11:36:27 +00:00
|
|
|
Plane get_plane() const;
|
|
|
|
|
2019-02-05 10:02:13 +00:00
|
|
|
Ref<Mesh> get_mesh(void) const;
|
|
|
|
|
2017-08-03 08:58:05 +00:00
|
|
|
String get_configuration_warning() const;
|
|
|
|
|
|
|
|
ARVRAnchor();
|
|
|
|
~ARVRAnchor();
|
|
|
|
};
|
|
|
|
|
2017-04-23 12:10:41 +00:00
|
|
|
/*
|
|
|
|
ARVROrigin is special spatial node that acts as our origin point mapping our real world center of our tracking volume into our virtual world.
|
|
|
|
|
|
|
|
It is this point that you will move around the world as the player 'moves while standing still', i.e. the player moves through teleporting or controller inputs as opposed to physically moving.
|
|
|
|
|
|
|
|
Our camera and controllers will always be child nodes and thus place relative to this origin point.
|
|
|
|
This node will automatically locate any camera child nodes and update its position while our ARVRController node will handle tracked controllers.
|
|
|
|
*/
|
2020-03-26 21:49:16 +00:00
|
|
|
class ARVROrigin : public Node3D {
|
2017-04-23 12:10:41 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
GDCLASS(ARVROrigin, Node3D);
|
2017-04-23 12:10:41 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ARVRCamera *tracked_camera;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
String get_configuration_warning() const;
|
|
|
|
|
|
|
|
void set_tracked_camera(ARVRCamera *p_tracked_camera);
|
|
|
|
void clear_tracked_camera_if(ARVRCamera *p_tracked_camera);
|
|
|
|
|
|
|
|
float get_world_scale() const;
|
|
|
|
void set_world_scale(float p_world_scale);
|
|
|
|
|
|
|
|
ARVROrigin();
|
|
|
|
~ARVROrigin();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* ARVR_NODES_H */
|