Table of Contents

Class GltfState

Namespace
Godot
Assembly
GodotSharp.dll

Contains all nodes and resources of a GLTF file. This is used by GltfDocument as data storage, which allows GltfDocument and all GltfDocumentExtension classes to remain stateless.

GLTFState can be populated by GltfDocument reading a file or by converting a Godot scene. Then the data can either be used to create a Godot scene or save to a GLTF file. The code that converts to/from a Godot scene can be intercepted at arbitrary points by GltfDocumentExtension classes. This allows for custom data to be stored in the GLTF file or for custom data to be converted to/from Godot nodes.

[GodotClassName("GLTFState")]
public class GltfState : Resource, IDisposable
Inheritance
GltfState
Implements
Inherited Members

Constructors

GltfState()

public GltfState()

Fields

HandleBinaryDiscardTextures

Discards all embedded textures and uses untextured materials.

public const long HandleBinaryDiscardTextures = 0

Field Value

long

HandleBinaryEmbedAsBasisu

Embeds textures VRAM compressed with Basis Universal into the generated scene.

public const long HandleBinaryEmbedAsBasisu = 2

Field Value

long

HandleBinaryEmbedAsUncompressed

Embeds textures compressed losslessly into the generated scene, matching old behavior.

public const long HandleBinaryEmbedAsUncompressed = 3

Field Value

long

HandleBinaryExtractTextures

Extracts embedded textures to be reimported and compressed. Editor only. Acts as uncompressed at runtime.

public const long HandleBinaryExtractTextures = 1

Field Value

long

Properties

Accessors

public Array<GltfAccessor> Accessors { get; set; }

Property Value

Array<GltfAccessor>

Animations

public Array<GltfAnimation> Animations { get; set; }

Property Value

Array<GltfAnimation>

BasePath

The folder path associated with this GLTF data. This is used to find other files the GLTF file references, like images or binary buffers. This will be set during import when appending from a file, and will be set during export when writing to a file.

public string BasePath { get; set; }

Property Value

string

BufferViews

public Array<GltfBufferView> BufferViews { get; set; }

Property Value

Array<GltfBufferView>

Buffers

public Array<byte[]> Buffers { get; set; }

Property Value

Array<byte[]>

Cameras

public Array<GltfCamera> Cameras { get; set; }

Property Value

Array<GltfCamera>

The copyright string in the asset header of the GLTF file. This is set during import if present and export if non-empty. See the GLTF asset header documentation for more information.

public string Copyright { get; set; }

Property Value

string

CreateAnimations

public bool CreateAnimations { get; set; }

Property Value

bool

FileName

The file name associated with this GLTF data. If it ends with .gltf, this is text-based GLTF, otherwise this is binary GLB. This will be set during import when appending from a file, and will be set during export when writing to a file. If writing to a buffer, this will be an empty string.

public string FileName { get; set; }

Property Value

string

GlbData

public byte[] GlbData { get; set; }

Property Value

byte[]

HandleBinaryImage

public int HandleBinaryImage { get; set; }

Property Value

int

Images

public Array<Texture2D> Images { get; set; }

Property Value

Array<Texture2D>

Json

public Dictionary Json { get; set; }

Property Value

Dictionary

Lights

public Array<GltfLight> Lights { get; set; }

Property Value

Array<GltfLight>

MajorVersion

public int MajorVersion { get; set; }

Property Value

int

Materials

public Array<Material> Materials { get; set; }

Property Value

Array<Material>

Meshes

public Array<GltfMesh> Meshes { get; set; }

Property Value

Array<GltfMesh>

MinorVersion

public int MinorVersion { get; set; }

Property Value

int

Nodes

public Array<GltfNode> Nodes { get; set; }

Property Value

Array<GltfNode>

RootNodes

The root nodes of the GLTF file. Typically, a GLTF file will only have one scene, and therefore one root node. However, a GLTF file may have multiple scenes and therefore multiple root nodes, which will be generated as siblings of each other and as children of the root node of the generated Godot scene.

public int[] RootNodes { get; set; }

Property Value

int[]

SceneName

The name of the scene. When importing, if not specified, this will be the file name. When exporting, if specified, the scene name will be saved to the GLTF file.

public string SceneName { get; set; }

Property Value

string

Skeletons

public Array<GltfSkeleton> Skeletons { get; set; }

Property Value

Array<GltfSkeleton>

Skins

public Array<GltfSkin> Skins { get; set; }

Property Value

Array<GltfSkin>

TextureSamplers

public Array<GltfTextureSampler> TextureSamplers { get; set; }

Property Value

Array<GltfTextureSampler>

Textures

public Array<GltfTexture> Textures { get; set; }

Property Value

Array<GltfTexture>

UniqueAnimationNames

public Array<string> UniqueAnimationNames { get; set; }

Property Value

Array<string>

UniqueNames

public Array<string> UniqueNames { get; set; }

Property Value

Array<string>

UseNamedSkinBinds

public bool UseNamedSkinBinds { get; set; }

Property Value

bool

Methods

AddUsedExtension(string, bool)

Appends an extension to the list of extensions used by this GLTF file during serialization. If required is true, the extension will also be added to the list of required extensions. Do not run this in _ExportPost(GltfState), as that stage is too late to add extensions. The final list is sorted alphabetically.

public void AddUsedExtension(string extensionName, bool required)

Parameters

extensionName string
required bool

GetAdditionalData(StringName)

Gets additional arbitrary data in this GltfState instance. This can be used to keep per-file state data in GltfDocumentExtension classes, which is important because they are stateless.

The argument should be the GltfDocumentExtension name (does not have to match the extension name in the GLTF file), and the return value can be anything you set. If nothing was set, the return value is null.

public Variant GetAdditionalData(StringName extensionName)

Parameters

extensionName StringName

Returns

Variant

GetAnimationPlayer(int)

Returns the AnimationPlayer node with the given index. These nodes are only used during the export process when converting Godot AnimationPlayer nodes to GLTF animations.

public AnimationPlayer GetAnimationPlayer(int idx)

Parameters

idx int

Returns

AnimationPlayer

GetAnimationPlayersCount(int)

Returns the number of AnimationPlayer nodes in this GltfState. These nodes are only used during the export process when converting Godot AnimationPlayer nodes to GLTF animations.

public int GetAnimationPlayersCount(int idx)

Parameters

idx int

Returns

int

GetNodeIndex(Node)

Returns the index of the GltfNode corresponding to this Godot scene node. This is the inverse of GetSceneNode(int). Useful during the export process.

Note: Not every Godot scene node will have a corresponding GltfNode, and not every GltfNode will have a scene node generated. If there is no GltfNode index for this scene node, -1 is returned.

public int GetNodeIndex(Node sceneNode)

Parameters

sceneNode Node

Returns

int

GetSceneNode(int)

Returns the Godot scene node that corresponds to the same index as the GltfNode it was generated from. This is the inverse of GetNodeIndex(Node). Useful during the import process.

Note: Not every GltfNode will have a scene node generated, and not every generated scene node will have a corresponding GltfNode. If there is no scene node for this GltfNode index, null is returned.

public Node GetSceneNode(int idx)

Parameters

idx int

Returns

Node

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

SetAdditionalData(StringName, Variant)

Sets additional arbitrary data in this GltfState instance. This can be used to keep per-file state data in GltfDocumentExtension classes, which is important because they are stateless.

The first argument should be the GltfDocumentExtension name (does not have to match the extension name in the GLTF file), and the second argument can be anything you want.

public void SetAdditionalData(StringName extensionName, Variant additionalData)

Parameters

extensionName StringName
additionalData Variant