Documentation
¶
Overview ¶
GLTFDocument supports reading data from a glTF file, buffer, or Godot scene. This data can then be written to the filesystem, buffer, or used to create a Godot scene.
All of the data in a glTF scene is stored in the graphics.gd/classdb/GLTFState class. GLTFDocument processes state objects, but does not contain any scene data itself. GLTFDocument has member variables to store export configuration settings such as the image format, but is otherwise stateless. Multiple scenes can be processed with the same settings using the same GLTFDocument object and different graphics.gd/classdb/GLTFState objects.
GLTFDocument can be extended with arbitrary functionality by extending the graphics.gd/classdb/GLTFDocumentExtension class and registering it with GLTFDocument via RegisterGltfDocumentExtension. This allows for custom data to be imported and exported.
Index ¶
- func ExportObjectModelProperty(state GLTFState.Instance, node_path string, godot_node Node.Instance, ...) GLTFObjectModelProperty.Instance
- func GetSupportedGltfExtensions() []string
- func ImportObjectModelProperty(state GLTFState.Instance, json_pointer string) GLTFObjectModelProperty.Instance
- func RegisterGltfDocumentExtension(extension GLTFDocumentExtension.Instance, first_priority bool)
- func RegisterGltfDocumentExtensionOptions(extension GLTFDocumentExtension.Instance, first_priority bool)
- func UnregisterGltfDocumentExtension(extension GLTFDocumentExtension.Instance)
- type Advanced
- type Any
- type Expanded
- func (self Expanded) AppendFromBuffer(bytes []byte, base_path string, state GLTFState.Instance, flags int) error
- func (self Expanded) AppendFromFile(path string, state GLTFState.Instance, flags int, base_path string) error
- func (self Expanded) AppendFromScene(node Node.Instance, state GLTFState.Instance, flags int) error
- func (self Expanded) GenerateScene(state GLTFState.Instance, bake_fps Float.X, trimming bool, ...) Node.Instance
- type Extension
- type ID
- type Instance
- func (self Instance) AppendFromBuffer(bytes []byte, base_path string, state GLTFState.Instance) error
- func (self Instance) AppendFromFile(path string, state GLTFState.Instance) error
- func (self Instance) AppendFromScene(node Node.Instance, state GLTFState.Instance) error
- func (self Instance) AsGLTFDocument() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) FallbackImageFormat() string
- func (self Instance) FallbackImageQuality() Float.X
- func (self Instance) GenerateBuffer(state GLTFState.Instance) []byte
- func (self Instance) GenerateScene(state GLTFState.Instance) Node.Instance
- func (self Instance) ID() ID
- func (self Instance) ImageFormat() string
- func (self Instance) LossyQuality() Float.X
- func (self Instance) RootNodeMode() RootNodeMode
- func (self Instance) SetFallbackImageFormat(value string)
- func (self Instance) SetFallbackImageQuality(value Float.X)
- func (self Instance) SetImageFormat(value string)
- func (self Instance) SetLossyQuality(value Float.X)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetRootNodeMode(value RootNodeMode)
- func (self Instance) SetVisibilityMode(value VisibilityMode)
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) VisibilityMode() VisibilityMode
- func (self Instance) WriteToFilesystem(state GLTFState.Instance, path string) error
- type RootNodeMode
- type VisibilityMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportObjectModelProperty ¶
func ExportObjectModelProperty(state GLTFState.Instance, node_path string, godot_node Node.Instance, gltf_node_index int) GLTFObjectModelProperty.Instance
Determines a mapping between the given Godot 'node_path' and the corresponding glTF Object Model JSON pointer(s) in the generated glTF file. The details of this mapping are returned in a graphics.gd/classdb/GLTFObjectModelProperty object. Additional mappings can be supplied via the graphics.gd/classdb/GLTFDocumentExtension.Instance.ImportObjectModelProperty callback method.
func GetSupportedGltfExtensions ¶
func GetSupportedGltfExtensions() []string
Returns a list of all support glTF extensions, including extensions supported directly by the engine, and extensions supported by user plugins registering graphics.gd/classdb/GLTFDocumentExtension classes.
Note: If this method is run before a GLTFDocumentExtension is registered, its extensions won't be included in the list. Be sure to only run this method after all extensions are registered. If you run this when the engine starts, consider waiting a frame before calling this method to ensure all extensions are registered.
func ImportObjectModelProperty ¶
func ImportObjectModelProperty(state GLTFState.Instance, json_pointer string) GLTFObjectModelProperty.Instance
Determines a mapping between the given glTF Object Model 'json_pointer' and the corresponding Godot node path(s) in the generated Godot scene. The details of this mapping are returned in a graphics.gd/classdb/GLTFObjectModelProperty object. Additional mappings can be supplied via the graphics.gd/classdb/GLTFDocumentExtension.Instance.ExportObjectModelProperty callback method.
func RegisterGltfDocumentExtension ¶
func RegisterGltfDocumentExtension(extension GLTFDocumentExtension.Instance, first_priority bool)
Registers the given graphics.gd/classdb/GLTFDocumentExtension instance with GLTFDocument. If 'first_priority' is true, this extension will be run first. Otherwise, it will be run last.
Note: Like GLTFDocument itself, all GLTFDocumentExtension classes must be stateless in order to function properly. If you need to store data, use the set_additional_data and get_additional_data methods in graphics.gd/classdb/GLTFState or graphics.gd/classdb/GLTFNode.
func RegisterGltfDocumentExtensionOptions ¶
func RegisterGltfDocumentExtensionOptions(extension GLTFDocumentExtension.Instance, first_priority bool)
Registers the given graphics.gd/classdb/GLTFDocumentExtension instance with GLTFDocument. If 'first_priority' is true, this extension will be run first. Otherwise, it will be run last.
Note: Like GLTFDocument itself, all GLTFDocumentExtension classes must be stateless in order to function properly. If you need to store data, use the set_additional_data and get_additional_data methods in graphics.gd/classdb/GLTFState or graphics.gd/classdb/GLTFNode.
func UnregisterGltfDocumentExtension ¶
func UnregisterGltfDocumentExtension(extension GLTFDocumentExtension.Instance)
Unregisters the given graphics.gd/classdb/GLTFDocumentExtension instance.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Expanded ¶
type Expanded [1]gdclass.GLTFDocument
func (Expanded) AppendFromBuffer ¶
func (self Expanded) AppendFromBuffer(bytes []byte, base_path string, state GLTFState.Instance, flags int) error
Takes a []byte defining a glTF and imports the data to the given graphics.gd/classdb/GLTFState object through the 'state' parameter.
Note: The 'base_path' tells Instance.AppendFromBuffer where to find dependencies and can be empty.
func (Expanded) AppendFromFile ¶
func (self Expanded) AppendFromFile(path string, state GLTFState.Instance, flags int, base_path string) error
Takes a path to a glTF file and imports the data at that file path to the given graphics.gd/classdb/GLTFState object through the 'state' parameter.
Note: The 'base_path' tells Instance.AppendFromFile where to find dependencies and can be empty.
func (Expanded) AppendFromScene ¶
Takes a Godot Engine scene node and exports it and its descendants to the given graphics.gd/classdb/GLTFState object through the 'state' parameter.
func (Expanded) GenerateScene ¶
func (self Expanded) GenerateScene(state GLTFState.Instance, bake_fps Float.X, trimming bool, remove_immutable_tracks bool) Node.Instance
Takes a graphics.gd/classdb/GLTFState object through the 'state' parameter and returns a Godot Engine scene node.
The 'bake_fps' parameter overrides the bake_fps in 'state'.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsGLTFDocument ¶
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.GLTFDocument
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AppendFromBuffer ¶
func (self Instance) AppendFromBuffer(bytes []byte, base_path string, state GLTFState.Instance) error
Takes a []byte defining a glTF and imports the data to the given graphics.gd/classdb/GLTFState object through the 'state' parameter.
Note: The 'base_path' tells Instance.AppendFromBuffer where to find dependencies and can be empty.
func (Instance) AppendFromFile ¶
Takes a path to a glTF file and imports the data at that file path to the given graphics.gd/classdb/GLTFState object through the 'state' parameter.
Note: The 'base_path' tells Instance.AppendFromFile where to find dependencies and can be empty.
func (Instance) AppendFromScene ¶
Takes a Godot Engine scene node and exports it and its descendants to the given graphics.gd/classdb/GLTFState object through the 'state' parameter.
func (Instance) AsGLTFDocument ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) FallbackImageFormat ¶
func (Instance) FallbackImageQuality ¶
func (Instance) GenerateBuffer ¶
Takes a graphics.gd/classdb/GLTFState object through the 'state' parameter and returns a glTF []byte.
func (Instance) GenerateScene ¶
Takes a graphics.gd/classdb/GLTFState object through the 'state' parameter and returns a Godot Engine scene node.
The 'bake_fps' parameter overrides the bake_fps in 'state'.
func (Instance) ImageFormat ¶
func (Instance) LossyQuality ¶
func (Instance) RootNodeMode ¶
func (self Instance) RootNodeMode() RootNodeMode
func (Instance) SetFallbackImageFormat ¶
func (Instance) SetFallbackImageQuality ¶
func (Instance) SetImageFormat ¶
func (Instance) SetLossyQuality ¶
func (Instance) SetRootNodeMode ¶
func (self Instance) SetRootNodeMode(value RootNodeMode)
func (Instance) SetVisibilityMode ¶
func (self Instance) SetVisibilityMode(value VisibilityMode)
func (Instance) VisibilityMode ¶
func (self Instance) VisibilityMode() VisibilityMode
func (Instance) WriteToFilesystem ¶
Takes a graphics.gd/classdb/GLTFState object through the 'state' parameter and writes a glTF file to the filesystem.
Note: The extension of the glTF file determines if it is a .glb binary file or a .gltf text file.
type RootNodeMode ¶
type RootNodeMode int //gd:GLTFDocument.RootNodeMode
const ( // Treat the Godot scene's root node as the root node of the glTF file, and mark it as the single root node via the GODOT_single_root glTF extension. This will be parsed the same as [RootNodeModeKeepRoot] if the implementation does not support GODOT_single_root. RootNodeModeSingleRoot RootNodeMode = 0 // Treat the Godot scene's root node as the root node of the glTF file, but do not mark it as anything special. An extra root node will be generated when importing into Godot. This uses only vanilla glTF features. This is equivalent to the behavior in Godot 4.1 and earlier. RootNodeModeKeepRoot RootNodeMode = 1 // Treat the Godot scene's root node as the name of the glTF scene, and add all of its children as root nodes of the glTF file. This uses only vanilla glTF features. This avoids an extra root node, but only the name of the Godot scene's root node will be preserved, as it will not be saved as a node. RootNodeModeMultiRoot RootNodeMode = 2 )
type VisibilityMode ¶
type VisibilityMode int //gd:GLTFDocument.VisibilityMode
const ( // If the scene contains any non-visible nodes, include them, mark them as non-visible with KHR_node_visibility, and require that importers respect their non-visibility. Downside: If the importer does not support KHR_node_visibility, the file cannot be imported. VisibilityModeIncludeRequired VisibilityMode = 0 // If the scene contains any non-visible nodes, include them, mark them as non-visible with KHR_node_visibility, and do not impose any requirements on importers. Downside: If the importer does not support KHR_node_visibility, invisible objects will be visible. VisibilityModeIncludeOptional VisibilityMode = 1 // If the scene contains any non-visible nodes, do not include them in the export. This is the same as the behavior in Godot 4.4 and earlier. Downside: Invisible nodes will not exist in the exported file. VisibilityModeExclude VisibilityMode = 2 )