1/**************************************************************************/
2/* path_3d.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef PATH_3D_H
32#define PATH_3D_H
33
34#include "scene/3d/node_3d.h"
35#include "scene/resources/curve.h"
36
37class Path3D : public Node3D {
38 GDCLASS(Path3D, Node3D);
39
40 Ref<Curve3D> curve;
41
42 void _curve_changed();
43
44 RID debug_instance;
45 Ref<ArrayMesh> debug_mesh;
46
47private:
48 void _update_debug_mesh();
49
50protected:
51 void _notification(int p_what);
52
53 static void _bind_methods();
54
55public:
56 void set_curve(const Ref<Curve3D> &p_curve);
57 Ref<Curve3D> get_curve() const;
58
59 Path3D();
60 ~Path3D();
61};
62
63class PathFollow3D : public Node3D {
64 GDCLASS(PathFollow3D, Node3D);
65
66public:
67 enum RotationMode {
68 ROTATION_NONE,
69 ROTATION_Y,
70 ROTATION_XY,
71 ROTATION_XYZ,
72 ROTATION_ORIENTED
73 };
74
75 bool use_model_front = false;
76
77 static Transform3D correct_posture(Transform3D p_transform, PathFollow3D::RotationMode p_rotation_mode);
78
79private:
80 Path3D *path = nullptr;
81 real_t progress = 0.0;
82 real_t h_offset = 0.0;
83 real_t v_offset = 0.0;
84 bool cubic = true;
85 bool loop = true;
86 bool tilt_enabled = true;
87 RotationMode rotation_mode = ROTATION_XYZ;
88
89 void _update_transform(bool p_update_xyz_rot = true);
90
91protected:
92 void _validate_property(PropertyInfo &p_property) const;
93
94 void _notification(int p_what);
95 static void _bind_methods();
96
97public:
98 void set_progress(real_t p_progress);
99 real_t get_progress() const;
100
101 void set_h_offset(real_t p_h_offset);
102 real_t get_h_offset() const;
103
104 void set_v_offset(real_t p_v_offset);
105 real_t get_v_offset() const;
106
107 void set_progress_ratio(real_t p_ratio);
108 real_t get_progress_ratio() const;
109
110 void set_loop(bool p_loop);
111 bool has_loop() const;
112
113 void set_tilt_enabled(bool p_enabled);
114 bool is_tilt_enabled() const;
115
116 void set_rotation_mode(RotationMode p_rotation_mode);
117 RotationMode get_rotation_mode() const;
118
119 void set_use_model_front(bool p_use_model_front);
120 bool is_using_model_front() const;
121
122 void set_cubic_interpolation_enabled(bool p_enabled);
123 bool is_cubic_interpolation_enabled() const;
124
125 PackedStringArray get_configuration_warnings() const override;
126
127 PathFollow3D() {}
128};
129
130VARIANT_ENUM_CAST(PathFollow3D::RotationMode);
131
132#endif // PATH_3D_H
133