Debian Codegraph @

scene/3d/look_at_modifier_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* look_at_modifier_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 #pragma once
32
33 #include "scene/3d/skeleton_modifier_3d.h"
34 #include "scene/animation/tween.h"
35
36 class LookAtModifier3D : public SkeletonModifier3D {
37 GDCLASS(LookAtModifier3D, SkeletonModifier3D);
38
39 public:
40 enum OriginFrom {
41 ORIGIN_FROM_SELF,
42 ORIGIN_FROM_SPECIFIC_BONE,
43 ORIGIN_FROM_EXTERNAL_NODE,
44 };
45
46 private:
47 String bone_name;
48 int bone = -1;
49
50 Vector3 forward_vector;
51 Vector3 forward_vector_nrm;
52 BoneAxis forward_axis = BONE_AXIS_PLUS_Z;
53 Vector3::Axis primary_rotation_axis = Vector3::AXIS_Y;
54 Vector3::Axis secondary_rotation_axis = Vector3::AXIS_X;
55 bool use_secondary_rotation = true;
56 bool relative = false;
57
58 OriginFrom origin_from = ORIGIN_FROM_SELF;
59 String origin_bone_name;
60 int origin_bone = -1;
61 NodePath origin_external_node;
62
63 Vector3 origin_offset;
64 float origin_safe_margin = 0.1;
65
66 NodePath target_node;
67
68 float duration = 0;
69 Tween::TransitionType transition_type = Tween::TRANS_LINEAR;
70 Tween::EaseType ease_type = Tween::EASE_IN;
71
72 bool use_angle_limitation = false;
73 bool symmetry_limitation = true;
74
75 float primary_limit_angle = Math::TAU;
76 float primary_damp_threshold = 1.0f;
77 float primary_positive_limit_angle = Math::PI;
78 float primary_positive_damp_threshold = 1.0f;
79 float primary_negative_limit_angle = Math::PI;
80 float primary_negative_damp_threshold = 1.0f;
81
82 float secondary_limit_angle = Math::TAU;
83 float secondary_damp_threshold = 1.0f;
84 float secondary_positive_limit_angle = Math::PI;
85 float secondary_positive_damp_threshold = 1.0f;
86 float secondary_negative_limit_angle = Math::PI;
87 float secondary_negative_damp_threshold = 1.0f;
88
89 bool is_within_limitations = false;
90
91 // For time-based interpolation.
92 Quaternion from_q;
93 Quaternion prev_q;
94
95 float remaining = 0;
96 float time_step = 1.0;
97
98 float remap_damped(float p_from, float p_to, float p_damp_threshold, float p_value) const;
99 double get_bspline_y(const Vector2 &p_from, const Vector2 &p_control, const Vector2 &p_to, double p_x) const;
100 bool is_intersecting_axis(const Vector3 &p_prev, const Vector3 &p_current, Vector3::Axis p_flipping_axis, Vector3::Axis p_check_axis, bool p_check_plane = false) const;
101
102 Transform3D look_at_with_axes(const Transform3D &p_rest);
103 void init_transition();
104
105 protected:
106 virtual PackedStringArray get_configuration_warnings() const override;
107 void _validate_property(PropertyInfo &p_property) const;
108
109 virtual void _validate_bone_names() override;
110
111 static void _bind_methods();
112
113 virtual void _process_modification(double p_delta) override;
114
115 public:
116 void set_bone_name(const String &p_bone_name);
117 String get_bone_name() const;
118 void set_bone(int p_bone);
119 int get_bone() const;
120
121 void set_forward_axis(BoneAxis p_axis);
122 BoneAxis get_forward_axis() const;
123 void set_primary_rotation_axis(Vector3::Axis p_axis);
124 Vector3::Axis get_primary_rotation_axis() const;
125 void set_use_secondary_rotation(bool p_enabled);
126 bool is_using_secondary_rotation() const;
127 void set_relative(bool p_enabled);
128 bool is_relative() const;
129
130 void set_origin_from(OriginFrom p_origin_from);
131 OriginFrom get_origin_from() const;
132 void set_origin_bone_name(const String &p_bone_name);
133 String get_origin_bone_name() const;
134 void set_origin_bone(int p_bone);
135 int get_origin_bone() const;
136 void set_origin_external_node(const NodePath &p_external_node);
137 NodePath get_origin_external_node() const;
138
139 void set_origin_offset(const Vector3 &p_offset);
140 Vector3 get_origin_offset() const;
141 void set_origin_safe_margin(float p_margin);
142 float get_origin_safe_margin() const;
143
144 void set_target_node(const NodePath &p_target_node);
145 NodePath get_target_node() const;
146
147 void set_duration(float p_duration);
148 float get_duration() const;
149 void set_transition_type(Tween::TransitionType p_transition_type);
150 Tween::TransitionType get_transition_type() const;
151 void set_ease_type(Tween::EaseType p_ease_type);
152 Tween::EaseType get_ease_type() const;
153
154 void set_use_angle_limitation(bool p_enabled);
155 bool is_using_angle_limitation() const;
156 void set_symmetry_limitation(bool p_enabled);
157 bool is_limitation_symmetry() const;
158
159 void set_primary_limit_angle(float p_angle);
160 float get_primary_limit_angle() const;
161 void set_primary_damp_threshold(float p_power);
162 float get_primary_damp_threshold() const;
163
164 void set_primary_positive_limit_angle(float p_angle);
165 float get_primary_positive_limit_angle() const;
166 void set_primary_positive_damp_threshold(float p_power);
167 float get_primary_positive_damp_threshold() const;
168 void set_primary_negative_limit_angle(float p_angle);
169 float get_primary_negative_limit_angle() const;
170 void set_primary_negative_damp_threshold(float p_power);
171 float get_primary_negative_damp_threshold() const;
172
173 void set_secondary_limit_angle(float p_angle);
174 float get_secondary_limit_angle() const;
175 void set_secondary_damp_threshold(float p_power);
176 float get_secondary_damp_threshold() const;
177
178 void set_secondary_positive_limit_angle(float p_angle);
179 float get_secondary_positive_limit_angle() const;
180 void set_secondary_positive_damp_threshold(float p_power);
181 float get_secondary_positive_damp_threshold() const;
182 void set_secondary_negative_limit_angle(float p_angle);
183 float get_secondary_negative_limit_angle() const;
184 void set_secondary_negative_damp_threshold(float p_power);
185 float get_secondary_negative_damp_threshold() const;
186
187 float get_interpolation_remaining() const;
188 bool is_interpolating() const;
189 bool is_target_within_limitation() const;
190
191 static Vector3::Axis get_secondary_rotation_axis(BoneAxis p_forward_axis, Vector3::Axis p_primary_rotation_axis);
192 static Vector3 get_basis_vector_from_bone_axis(const Basis &p_basis, BoneAxis p_axis);
193 static Vector2 get_projection_vector(const Vector3 &p_vector, Vector3::Axis p_axis);
194 };
195
196 VARIANT_ENUM_CAST(LookAtModifier3D::OriginFrom);