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 | #ifndef GLTF_PHYSICS_BODY_H |
32 | #define GLTF_PHYSICS_BODY_H |
33 | |
34 | #include "scene/3d/physics_body_3d.h" |
35 | |
36 | // GLTFPhysicsBody is an intermediary between OMI_physics_body and Godot's physics body nodes. |
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 | protected: |
43 | static void _bind_methods(); |
44 | |
45 | private: |
46 | String body_type = "static" ; |
47 | real_t mass = 1.0; |
48 | Vector3 linear_velocity; |
49 | Vector3 angular_velocity; |
50 | Vector3 center_of_mass; |
51 | Basis inertia_tensor = Basis(0, 0, 0, 0, 0, 0, 0, 0, 0); |
52 | |
53 | public: |
54 | String get_body_type() const; |
55 | void set_body_type(String p_body_type); |
56 | |
57 | real_t get_mass() const; |
58 | void set_mass(real_t p_mass); |
59 | |
60 | Vector3 get_linear_velocity() const; |
61 | void set_linear_velocity(Vector3 p_linear_velocity); |
62 | |
63 | Vector3 get_angular_velocity() const; |
64 | void set_angular_velocity(Vector3 p_angular_velocity); |
65 | |
66 | Vector3 get_center_of_mass() const; |
67 | void set_center_of_mass(const Vector3 &p_center_of_mass); |
68 | |
69 | Basis get_inertia_tensor() const; |
70 | void set_inertia_tensor(Basis p_inertia_tensor); |
71 | |
72 | static Ref<GLTFPhysicsBody> from_node(const CollisionObject3D *p_body_node); |
73 | CollisionObject3D *to_node() const; |
74 | |
75 | static Ref<GLTFPhysicsBody> from_dictionary(const Dictionary p_dictionary); |
76 | Dictionary to_dictionary() const; |
77 | }; |
78 | |
79 | #endif // GLTF_PHYSICS_BODY_H |
80 | |