Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/gltf/extensions/physics/gltf_physics_shape.h
10279 views
1
/**************************************************************************/
2
/* gltf_physics_shape.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 "../../gltf_defines.h"
34
35
#include "scene/3d/physics/collision_shape_3d.h"
36
37
class ImporterMesh;
38
39
// GLTFPhysicsShape is an intermediary between Godot's collision shape nodes
40
// and the OMI_physics_shape extension.
41
// https://github.com/omigroup/gltf-extensions/tree/main/extensions/2.0/OMI_physics_shape
42
43
class GLTFPhysicsShape : public Resource {
44
GDCLASS(GLTFPhysicsShape, Resource)
45
46
protected:
47
static void _bind_methods();
48
49
private:
50
String shape_type;
51
Vector3 size = Vector3(1.0, 1.0, 1.0);
52
real_t radius = 0.5;
53
real_t height = 2.0;
54
bool is_trigger = false;
55
GLTFMeshIndex mesh_index = -1;
56
Ref<ImporterMesh> importer_mesh = nullptr;
57
// Internal only, for caching Godot shape resources. Used in `to_resource` and `to_node`.
58
Ref<Shape3D> _shape_cache = nullptr;
59
60
public:
61
String get_shape_type() const;
62
void set_shape_type(String p_shape_type);
63
64
Vector3 get_size() const;
65
void set_size(Vector3 p_size);
66
67
real_t get_radius() const;
68
void set_radius(real_t p_radius);
69
70
real_t get_height() const;
71
void set_height(real_t p_height);
72
73
bool get_is_trigger() const;
74
void set_is_trigger(bool p_is_trigger);
75
76
GLTFMeshIndex get_mesh_index() const;
77
void set_mesh_index(GLTFMeshIndex p_mesh_index);
78
79
Ref<ImporterMesh> get_importer_mesh() const;
80
void set_importer_mesh(Ref<ImporterMesh> p_importer_mesh);
81
82
static Ref<GLTFPhysicsShape> from_node(const CollisionShape3D *p_shape_node);
83
CollisionShape3D *to_node(bool p_cache_shapes = false);
84
85
static Ref<GLTFPhysicsShape> from_resource(const Ref<Shape3D> &p_shape_resource);
86
Ref<Shape3D> to_resource(bool p_cache_shapes = false);
87
88
static Ref<GLTFPhysicsShape> from_dictionary(const Dictionary p_dictionary);
89
Dictionary to_dictionary() const;
90
};
91
92