| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/3d/node_3d.h" |
| 34 |
#include "scene/resources/curve.h" |
| 35 |
|
| 36 |
class Path3D : public Node3D { |
| 37 |
GDCLASS(Path3D, Node3D); |
| 38 |
|
| 39 |
private: |
| 40 |
Ref<Curve3D> curve; |
| 41 |
RID debug_instance; |
| 42 |
Color debug_custom_color; |
| 43 |
Ref<ArrayMesh> debug_mesh; |
| 44 |
Ref<Material> debug_material; |
| 45 |
|
| 46 |
Callable update_callback; |
| 47 |
|
| 48 |
void _update_debug_mesh(); |
| 49 |
void _update_debug_path_material(); |
| 50 |
void _curve_changed(); |
| 51 |
|
| 52 |
protected: |
| 53 |
void _notification(int p_what); |
| 54 |
|
| 55 |
static void _bind_methods(); |
| 56 |
|
| 57 |
public: |
| 58 |
void set_update_callback(Callable p_callback); |
| 59 |
|
| 60 |
void set_curve(const Ref<Curve3D> &p_curve); |
| 61 |
Ref<Curve3D> get_curve() const; |
| 62 |
|
| 63 |
const Color &get_debug_custom_color() const; |
| 64 |
void set_debug_custom_color(const Color &p_color); |
| 65 |
|
| 66 |
Ref<StandardMaterial3D> get_debug_material(); |
| 67 |
|
| 68 |
Path3D(); |
| 69 |
~Path3D(); |
| 70 |
}; |
| 71 |
|
| 72 |
class PathFollow3D : public Node3D { |
| 73 |
GDCLASS(PathFollow3D, Node3D); |
| 74 |
|
| 75 |
public: |
| 76 |
enum RotationMode { |
| 77 |
ROTATION_NONE, |
| 78 |
ROTATION_Y, |
| 79 |
ROTATION_XY, |
| 80 |
ROTATION_XYZ, |
| 81 |
ROTATION_ORIENTED |
| 82 |
}; |
| 83 |
|
| 84 |
private: |
| 85 |
Path3D *path = nullptr; |
| 86 |
real_t progress = 0.0; |
| 87 |
real_t h_offset = 0.0; |
| 88 |
real_t v_offset = 0.0; |
| 89 |
bool cubic = true; |
| 90 |
bool loop = true; |
| 91 |
bool tilt_enabled = true; |
| 92 |
bool use_model_front = false; |
| 93 |
RotationMode rotation_mode = ROTATION_XYZ; |
| 94 |
|
| 95 |
protected: |
| 96 |
void _validate_property(PropertyInfo &p_property) const; |
| 97 |
|
| 98 |
void _notification(int p_what); |
| 99 |
|
| 100 |
static void _bind_methods(); |
| 101 |
|
| 102 |
public: |
| 103 |
void set_progress(real_t p_progress); |
| 104 |
real_t get_progress() const; |
| 105 |
|
| 106 |
void set_h_offset(real_t p_h_offset); |
| 107 |
real_t get_h_offset() const; |
| 108 |
|
| 109 |
void set_v_offset(real_t p_v_offset); |
| 110 |
real_t get_v_offset() const; |
| 111 |
|
| 112 |
void set_progress_ratio(real_t p_ratio); |
| 113 |
real_t get_progress_ratio() const; |
| 114 |
|
| 115 |
void set_loop(bool p_loop); |
| 116 |
bool has_loop() const; |
| 117 |
|
| 118 |
void set_tilt_enabled(bool p_enabled); |
| 119 |
bool is_tilt_enabled() const; |
| 120 |
|
| 121 |
void set_rotation_mode(RotationMode p_rotation_mode); |
| 122 |
RotationMode get_rotation_mode() const; |
| 123 |
|
| 124 |
void set_use_model_front(bool p_use_model_front); |
| 125 |
bool is_using_model_front() const; |
| 126 |
|
| 127 |
void set_cubic_interpolation_enabled(bool p_enabled); |
| 128 |
bool is_cubic_interpolation_enabled() const; |
| 129 |
|
| 130 |
PackedStringArray get_configuration_warnings() const override; |
| 131 |
|
| 132 |
void update_transform(); |
| 133 |
|
| 134 |
static Transform3D correct_posture(Transform3D p_transform, PathFollow3D::RotationMode p_rotation_mode); |
| 135 |
}; |
| 136 |
|
| 137 |
VARIANT_ENUM_CAST(PathFollow3D::RotationMode); |