-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69266 from aaronfranke/gltf-physics
Implement physics support in the GLTF module
- Loading branch information
Showing
12 changed files
with
1,164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="GLTFCollider" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> | ||
<brief_description> | ||
Represents a GLTF collider. | ||
</brief_description> | ||
<description> | ||
Represents a collider as defined by the [code]OMI_collider[/code] GLTF extension. This class is an intermediary between the GLTF data and Godot's nodes, and it's abstracted in a way that allows adding support for different GLTF physics extensions in the future. | ||
</description> | ||
<tutorials> | ||
<link title="OMI_collider GLTF extension">https://github.com/omigroup/gltf-extensions/tree/main/extensions/2.0/OMI_collider</link> | ||
</tutorials> | ||
<methods> | ||
<method name="from_dictionary" qualifiers="static"> | ||
<return type="GLTFCollider" /> | ||
<param index="0" name="dictionary" type="Dictionary" /> | ||
<description> | ||
Creates a new GLTFCollider instance by parsing the given [Dictionary]. | ||
</description> | ||
</method> | ||
<method name="from_node" qualifiers="static"> | ||
<return type="GLTFCollider" /> | ||
<param index="0" name="collider_node" type="CollisionShape3D" /> | ||
<description> | ||
Create a new GLTFCollider instance from the given Godot [CollisionShape3D] node. | ||
</description> | ||
</method> | ||
<method name="to_dictionary" qualifiers="const"> | ||
<return type="Dictionary" /> | ||
<description> | ||
Serializes this GLTFCollider instance into a [Dictionary]. | ||
</description> | ||
</method> | ||
<method name="to_node"> | ||
<return type="CollisionShape3D" /> | ||
<param index="0" name="cache_shapes" type="bool" default="false" /> | ||
<description> | ||
Converts this GLTFCollider instance into a Godot [CollisionShape3D] node. | ||
</description> | ||
</method> | ||
</methods> | ||
<members> | ||
<member name="height" type="float" setter="set_height" getter="get_height" default="2.0"> | ||
The height of the collider, in meters. This is only used when the collider type is "capsule" or "cylinder". This value should not be negative, and for "capsule" it should be at least twice the radius. | ||
</member> | ||
<member name="importer_mesh" type="ImporterMesh" setter="set_importer_mesh" getter="get_importer_mesh"> | ||
The [ImporterMesh] resource of the collider. This is only used when the collider type is "hull" (convex hull) or "trimesh" (concave trimesh). | ||
</member> | ||
<member name="is_trigger" type="bool" setter="set_is_trigger" getter="get_is_trigger" default="false"> | ||
If [code]true[/code], indicates that this collider is a trigger. For Godot, this means that the collider should be a child of an Area3D node. | ||
This is the only variable not used in the [method to_node] method, it's intended to be used alongside when deciding where to add the generated node as a child. | ||
</member> | ||
<member name="mesh_index" type="int" setter="set_mesh_index" getter="get_mesh_index" default="-1"> | ||
The index of the collider's mesh in the GLTF file. This is only used when the collider type is "hull" (convex hull) or "trimesh" (concave trimesh). | ||
</member> | ||
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="0.5"> | ||
The radius of the collider, in meters. This is only used when the collider type is "capsule", "cylinder", or "sphere". This value should not be negative. | ||
</member> | ||
<member name="shape_type" type="String" setter="set_shape_type" getter="get_shape_type" default=""""> | ||
The type of shape this collider represents. Valid values are "box", "capsule", "cylinder", "sphere", "hull", and "trimesh". | ||
</member> | ||
<member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(1, 1, 1)"> | ||
The size of the collider, in meters. This is only used when the collider type is "box", and it represents the "diameter" of the box. This value should not be negative. | ||
</member> | ||
</members> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="GLTFPhysicsBody" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> | ||
<brief_description> | ||
Represents a GLTF physics body. | ||
</brief_description> | ||
<description> | ||
Represents a physics body as defined by the [code]OMI_physics_body[/code] GLTF extension. This class is an intermediary between the GLTF data and Godot's nodes, and it's abstracted in a way that allows adding support for different GLTF physics extensions in the future. | ||
</description> | ||
<tutorials> | ||
<link title="OMI_physics_body GLTF extension">https://github.com/omigroup/gltf-extensions/tree/main/extensions/2.0/OMI_physics_body</link> | ||
</tutorials> | ||
<methods> | ||
<method name="from_dictionary" qualifiers="static"> | ||
<return type="GLTFPhysicsBody" /> | ||
<param index="0" name="dictionary" type="Dictionary" /> | ||
<description> | ||
Creates a new GLTFPhysicsBody instance by parsing the given [Dictionary]. | ||
</description> | ||
</method> | ||
<method name="from_node" qualifiers="static"> | ||
<return type="GLTFPhysicsBody" /> | ||
<param index="0" name="body_node" type="CollisionObject3D" /> | ||
<description> | ||
Create a new GLTFPhysicsBody instance from the given Godot [CollisionObject3D] node. | ||
</description> | ||
</method> | ||
<method name="to_dictionary" qualifiers="const"> | ||
<return type="Dictionary" /> | ||
<description> | ||
Serializes this GLTFPhysicsBody instance into a [Dictionary]. | ||
</description> | ||
</method> | ||
<method name="to_node" qualifiers="const"> | ||
<return type="CollisionObject3D" /> | ||
<description> | ||
Converts this GLTFPhysicsBody instance into a Godot [CollisionObject3D] node. | ||
</description> | ||
</method> | ||
</methods> | ||
<members> | ||
<member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity" default="Vector3(0, 0, 0)"> | ||
The angular velocity of the physics body, in radians per second. This is only used when the body type is "rigid" or "vehicle". | ||
</member> | ||
<member name="body_type" type="String" setter="set_body_type" getter="get_body_type" default=""static""> | ||
The type of the body. Valid values are "static", "kinematic", "character", "rigid", "vehicle", and "trigger". | ||
</member> | ||
<member name="inertia" type="Vector3" setter="set_inertia" getter="get_inertia" default="Vector3(0, 0, 0)"> | ||
The principle axes of the inertia tensor of the physics body, in kilogram meter squared (kg⋅m²). This is only used when the body type is "rigid" or "vehicle". | ||
This is written to and read from the GLTF file as a 3x3 matrix, but is exposed as a Vector3 since Godot only supports principal axis inertia values. When converted to a Godot [RigidBody3D] node, if this value is zero, then the inertia will be calculated automatically. | ||
</member> | ||
<member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3(0, 0, 0)"> | ||
The linear velocity of the physics body, in meters per second. This is only used when the body type is "rigid" or "vehicle". | ||
</member> | ||
<member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0"> | ||
The mass of the physics body, in kilograms. This is only used when the body type is "rigid" or "vehicle". | ||
</member> | ||
</members> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.