Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

GLTFNode

繼承: Resource < RefCounted < Object

glTF 節點類。

說明

代表 glTF 節點。glTF 節點中可以包含名稱、變換、子節點(glTF 節點)以及其他專門的屬性(由各自不同的類表示)。

glTF 節點通常存在於表示 glTF 檔案中的所有資料的 GLTFState 內部。大多數 GLTFNode 的屬性都是 glTF 檔案中其他資料的索引。你可以使用 get_additional_data() 和 set_additional_data() 來新增額外的屬性,擴充 glTF 節點。

教學

屬性

int

camera

-1

PackedInt32Array

children

PackedInt32Array()

int

height

-1

int

light

-1

int

mesh

-1

String

original_name

""

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

bool

visible

true

Transform3D

xform

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

方法

void

append_child_index(child_index: int)

Variant

get_additional_data(extension_name: StringName)

NodePath

get_scene_node_path(gltf_state: GLTFState, handle_skeletons: bool = true)

void

set_additional_data(extension_name: StringName, additional_data: Variant)


屬性說明

int camera = -1 🔗

  • void set_camera(value: int)

  • int get_camera()

如果該 glTF 節點是一個相機,則 GLTFState 中 GLTFCamera 的索引將描述該相機的屬性。如果為 -1,則該節點不是相機。


PackedInt32Array children = PackedInt32Array() 🔗

GLTFState 中子節點的索引。如果該 glTF 節點沒有子節點,則這將是一個空陣列。

Note: The returned array is copied and any changes to it will not update the original property value. See PackedInt32Array for more details.


int height = -1 🔗

  • void set_height(value: int)

  • int get_height()

該節點在節點層次結構中的深度。根節點的高度為 0,其子節點的高度為 1,依此類推。如果為 -1,則尚未計算高度。


int light = -1 🔗

  • void set_light(value: int)

  • int get_light()

如果該 glTF 節點是一盞燈,則 GLTFState 中 GLTFLight 的索引將描述該燈的屬性。如果為 -1,則該節點不是燈。


int mesh = -1 🔗

  • void set_mesh(value: int)

  • int get_mesh()

如果該 glTF 節點是網格,則 GLTFState 中 GLTFMesh 的索引將描述該網格的屬性。如果為 -1,則該節點不是網格。


String original_name = "" 🔗

  • void set_original_name(value: String)

  • String get_original_name()

節點的原名。


int parent = -1 🔗

  • void set_parent(value: int)

  • 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(value: int)

  • int get_skeleton()

如果該 glTF 節點具有骨架,則 GLTFState 中的 GLTFSkeleton 的索引將描述骨架的屬性。如果為 -1,則該節點沒有骨架。


int skin = -1 🔗

  • void set_skin(value: int)

  • int get_skin()

如果該 glTF 節點有皮膚,則 GLTFState 中的 GLTFSkin 的索引將描述皮膚的屬性。如果為 -1,則該節點沒有皮膚。


bool visible = true 🔗

  • void set_visible(value: bool)

  • bool get_visible()

如果為 true,則 GLTF 節點可見。如果 false,則 GLTF 節點不可見。這會被轉換為 Godot 場景中的 Node3D.visible 屬性,為 false 時會匯出到 KHR_node_visibility。


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

glTF 節點相對於其父節點的變換。由於通常首選位置、旋轉和縮放屬性,因此不使用該屬性。


方法說明

void append_child_index(child_index: int) 🔗

將給定的子節點索引附加到 children 陣列。


Variant get_additional_data(extension_name: StringName) 🔗

在這個 GLTFNode 實例中取得額外的任意資料。這可以用來保持 GLTFDocumentExtension 類中每個節點的狀態資料,這很重要,因為它們是無狀態的。

參數應該是 GLTFDocumentExtension 的名字(不必與 glTF 檔案中的副檔名相匹配),而該回傳值可以是你設定的任何值。如果沒有設定任何值,則回傳值為 null。


NodePath get_scene_node_path(gltf_state: GLTFState, handle_skeletons: bool = true) 🔗

回傳該 GLTF 節點匯入後在 Godot 場景樹中的 NodePath。這在使用 GLTFObjectModelProperty 匯入 glTF 物件模型指針時非常有用,可以處理 KHR_animation_pointer、KHR_interactivity 等擴充。

如果 handle_skeletons 為 true,則會正確解析骨骼 glTF 節點的路徑。例如為 false 時為 ^"A/B/C/Bone1/Bone2/Bone3" 的路徑在為 true 時會變成 ^"A/B/C/Skeleton3D:Bone3"。


void set_additional_data(extension_name: StringName, additional_data: Variant) 🔗

在這個 GLTFNode 實例中設定額外的任意資料。這可以用來保持 GLTFDocumentExtension 類中每個節點的狀態資料,這很重要,因為它們是無狀態的。

第一個參數應該是 GLTFDocumentExtension 的名字(不必與 glTF 檔案中的副檔名相匹配),第二個參數可以是任何你想要的東西。