Skip to main content

IGltfDocumentExtensionConvertImporterMesh

Trait IGltfDocumentExtensionConvertImporterMesh 

pub trait IGltfDocumentExtensionConvertImporterMesh: GodotClass<Base = GltfDocumentExtensionConvertImporterMesh> + You_forgot_the_attribute__godot_api {
Show 35 methods // Provided methods fn init(base: Base<Self::Base>) -> Self { ... } fn on_notification(&mut self, what: ObjectNotification) { ... } fn on_get(&self, property: StringName) -> Option<Variant> { ... } fn on_set(&mut self, property: StringName, value: Variant) -> bool { ... } fn on_validate_property(&self, property: &mut PropertyInfo) { ... } fn on_get_property_list(&mut self) -> Vec<PropertyInfo> { ... } fn on_property_get_revert(&self, property: StringName) -> Option<Variant> { ... } fn to_string(&self) -> GString { ... } fn import_preflight( &mut self, state: Option<Gd<GltfState>>, extensions: PackedArray<GString>, ) -> Error { ... } fn get_supported_extensions(&mut self) -> PackedArray<GString> { ... } fn parse_node_extensions( &mut self, state: Option<Gd<GltfState>>, gltf_node: Option<Gd<GltfNode>>, extensions: Dictionary<Variant, Variant>, ) -> Error { ... } fn parse_image_data( &mut self, state: Option<Gd<GltfState>>, image_data: PackedArray<u8>, mime_type: GString, ret_image: Option<Gd<Image>>, ) -> Error { ... } fn get_image_file_extension(&mut self) -> GString { ... } fn parse_texture_json( &mut self, state: Option<Gd<GltfState>>, texture_json: Dictionary<Variant, Variant>, ret_gltf_texture: Option<Gd<GltfTexture>>, ) -> Error { ... } fn import_object_model_property( &mut self, state: Option<Gd<GltfState>>, split_json_pointer: PackedArray<GString>, partial_paths: Array<NodePath>, ) -> Option<Gd<GltfObjectModelProperty>> { ... } fn import_post_parse(&mut self, state: Option<Gd<GltfState>>) -> Error { ... } fn import_pre_generate(&mut self, state: Option<Gd<GltfState>>) -> Error { ... } fn generate_scene_node( &mut self, state: Option<Gd<GltfState>>, gltf_node: Option<Gd<GltfNode>>, scene_parent: Option<Gd<Node>>, ) -> Option<Gd<Node3D>> { ... } fn import_node( &mut self, state: Option<Gd<GltfState>>, gltf_node: Option<Gd<GltfNode>>, json: Dictionary<Variant, Variant>, node: Option<Gd<Node>>, ) -> Error { ... } fn import_post( &mut self, state: Option<Gd<GltfState>>, root: Option<Gd<Node>>, ) -> Error { ... } fn export_preflight( &mut self, state: Option<Gd<GltfState>>, root: Option<Gd<Node>>, ) -> Error { ... } fn convert_scene_node( &mut self, state: Option<Gd<GltfState>>, gltf_node: Option<Gd<GltfNode>>, scene_node: Option<Gd<Node>>, ) { ... } fn export_post_convert( &mut self, state: Option<Gd<GltfState>>, root: Option<Gd<Node>>, ) -> Error { ... } fn export_preserialize(&mut self, state: Option<Gd<GltfState>>) -> Error { ... } fn export_object_model_property( &mut self, state: Option<Gd<GltfState>>, node_path: NodePath, godot_node: Option<Gd<Node>>, gltf_node_index: i32, target_object: Option<Gd<Object>>, target_depth: i32, ) -> Option<Gd<GltfObjectModelProperty>> { ... } fn get_saveable_image_formats(&mut self) -> PackedArray<GString> { ... } fn serialize_image_to_bytes( &mut self, state: Option<Gd<GltfState>>, image: Option<Gd<Image>>, image_dict: Dictionary<Variant, Variant>, image_format: GString, lossy_quality: f32, ) -> PackedArray<u8> { ... } fn save_image_at_path( &mut self, state: Option<Gd<GltfState>>, image: Option<Gd<Image>>, file_path: GString, image_format: GString, lossy_quality: f32, ) -> Error { ... } fn serialize_texture_json( &mut self, state: Option<Gd<GltfState>>, texture_json: Dictionary<Variant, Variant>, gltf_texture: Option<Gd<GltfTexture>>, image_format: GString, ) -> Error { ... } fn export_node( &mut self, state: Option<Gd<GltfState>>, gltf_node: Option<Gd<GltfNode>>, json: Dictionary<Variant, Variant>, node: Option<Gd<Node>>, ) -> Error { ... } fn export_post(&mut self, state: Option<Gd<GltfState>>) -> Error { ... } fn setup_local_to_scene(&mut self) { ... } fn get_rid(&self) -> Rid { ... } fn reset_state(&mut self) { ... } fn set_path_cache(&self, path: GString) { ... }
}
Expand description

§Interface trait for class GltfDocumentExtensionConvertImporterMesh.

Functions in this trait represent constructors (init) or virtual method callbacks invoked by the engine.

Base interfaces: IGltfDocumentExtension > IResource > IRefCounted > IObject.

See also Godot docs for GLTFDocumentExtensionConvertImporterMesh methods.

Provided Methods§

fn init(base: Base<Self::Base>) -> Self

Godot constructor, accepting an injected base object.

base refers to the base instance of the class, which can either be stored in a Base<T> field or discarded. This method returns a fully-constructed instance, which will then be moved into a Gd<T> pointer.

If the class has a #[class(init)] attribute, this method will be auto-generated and must not be overridden.

fn on_notification(&mut self, what: ObjectNotification)

Called when the object receives a Godot notification.

The type of notification can be identified through what. The enum is designed to hold all possible NOTIFICATION_* constants that the current class can handle. However, this is not validated in Godot, so an enum variant Unknown exists to represent integers out of known constants (mistakes or future additions).

This method is named _notification in Godot, but on_notification in Rust. To send notifications, use the Object::notify method.

See also in Godot docs:

fn on_get(&self, property: StringName) -> Option<Variant>

Called whenever get() is called or Godot gets the value of a property.

Should return the given property’s value as Some(value), or None if the property should be handled normally.

See also in Godot docs:

fn on_set(&mut self, property: StringName, value: Variant) -> bool

Called whenever Godot set() is called or Godot sets the value of a property.

Should set property to the given value and return true, or return false to indicate the property should be handled normally.

See also in Godot docs:

fn on_validate_property(&self, property: &mut PropertyInfo)

Called whenever Godot retrieves value of property. Allows to customize existing properties. Every property info goes through this method, except properties added with on_get_property_list().

Exposed property here is a shared mutable reference obtained (and returned to) from Godot.

See also in the Godot docs:

fn on_get_property_list(&mut self) -> Vec<PropertyInfo>

Available on since_api=4.3 only.

Called whenever Godot get_property_list() is called, the returned vector here is appended to the existing list of properties.

This should mainly be used for advanced purposes, such as dynamically updating the property list in the editor.

See also in Godot docs:

fn on_property_get_revert(&self, property: StringName) -> Option<Variant>

Called by Godot to tell if a property has a custom revert or not.

Return None for no custom revert, and return Some(value) to specify the custom revert.

This is a combination of Godot’s Object::_property_get_revert and Object::_property_can_revert. This means that this function will usually be called twice by Godot to find the revert.

Note that this should be a pure function. That is, it should always return the same value for a property as long as self remains unchanged. Otherwise, this may lead to unexpected (safe) behavior.

fn to_string(&self) -> GString

String representation of the Godot instance.

Override this method to define how the instance is represented as a string. Used by impl Display for Gd<T>, as well as str() and print() in GDScript.

fn import_preflight( &mut self, state: Option<Gd<GltfState>>, extensions: PackedArray<GString>, ) -> Error

Part of the import process. This method is run first, before all other parts of the import process.

The return value is used to determine if this GLTFDocumentExtension instance should be used for importing a given glTF file. If Error::OK, the import will use this GLTFDocumentExtension instance. If not overridden, Error::OK is returned.

fn get_supported_extensions(&mut self) -> PackedArray<GString>

Part of the import process. This method is run after import_preflight and before parse_node_extensions.

Returns an array of the glTF extensions supported by this GLTFDocumentExtension class. This is used to validate if a glTF file with required extensions can be loaded.

fn parse_node_extensions( &mut self, state: Option<Gd<GltfState>>, gltf_node: Option<Gd<GltfNode>>, extensions: Dictionary<Variant, Variant>, ) -> Error

Part of the import process. This method is run after get_supported_extensions and before import_post_parse.

Runs when parsing the node extensions of a GLTFNode. This method can be used to process the extension JSON data into a format that can be used by generate_scene_node. The return value should be a member of the [enum Error] enum.

fn parse_image_data( &mut self, state: Option<Gd<GltfState>>, image_data: PackedArray<u8>, mime_type: GString, ret_image: Option<Gd<Image>>, ) -> Error

Part of the import process. This method is run after parse_node_extensions and before parse_texture_json.

Runs when parsing image data from a glTF file. The data could be sourced from a separate file, a URI, or a buffer, and then is passed as a byte array.

fn get_image_file_extension(&mut self) -> GString

Returns the file extension to use for saving image data into, for example, ".png". If defined, when this extension is used to handle images, and the images are saved to a separate file, the image bytes will be copied to a file with this extension. If this is set, there should be a ResourceImporter class able to import the file. If not defined or empty, Godot will save the image into a PNG file.

fn parse_texture_json( &mut self, state: Option<Gd<GltfState>>, texture_json: Dictionary<Variant, Variant>, ret_gltf_texture: Option<Gd<GltfTexture>>, ) -> Error

Part of the import process. This method is run after parse_image_data and before generate_scene_node.

Runs when parsing the texture JSON from the glTF textures array. This can be used to set the source image index to use as the texture.

fn import_object_model_property( &mut self, state: Option<Gd<GltfState>>, split_json_pointer: PackedArray<GString>, partial_paths: Array<NodePath>, ) -> Option<Gd<GltfObjectModelProperty>>

Part of the import process. Allows GLTFDocumentExtension classes to provide mappings for JSON pointers to glTF properties, as defined by the glTF object model, to properties of nodes in the Godot scene tree.

Returns a GLTFObjectModelProperty instance that defines how the property should be mapped. If your extension can’t handle the property, return null or an instance without any NodePaths (see has_node_paths). You should use set_types to set the types, and append_path_to_property function is useful for most simple cases.

In many cases, partial_paths will contain the start of a path, allowing the extension to complete the path. For example, for /nodes/3/extensions/MY_ext/prop, Godot will pass you a NodePath that leads to node 3, so the GLTFDocumentExtension class only needs to resolve the last MY_ext/prop part of the path. In this example, the extension should check split.size() > 4 and split[0] == "nodes" and split[2] == "extensions" and split[3] == "MY_ext" at the start of the function to check if this JSON pointer applies to it, then it can use partial_paths and handle split[4].

fn import_post_parse(&mut self, state: Option<Gd<GltfState>>) -> Error

Part of the import process. This method is run after parse_node_extensions and before import_pre_generate.

This method can be used to modify any of the data imported so far after parsing each node, but before generating the scene or any of its nodes.

fn import_pre_generate(&mut self, state: Option<Gd<GltfState>>) -> Error

Part of the import process. This method is run after import_post_parse and before generate_scene_node.

This method can be used to modify or read from any of the processed data structures, before generating the nodes and then running the final per-node import step.

fn generate_scene_node( &mut self, state: Option<Gd<GltfState>>, gltf_node: Option<Gd<GltfNode>>, scene_parent: Option<Gd<Node>>, ) -> Option<Gd<Node3D>>

Part of the import process. This method is run after import_pre_generate and before import_node.

Runs when generating a Godot scene node from a GLTFNode. The returned node will be added to the scene tree. Multiple nodes can be generated in this step if they are added as a child of the returned node.

Note: The scene_parent parameter may be null if this is the single root node.

fn import_node( &mut self, state: Option<Gd<GltfState>>, gltf_node: Option<Gd<GltfNode>>, json: Dictionary<Variant, Variant>, node: Option<Gd<Node>>, ) -> Error

Part of the import process. This method is run after generate_scene_node and before import_post.

This method can be used to make modifications to each of the generated Godot scene nodes.

fn import_post( &mut self, state: Option<Gd<GltfState>>, root: Option<Gd<Node>>, ) -> Error

Part of the import process. This method is run last, after all other parts of the import process.

This method can be used to modify the final Godot scene generated by the import process.

fn export_preflight( &mut self, state: Option<Gd<GltfState>>, root: Option<Gd<Node>>, ) -> Error

Part of the export process. This method is run first, before all other parts of the export process.

The return value is used to determine if this GLTFDocumentExtension instance should be used for exporting a given glTF file. If Error::OK, the export will use this GLTFDocumentExtension instance. If not overridden, Error::OK is returned.

fn convert_scene_node( &mut self, state: Option<Gd<GltfState>>, gltf_node: Option<Gd<GltfNode>>, scene_node: Option<Gd<Node>>, )

Part of the export process. This method is run after export_preflight and before export_post_convert.

Runs when converting the data from a Godot scene node. This method can be used to process the Godot scene node data into a format that can be used by export_node.

fn export_post_convert( &mut self, state: Option<Gd<GltfState>>, root: Option<Gd<Node>>, ) -> Error

Part of the export process. This method is run after convert_scene_node and before export_preserialize.

This method can be used to modify the converted node data structures before serialization with any additional data from the scene tree.

fn export_preserialize(&mut self, state: Option<Gd<GltfState>>) -> Error

Part of the export process. This method is run after export_post_convert and before get_saveable_image_formats.

This method can be used to alter the state before performing serialization. It runs every time when generating a buffer with generate_buffer or writing to the file system with write_to_filesystem.

fn export_object_model_property( &mut self, state: Option<Gd<GltfState>>, node_path: NodePath, godot_node: Option<Gd<Node>>, gltf_node_index: i32, target_object: Option<Gd<Object>>, target_depth: i32, ) -> Option<Gd<GltfObjectModelProperty>>

Part of the export process. Allows GLTFDocumentExtension classes to provide mappings for properties of nodes in the Godot scene tree, to JSON pointers to glTF properties, as defined by the glTF object model.

Returns a GLTFObjectModelProperty instance that defines how the property should be mapped. If your extension can’t handle the property, return null or an instance without any JSON pointers (see has_json_pointers). You should use set_types to set the types, and set the JSON pointer(s) using the [member GLTFObjectModelProperty.json_pointers] property.

The parameters provide context for the property, including the NodePath, the Godot node, the GLTF node index, and the target object. The target_object will be equal to godot_node if no sub-object can be found, otherwise it will point to a sub-object. For example, if the path is ^"A/B/C/MeshInstance3D:mesh:surface_0/material:emission_intensity", it will get the node, then the mesh, and then the material, so target_object will be the Material resource, and target_depth will be 2 because 2 levels were traversed to get to the target.

fn get_saveable_image_formats(&mut self) -> PackedArray<GString>

Part of the export process. This method is run after convert_scene_node and before export_node.

Returns an array of the image formats that can be saved/exported by this extension. This extension will only be selected as the image exporter if the GLTFDocument’s [member GLTFDocument.image_format] is in this array. If this GLTFDocumentExtension is selected as the image exporter, one of the save_image_at_path or serialize_image_to_bytes methods will run next, otherwise export_node will run next. If the format name contains "Lossy", the lossy quality slider will be displayed.

fn serialize_image_to_bytes( &mut self, state: Option<Gd<GltfState>>, image: Option<Gd<Image>>, image_dict: Dictionary<Variant, Variant>, image_format: GString, lossy_quality: f32, ) -> PackedArray<u8>

Part of the export process. This method is run after get_saveable_image_formats and before serialize_texture_json.

This method is run when embedding images in the glTF file. When images are saved separately, save_image_at_path runs instead. Note that these methods only run when this GLTFDocumentExtension is selected as the image exporter.

This method must set the image MIME type in the image_dict with the "mimeType" key. For example, for a PNG image, it would be set to "image/png". The return value must be a PackedByteArray containing the image data.

fn save_image_at_path( &mut self, state: Option<Gd<GltfState>>, image: Option<Gd<Image>>, file_path: GString, image_format: GString, lossy_quality: f32, ) -> Error

Part of the export process. This method is run after get_saveable_image_formats and before serialize_texture_json.

This method is run when saving images separately from the glTF file. When images are embedded, serialize_image_to_bytes runs instead. Note that these methods only run when this GLTFDocumentExtension is selected as the image exporter.

fn serialize_texture_json( &mut self, state: Option<Gd<GltfState>>, texture_json: Dictionary<Variant, Variant>, gltf_texture: Option<Gd<GltfTexture>>, image_format: GString, ) -> Error

Part of the export process. This method is run after save_image_at_path or serialize_image_to_bytes, and before export_node. Note that this method only runs when this GLTFDocumentExtension is selected as the image exporter.

This method can be used to set up the extensions for the texture JSON by editing texture_json. The extension must also be added as used extension with add_used_extension, be sure to set required to true if you are not providing a fallback.

fn export_node( &mut self, state: Option<Gd<GltfState>>, gltf_node: Option<Gd<GltfNode>>, json: Dictionary<Variant, Variant>, node: Option<Gd<Node>>, ) -> Error

Part of the export process. This method is run after get_saveable_image_formats and before export_post. If this GLTFDocumentExtension is used for exporting images, this runs after serialize_texture_json.

This method can be used to modify the final JSON of each node. Data should be primarily stored in gltf_node prior to serializing the JSON, but the original Godot Node is also provided if available. node may be null if not available, such as when exporting glTF data not generated from a Godot scene.

fn export_post(&mut self, state: Option<Gd<GltfState>>) -> Error

Part of the export process. This method is run last, after all other parts of the export process.

This method can be used to modify the final JSON of the generated glTF file.

fn setup_local_to_scene(&mut self)

Override this method to customize the newly duplicated resource created from instantiate, if the original’s [member resource_local_to_scene] is set to true.

Example: Set a random damage value to every local resource from an instantiated scene:

extends Resource

var damage = 0

func _setup_local_to_scene():
	damage = randi_range(10, 40)

fn get_rid(&self) -> Rid

Override this method to return a custom RID when get_rid is called.

fn reset_state(&mut self)

For resources that store state in non-exported properties, such as via on_validate_property or on_get_property_list, this method must be implemented to clear them.

fn set_path_cache(&self, path: GString)

Override this method to execute additional logic after set_path_cache is called on this object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§