Class reference
GLTFPhysicsShape
Inherits Resource
Represents a glTF physics shape.
Description
Represents a physics shape as defined by the OMI_physics_shape or OMI_collider glTF extensions. This class is an intermediary between the glTF data and Redot's nodes, and it's abstracted in a way that allows adding support for different glTF physics extensions in the future.
Properties
float height = 2.0
float height = 2.0The height of the shape, in meters. This is only used when the shape type is "capsule" or "cylinder". This value should not be negative, and for "capsule" it should be at least twice the radius.
ImporterMesh importer_mesh
ImporterMesh importer_meshThe ImporterMesh resource of the shape. This is only used when the shape type is "hull" (convex hull) or "trimesh" (concave trimesh).
bool is_trigger = false
bool is_trigger = falseIf true, indicates that this shape is a trigger. For Redot, this means that the shape should be a child of an Area3D node. This is the only variable not used in the to_node() method, it's intended to be used alongside when deciding where to add the generated node as a child.
int mesh_index = -1
int mesh_index = -1The index of the shape's mesh in the glTF file. This is only used when the shape type is "hull" (convex hull) or "trimesh" (concave trimesh).
float radius = 0.5
float radius = 0.5The radius of the shape, in meters. This is only used when the shape type is "capsule", "cylinder", or "sphere". This value should not be negative.
String shape_type = ""
String shape_type = ""The type of shape this shape represents. Valid values are "box", "capsule", "cylinder", "sphere", "hull", and "trimesh".
Vector3 size = Vector3(1, 1, 1)
Vector3 size = Vector3(1, 1, 1)The size of the shape, in meters. This is only used when the shape type is "box", and it represents the "diameter" of the box. This value should not be negative.
Methods
GLTFPhysicsShape from_dictionary(Dictionary dictionary) static
GLTFPhysicsShape from_dictionary(Dictionary dictionary) staticCreates a new GLTFPhysicsShape instance by parsing the given Dictionary.
GLTFPhysicsShape from_node(CollisionShape3D shape_node) static
GLTFPhysicsShape from_node(CollisionShape3D shape_node) staticCreates a new GLTFPhysicsShape instance from the given Redot CollisionShape3D node.
GLTFPhysicsShape from_resource(Shape3D shape_resource) static
GLTFPhysicsShape from_resource(Shape3D shape_resource) staticCreates a new GLTFPhysicsShape instance from the given Redot Shape3D resource.
Dictionary to_dictionary() const
Dictionary to_dictionary() constSerializes this GLTFPhysicsShape instance into a Dictionary in the format defined by OMI_physics_shape.
CollisionShape3D to_node(bool cache_shapes = false)
CollisionShape3D to_node(bool cache_shapes = false)Converts this GLTFPhysicsShape instance into a Redot CollisionShape3D node.
Shape3D to_resource(bool cache_shapes = false)
Shape3D to_resource(bool cache_shapes = false)Converts this GLTFPhysicsShape instance into a Redot Shape3D resource.