Debian Codegraph @

modules/gltf/extensions/physics/gltf_physics_body.h

raw symbols SCIP
1 /**************************************************************************/
2 /* gltf_physics_body.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/physics/physics_body_3d.h"
34
35 // GLTFPhysicsBody is an intermediary between Godot's physics body nodes
36 // and the OMI_physics_body extension.
37 // https://github.com/omigroup/gltf-extensions/tree/main/extensions/2.0/OMI_physics_body
38
39 class GLTFPhysicsBody : public Resource {
40 GDCLASS(GLTFPhysicsBody, Resource)
41
42 public:
43 // These values map to Godot's physics body types.
44 // When importing, the body type will be set to the closest match, and
45 // user code can change this to make Godot generate a different node type.
46 // When exporting, this will be squashed down to one of "static",
47 // "kinematic", or "dynamic" motion types, or the "trigger" property.
48 enum class PhysicsBodyType {
49 STATIC,
50 ANIMATABLE,
51 CHARACTER,
52 RIGID,
53 VEHICLE,
54 TRIGGER,
55 };
56
57 protected:
58 static void _bind_methods();
59
60 private:
61 PhysicsBodyType body_type = PhysicsBodyType::RIGID;
62 real_t mass = 1.0;
63 Vector3 linear_velocity;
64 Vector3 angular_velocity;
65 Vector3 center_of_mass;
66 Vector3 inertia_diagonal;
67 Quaternion inertia_orientation;
68
69 public:
70 String get_body_type() const;
71 void set_body_type(const String &p_body_type);
72
73 PhysicsBodyType get_physics_body_type() const;
74 void set_physics_body_type(PhysicsBodyType p_body_type);
75
76 real_t get_mass() const;
77 void set_mass(real_t p_mass);
78
79 Vector3 get_linear_velocity() const;
80 void set_linear_velocity(const Vector3 &p_linear_velocity);
81
82 Vector3 get_angular_velocity() const;
83 void set_angular_velocity(const Vector3 &p_angular_velocity);
84
85 Vector3 get_center_of_mass() const;
86 void set_center_of_mass(const Vector3 &p_center_of_mass);
87
88 Vector3 get_inertia_diagonal() const;
89 void set_inertia_diagonal(const Vector3 &p_inertia_diagonal);
90
91 Quaternion get_inertia_orientation() const;
92 void set_inertia_orientation(const Quaternion &p_inertia_orientation);
93
94 #ifndef DISABLE_DEPRECATED
95 Basis get_inertia_tensor() const;
96 void set_inertia_tensor(const Basis &p_inertia_tensor);
97 #endif // DISABLE_DEPRECATED
98
99 static Ref<GLTFPhysicsBody> from_node(const CollisionObject3D *p_body_node);
100 CollisionObject3D *to_node() const;
101
102 static Ref<GLTFPhysicsBody> from_dictionary(const Dictionary &p_dictionary);
103 Dictionary to_dictionary() const;
104 };