Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

GLTFPhysicsShape

继承: Resource < RefCounted < Object

代表 GLTF 物理形状。

描述

代表 OMI_collider GLTF 扩展中定义的物理形状。这个类是 GLTF 数据与 Godot 节点的中介,并且经过了抽象,支持将来加入各种 GLTF 物理扩展。

教程

属性

float

height

2.0

ImporterMesh

importer_mesh

bool

is_trigger

false

int

mesh_index

-1

float

radius

0.5

String

shape_type

""

Vector3

size

Vector3(1, 1, 1)

方法

GLTFPhysicsShape

from_dictionary ( Dictionary dictionary ) static

GLTFPhysicsShape

from_node ( CollisionShape3D shape_node ) static

Dictionary

to_dictionary ( ) const

CollisionShape3D

to_node ( bool cache_shapes=false )


属性说明

float height = 2.0

  • void set_height ( float value )

  • float get_height ( )

形状的高度,单位为米。仅在形状类型为“capsule”或“cylinder”时使用。这个值不能为负数,并且对于“capsule”而言应当至少是半径的两倍。


ImporterMesh importer_mesh

形状的 ImporterMesh 资源。仅在形状类型为“hull”(凸包)和“trimesh”(凹三角网格)时使用。


bool is_trigger = false

  • void set_is_trigger ( bool value )

  • bool get_is_trigger ( )

如果为 true,则表示这个形状是触发器。对于 Godot 而言,这意味着该形状应当是 Area3D 节点的子节点。

这是 to_node 方法中唯一没有用到的变量,应该单独用来确定要将生成的节点添加到哪个节点之下。


int mesh_index = -1

  • void set_mesh_index ( int value )

  • int get_mesh_index ( )

形状网格在 GLTF 文件中的索引。仅在形状类型为“hull”(凸包)和“trimesh”(凹三角网格)时使用。


float radius = 0.5

  • void set_radius ( float value )

  • float get_radius ( )

形状的半径,单位为米。仅在形状类型为“capsule”“cylinder”或“sphere”时使用。这个值不应为负数。


String shape_type = ""

  • void set_shape_type ( String value )

  • String get_shape_type ( )

这个形状所代表的形状类型。有效取值有“box”“capsule”“cylinder”“sphere”“hull”以及“trimesh”。


Vector3 size = Vector3(1, 1, 1)

形状的大小,单位为米。仅在碰撞体类型为“box”时使用,代表盒子的“直径”。这个值不应为负数。


方法说明

GLTFPhysicsShape from_dictionary ( Dictionary dictionary ) static

通过解析给定的 Dictionary 新建 GLTFPhysicsShape 实例。


GLTFPhysicsShape from_node ( CollisionShape3D shape_node ) static

根据给定的 Godot CollisionShape3D 节点新建 GLTFPhysicsShape 实例。


Dictionary to_dictionary ( ) const

将这个 GLTFPhysicsShape 实例序列化为 Dictionary


CollisionShape3D to_node ( bool cache_shapes=false )

将这个 GLTFPhysicsShape 实例转换为 Godot CollisionShape3D 节点。