Up to date

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

GLTFNode

继承: Resource < RefCounted < Object

GLTF 节点类。

描述

代表 GLTF 节点。GLTF 节点中可以包含名称、变换、子节点(GLTF 节点)以及其他专门的属性(由各自不同的类表示)。

GLTF 节点通常存在于表示 GLTF 文件中的所有数据的 GLTFState 内部。大多数 GLTFNode 的属性都是 GLTF 文件中其他数据的索引。你可以使用 get_additional_dataset_additional_data 来添加额外的属性,扩展 GLTF 节点。

教程

属性

int

camera

-1

PackedInt32Array

children

PackedInt32Array()

int

height

-1

int

light

-1

int

mesh

-1

int

parent

-1

Vector3

position

Vector3(0, 0, 0)

Quaternion

rotation

Quaternion(0, 0, 0, 1)

Vector3

scale

Vector3(1, 1, 1)

int

skeleton

-1

int

skin

-1

Transform3D

xform

Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)

方法

Variant

get_additional_data ( StringName extension_name )

void

set_additional_data ( StringName extension_name, Variant additional_data )


属性说明

int camera = -1

  • void set_camera ( int value )

  • int get_camera ( )

如果该 GLTF 节点是一个相机,则 GLTFStateGLTFCamera 的索引将描述该相机的属性。如果为 -1,则该节点不是相机。


PackedInt32Array children = PackedInt32Array()

GLTFState 中子节点的索引。如果该 GLTF 节点没有子节点,则这将是一个空数组。


int height = -1

  • void set_height ( int value )

  • int get_height ( )

该节点在节点层次结构中的深度。根节点的高度为 0,其子节点的高度为 1,依此类推。如果为 -1,则尚未计算高度。


int light = -1

  • void set_light ( int value )

  • int get_light ( )

如果该 GLTF 节点是一盏灯,则 GLTFStateGLTFLight 的索引将描述该灯的属性。如果为 -1,则该节点不是灯。


int mesh = -1

  • void set_mesh ( int value )

  • int get_mesh ( )

如果该 GLTF 节点是网格,则 GLTFStateGLTFMesh 的索引将描述该网格的属性。如果为 -1,则该节点不是网格。


int parent = -1

  • void set_parent ( int value )

  • int get_parent ( )

GLTFState 中父节点的索引。如果为 -1,则该节点为根节点。


Vector3 position = Vector3(0, 0, 0)

该 GLTF 节点相对于其父节点的位置。


Quaternion rotation = Quaternion(0, 0, 0, 1)

该 GLTF 节点相对于其父节点的旋转。


Vector3 scale = Vector3(1, 1, 1)

该 GLTF 节点相对于其父节点的缩放。


int skeleton = -1

  • void set_skeleton ( int value )

  • int get_skeleton ( )

如果该 GLTF 节点具有骨架,则 GLTFState 中的 GLTFSkeleton 的索引将描述骨架的属性。如果为 -1,则该节点没有骨架。


int skin = -1

  • void set_skin ( int value )

  • int get_skin ( )

如果该 GLTF 节点有皮肤,则 GLTFState 中的 GLTFSkin 的索引将描述皮肤的属性。如果为 -1,则该节点没有皮肤。


Transform3D xform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)

GLTF 节点相对于其父节点的变换。由于通常首选位置、旋转和缩放属性,因此不使用该属性。


方法说明

Variant get_additional_data ( StringName extension_name )

在这个 GLTFNode 实例中获取额外的任意数据。这可以用来保持 GLTFDocumentExtension 类中每个节点的状态数据,这很重要,因为它们是无状态的。

参数应该是 GLTFDocumentExtension 的名字(不必与 GLTF 文件中的扩展名相匹配),而该返回值可以是你设置的任何值。如果没有设置任何值,则返回值为 null。


void set_additional_data ( StringName extension_name, Variant additional_data )

在这个 GLTFNode 实例中设置额外的任意数据。这可以用来保持 GLTFDocumentExtension 类中每个节点的状态数据,这很重要,因为它们是无状态的。

第一个参数应该是 GLTFDocumentExtension 的名字(不必与 GLTF 文件中的扩展名相匹配),第二个参数可以是任何你想要的东西。