Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/scene/3d/convert_transform_modifier_3d.h
21138 views
1
/**************************************************************************/
2
/* convert_transform_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/bone_constraint_3d.h"
34
35
class ConvertTransformModifier3D : public BoneConstraint3D {
36
GDCLASS(ConvertTransformModifier3D, BoneConstraint3D);
37
38
public:
39
enum TransformMode {
40
TRANSFORM_MODE_POSITION,
41
TRANSFORM_MODE_ROTATION,
42
TRANSFORM_MODE_SCALE,
43
};
44
45
struct ConvertTransform3DSetting : public BoneConstraint3DSetting {
46
TransformMode apply_transform_mode = TRANSFORM_MODE_POSITION;
47
Vector3::Axis apply_axis = Vector3::AXIS_X;
48
float apply_range_min = 0.0;
49
float apply_range_max = 0.0;
50
51
TransformMode reference_transform_mode = TRANSFORM_MODE_POSITION;
52
Vector3::Axis reference_axis = Vector3::AXIS_X;
53
float reference_range_min = 0.0;
54
float reference_range_max = 0.0;
55
56
bool relative = true;
57
bool additive = false;
58
59
bool is_relative() {
60
if (reference_type == REFERENCE_TYPE_NODE) {
61
return false;
62
}
63
return relative;
64
}
65
};
66
67
protected:
68
bool _get(const StringName &p_path, Variant &r_ret) const;
69
bool _set(const StringName &p_path, const Variant &p_value);
70
void _get_property_list(List<PropertyInfo> *p_list) const;
71
void _validate_dynamic_prop(PropertyInfo &p_property) const;
72
73
static void _bind_methods();
74
75
virtual void _process_constraint_by_bone(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, int p_reference_bone, float p_amount) override;
76
virtual void _process_constraint_by_node(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, const NodePath &p_reference_node, float p_amount) override;
77
virtual void _process_convert(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, const Transform3D &p_destination, float p_amount);
78
virtual void _validate_setting(int p_index) override;
79
80
public:
81
void set_apply_transform_mode(int p_index, TransformMode p_transform_mode);
82
TransformMode get_apply_transform_mode(int p_index) const;
83
void set_apply_axis(int p_index, Vector3::Axis p_axis);
84
Vector3::Axis get_apply_axis(int p_index) const;
85
void set_apply_range_min(int p_index, float p_range_min);
86
float get_apply_range_min(int p_index) const;
87
void set_apply_range_max(int p_index, float p_range_max);
88
float get_apply_range_max(int p_index) const;
89
90
void set_reference_transform_mode(int p_index, TransformMode p_transform_mode);
91
TransformMode get_reference_transform_mode(int p_index) const;
92
void set_reference_axis(int p_index, Vector3::Axis p_axis);
93
Vector3::Axis get_reference_axis(int p_index) const;
94
void set_reference_range_min(int p_index, float p_range_min);
95
float get_reference_range_min(int p_index) const;
96
void set_reference_range_max(int p_index, float p_range_max);
97
float get_reference_range_max(int p_index) const;
98
99
void set_relative(int p_index, bool p_enabled);
100
bool is_relative(int p_index) const;
101
102
void set_additive(int p_index, bool p_enabled);
103
bool is_additive(int p_index) const;
104
105
~ConvertTransformModifier3D();
106
};
107
108
VARIANT_ENUM_CAST(ConvertTransformModifier3D::TransformMode);
109
110