Path: blob/master/modules/gltf/extensions/physics/gltf_physics_body.h
10279 views
/**************************************************************************/1/* gltf_physics_body.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/3d/physics/physics_body_3d.h"3334// GLTFPhysicsBody is an intermediary between Godot's physics body nodes35// and the OMI_physics_body extension.36// https://github.com/omigroup/gltf-extensions/tree/main/extensions/2.0/OMI_physics_body3738class GLTFPhysicsBody : public Resource {39GDCLASS(GLTFPhysicsBody, Resource)4041public:42// These values map to Godot's physics body types.43// When importing, the body type will be set to the closest match, and44// user code can change this to make Godot generate a different node type.45// When exporting, this will be squashed down to one of "static",46// "kinematic", or "dynamic" motion types, or the "trigger" property.47enum class PhysicsBodyType {48STATIC,49ANIMATABLE,50CHARACTER,51RIGID,52VEHICLE,53TRIGGER,54};5556protected:57static void _bind_methods();5859private:60PhysicsBodyType body_type = PhysicsBodyType::RIGID;61real_t mass = 1.0;62Vector3 linear_velocity;63Vector3 angular_velocity;64Vector3 center_of_mass;65Vector3 inertia_diagonal;66Quaternion inertia_orientation;6768public:69String get_body_type() const;70void set_body_type(String p_body_type);7172PhysicsBodyType get_physics_body_type() const;73void set_physics_body_type(PhysicsBodyType p_body_type);7475real_t get_mass() const;76void set_mass(real_t p_mass);7778Vector3 get_linear_velocity() const;79void set_linear_velocity(Vector3 p_linear_velocity);8081Vector3 get_angular_velocity() const;82void set_angular_velocity(Vector3 p_angular_velocity);8384Vector3 get_center_of_mass() const;85void set_center_of_mass(const Vector3 &p_center_of_mass);8687Vector3 get_inertia_diagonal() const;88void set_inertia_diagonal(const Vector3 &p_inertia_diagonal);8990Quaternion get_inertia_orientation() const;91void set_inertia_orientation(const Quaternion &p_inertia_orientation);9293#ifndef DISABLE_DEPRECATED94Basis get_inertia_tensor() const;95void set_inertia_tensor(Basis p_inertia_tensor);96#endif // DISABLE_DEPRECATED9798static Ref<GLTFPhysicsBody> from_node(const CollisionObject3D *p_body_node);99CollisionObject3D *to_node() const;100101static Ref<GLTFPhysicsBody> from_dictionary(const Dictionary p_dictionary);102Dictionary to_dictionary() const;103};104105106