| 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 "editor/scene/3d/node_3d_editor_gizmos.h" |
| 34 |
|
| 35 |
class Timer; |
| 36 |
|
| 37 |
class Joint3DGizmoPlugin : public EditorNode3DGizmoPlugin { |
| 38 |
GDCLASS(Joint3DGizmoPlugin, EditorNode3DGizmoPlugin); |
| 39 |
|
| 40 |
Timer *update_timer = nullptr; |
| 41 |
EditorNode3DGizmo *last_drawn = nullptr; |
| 42 |
|
| 43 |
void incremental_update_gizmos(); |
| 44 |
|
| 45 |
public: |
| 46 |
bool has_gizmo(Node3D *p_spatial) override; |
| 47 |
String get_gizmo_name() const override; |
| 48 |
int get_priority() const override; |
| 49 |
void redraw(EditorNode3DGizmo *p_gizmo) override; |
| 50 |
|
| 51 |
static void CreatePinJointGizmo(const Transform3D &p_offset, Vector<Vector3> &r_cursor_points); |
| 52 |
static void CreateHingeJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); |
| 53 |
static void CreateSliderJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); |
| 54 |
static void CreateConeTwistJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); |
| 55 |
static void CreateGeneric6DOFJointGizmo( |
| 56 |
const Transform3D &p_offset, |
| 57 |
const Transform3D &p_trs_joint, |
| 58 |
const Transform3D &p_trs_body_a, |
| 59 |
const Transform3D &p_trs_body_b, |
| 60 |
real_t p_angular_limit_lower_x, |
| 61 |
real_t p_angular_limit_upper_x, |
| 62 |
real_t p_linear_limit_lower_x, |
| 63 |
real_t p_linear_limit_upper_x, |
| 64 |
bool p_enable_angular_limit_x, |
| 65 |
bool p_enable_linear_limit_x, |
| 66 |
real_t p_angular_limit_lower_y, |
| 67 |
real_t p_angular_limit_upper_y, |
| 68 |
real_t p_linear_limit_lower_y, |
| 69 |
real_t p_linear_limit_upper_y, |
| 70 |
bool p_enable_angular_limit_y, |
| 71 |
bool p_enable_linear_limit_y, |
| 72 |
real_t p_angular_limit_lower_z, |
| 73 |
real_t p_angular_limit_upper_z, |
| 74 |
real_t p_linear_limit_lower_z, |
| 75 |
real_t p_linear_limit_upper_z, |
| 76 |
bool p_enable_angular_limit_z, |
| 77 |
bool p_enable_linear_limit_z, |
| 78 |
Vector<Vector3> &r_points, |
| 79 |
Vector<Vector3> *r_body_a_points, |
| 80 |
Vector<Vector3> *r_body_b_points); |
| 81 |
|
| 82 |
Joint3DGizmoPlugin(); |
| 83 |
}; |
| 84 |
|
| 85 |
class JointGizmosDrawer { |
| 86 |
public: |
| 87 |
static Basis look_body(const Transform3D &p_joint_transform, const Transform3D &p_body_transform); |
| 88 |
static Basis look_body_toward(Vector3::Axis p_axis, const Transform3D &joint_transform, const Transform3D &body_transform); |
| 89 |
static Basis look_body_toward_x(const Transform3D &p_joint_transform, const Transform3D &p_body_transform); |
| 90 |
static Basis look_body_toward_y(const Transform3D &p_joint_transform, const Transform3D &p_body_transform); |
| 91 |
|
| 92 |
|
| 93 |
static Basis look_body_toward_z(const Transform3D &p_joint_transform, const Transform3D &p_body_transform); |
| 94 |
|
| 95 |
|
| 96 |
static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform3D &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false); |
| 97 |
static void draw_cone(const Transform3D &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points); |
| 98 |
}; |