reckfellENGINE

GltfDocumentExtension

GLTFDocument extension class.

On this page
class GltfDocumentExtensionReckfellSharpInherits Resource

GltfDocument extension class.

Extends the functionality of the GltfDocument class by allowing you to run arbitrary code at various stages of glTF import or export. To use, make a new class extending GLTFDocumentExtension, override any methods you need, make an instance of your class, and register it using GltfDocument.RegisterGltfDocumentExtension. Note: All GLTFDocumentExtension classes are duplicated when beginning the import or export process. Except for configuration values, these 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 GltfState or GltfNode.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

GltfDocumentExtensionConstructor
# GltfDocumentExtension
C#
public GltfDocumentExtension();

Methods24

_ConvertSceneNodevoid
# _ConvertSceneNode
C#
public virtual void _ConvertSceneNode(GltfState state, GltfNode gltfNode, Entity sceneNode);

Part of the export process. This method is run after GltfDocumentExtension._ExportPreflight and before GltfDocumentExtension._ExportPostConvert. Runs when converting the data from a Reckfell scene node. This method can be used to process the Reckfell scene node data into a format that can be used by GltfDocumentExtension._ExportNode.

Parameters
NameTypeDefault
stateGltfState—
gltfNodeGltfNode—
sceneNodeEntity—
_ExportGetPropertyListReckfell.Collections.Array<Reckfell.Collections.Dictionary>
# _ExportGetPropertyList
C#
public virtual Reckfell.Collections.Array<Reckfell.Collections.Dictionary> _ExportGetPropertyList(Entity rootEntity);

Runs prior to the export process. This method is run before GltfDocumentExtension._ExportPreflight when exporting a scene from the editor, or it may not be run at all in other situations. Unlike the rest of the export methods, this does not run when calling a GltfDocument's export methods in sequence with everything else, but rather runs before that entire process occurs, allowing configuration to occur beforehand, potentially minutes or hours in advance of GltfDocumentExtension._ExportPreflight. This allows extensions to decide which properties to show in the editor export settings dialog based on the contents of the scene, hiding any settings that are not relevant for that scene. The root_node parameter may be null, in which case all properties should be shown.

Parameters
NameTypeDefault
rootEntityEntity—
Returns Reckfell.Collections.Array<Reckfell.Collections.Dictionary>
_ExportNodeError
# _ExportNode
C#
public virtual Error _ExportNode(GltfState state, GltfNode gltfNode, Reckfell.Collections.Dictionary json, Entity node);

Part of the export process. This method is run after GltfDocumentExtension._GetSaveableImageFormats and before GltfDocumentExtension._ExportPost. If this GltfDocumentExtension is used for exporting images, this runs after GltfDocumentExtension._SerializeTextureJson. 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 Reckfell Entity is also provided if available. node may be null if not available, such as when exporting glTF data not generated from a Reckfell scene.

Parameters
NameTypeDefault
stateGltfState—
gltfNodeGltfNode—
jsonReckfell.Collections.Dictionary—
nodeEntity—
Returns Error
_ExportObjectModelPropertyGltfObjectModelProperty
# _ExportObjectModelProperty
C#
public virtual GltfObjectModelProperty _ExportObjectModelProperty(GltfState state, EntityPath entityPath, Entity reckfellNode, int gltfNodeIndex, ReckfellObject targetObject, int targetDepth);

Part of the export process. Allows GLTFDocumentExtension classes to provide mappings for properties of nodes in the Reckfell 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 GltfObjectModelProperty.HasJsonPointers). You should use GltfObjectModelProperty.SetTypes to set the types, and set the JSON pointer(s) using the GltfObjectModelProperty.JsonPointers property. The parameters provide context for the property, including the EntityPath, the Reckfell node, the GLTF node index, and the target object. The target_object will be equal to reckfell_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.

Parameters
NameTypeDefault
stateGltfState—
entityPathEntityPath—
reckfellNodeEntity—
gltfNodeIndexint—
targetObjectReckfellObject—
targetDepthint—
Returns GltfObjectModelProperty
_ExportPostError
# _ExportPost
C#
public virtual Error _ExportPost(GltfState state);

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.

Parameters
NameTypeDefault
stateGltfState—
Returns Error
_ExportPostConvertError
# _ExportPostConvert
C#
public virtual Error _ExportPostConvert(GltfState state, Entity root);

Part of the export process. This method is run after GltfDocumentExtension._ConvertSceneNode and before GltfDocumentExtension._ExportPreserialize. This method can be used to modify the converted node data structures before serialization with any additional data from the scene tree.

Parameters
NameTypeDefault
stateGltfState—
rootEntity—
Returns Error
_ExportPreflightError
# _ExportPreflight
C#
public virtual Error _ExportPreflight(GltfState state, Entity root);

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 OK, the export will use this GltfDocumentExtension instance. If not overridden, OK is returned.

Parameters
NameTypeDefault
stateGltfState—
rootEntity—
Returns Error
_ExportPreserializeError
# _ExportPreserialize
C#
public virtual Error _ExportPreserialize(GltfState state);

Part of the export process. This method is run after GltfDocumentExtension._ExportPostConvert and before GltfDocumentExtension._GetSaveableImageFormats. This method can be used to alter the state before performing serialization. It runs every time when generating a buffer with GltfDocument.GenerateBuffer or writing to the file system with GltfDocument.WriteToFilesystem.

Parameters
NameTypeDefault
stateGltfState—
Returns Error
_GenerateSceneNodeEntity3D
# _GenerateSceneNode
C#
public virtual Entity3D _GenerateSceneNode(GltfState state, GltfNode gltfNode, Entity sceneParent);

Part of the import process. This method is run after GltfDocumentExtension._ImportPreGenerate and before GltfDocumentExtension._ImportNode. Runs when generating a Reckfell 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.

Parameters
NameTypeDefault
stateGltfState—
gltfNodeGltfNode—
sceneParentEntity—
Returns Entity3D
_GetImageFileExtensionstring
# _GetImageFileExtension
C#
public virtual string _GetImageFileExtension();

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, Reckfell will save the image into a PNG file.

Returns string
_GetSaveableImageFormatsstring[]
# _GetSaveableImageFormats
C#
public virtual string[] _GetSaveableImageFormats();

Part of the export process. This method is run after GltfDocumentExtension._ConvertSceneNode and before GltfDocumentExtension._ExportNode. 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 GltfDocument.ImageFormat is in this array. If this GltfDocumentExtension is selected as the image exporter, one of the GltfDocumentExtension._SaveImageAtPath or GltfDocumentExtension._SerializeImageToBytes methods will run next, otherwise GltfDocumentExtension._ExportNode will run next. If the format name contains "Lossy", the lossy quality slider will be displayed.

Returns string[]
_GetSupportedExtensionsstring[]
# _GetSupportedExtensions
C#
public virtual string[] _GetSupportedExtensions();

Part of the import process. This method is run after GltfDocumentExtension._ImportPreflight and before GltfDocumentExtension._ParseNodeExtensions. 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.

Returns string[]
_ImportNodeError
# _ImportNode
C#
public virtual Error _ImportNode(GltfState state, GltfNode gltfNode, Reckfell.Collections.Dictionary json, Entity node);

Part of the import process. This method is run after GltfDocumentExtension._GenerateSceneNode and before GltfDocumentExtension._ImportPost. This method can be used to make modifications to each of the generated Reckfell scene nodes.

Parameters
NameTypeDefault
stateGltfState—
gltfNodeGltfNode—
jsonReckfell.Collections.Dictionary—
nodeEntity—
Returns Error
_ImportObjectModelPropertyGltfObjectModelProperty
# _ImportObjectModelProperty
C#
public virtual GltfObjectModelProperty _ImportObjectModelProperty(GltfState state, string[] splitJsonPointer, Reckfell.Collections.Array<EntityPath> partialPaths);

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 Reckfell 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 EntityPaths (see GltfObjectModelProperty.HasEntityPaths). You should use GltfObjectModelProperty.SetTypes to set the types, and GltfObjectModelProperty.AppendPathToProperty 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, Reckfell will pass you a EntityPath 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].

Parameters
NameTypeDefault
stateGltfState—
splitJsonPointerstring[]—
partialPathsReckfell.Collections.Array<EntityPath>—
Returns GltfObjectModelProperty
_ImportPostError
# _ImportPost
C#
public virtual Error _ImportPost(GltfState state, Entity root);

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 Reckfell scene generated by the import process.

Parameters
NameTypeDefault
stateGltfState—
rootEntity—
Returns Error
_ImportPostParseError
# _ImportPostParse
C#
public virtual Error _ImportPostParse(GltfState state);

Part of the import process. This method is run after GltfDocumentExtension._ParseNodeExtensions and before GltfDocumentExtension._ImportPreGenerate. 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.

Parameters
NameTypeDefault
stateGltfState—
Returns Error
_ImportPreGenerateError
# _ImportPreGenerate
C#
public virtual Error _ImportPreGenerate(GltfState state);

Part of the import process. This method is run after GltfDocumentExtension._ImportPostParse and before GltfDocumentExtension._GenerateSceneNode. 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.

Parameters
NameTypeDefault
stateGltfState—
Returns Error
_ImportPreflightError
# _ImportPreflight
C#
public virtual Error _ImportPreflight(GltfState state, string[] extensions);

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 OK, the import will use this GltfDocumentExtension instance. If not overridden, OK is returned.

Parameters
NameTypeDefault
stateGltfState—
extensionsstring[]—
Returns Error
_ParseImageDataError
# _ParseImageData
C#
public virtual Error _ParseImageData(GltfState state, byte[] imageData, string mimeType, Image retImage);

Part of the import process. This method is run after GltfDocumentExtension._ParseNodeExtensions and before GltfDocumentExtension._ParseTextureJson. 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.

Parameters
NameTypeDefault
stateGltfState—
imageDatabyte[]—
mimeTypestring—
retImageImage—
Returns Error
_ParseNodeExtensionsError
# _ParseNodeExtensions
C#
public virtual Error _ParseNodeExtensions(GltfState state, GltfNode gltfNode, Reckfell.Collections.Dictionary extensions);

Part of the import process. This method is run after GltfDocumentExtension._GetSupportedExtensions and before GltfDocumentExtension._ImportPostParse. 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 GltfDocumentExtension._GenerateSceneNode. The return value should be a member of the Error enum.

Parameters
NameTypeDefault
stateGltfState—
gltfNodeGltfNode—
extensionsReckfell.Collections.Dictionary—
Returns Error
_ParseTextureJsonError
# _ParseTextureJson
C#
public virtual Error _ParseTextureJson(GltfState state, Reckfell.Collections.Dictionary textureJson, GltfTexture retGltfTexture);

Part of the import process. This method is run after GltfDocumentExtension._ParseImageData and before GltfDocumentExtension._GenerateSceneNode. 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.

Parameters
NameTypeDefault
stateGltfState—
textureJsonReckfell.Collections.Dictionary—
retGltfTextureGltfTexture—
Returns Error
_SaveImageAtPathError
# _SaveImageAtPath
C#
public virtual Error _SaveImageAtPath(GltfState state, Image image, string filePath, string imageFormat, float lossyQuality);

Part of the export process. This method is run after GltfDocumentExtension._GetSaveableImageFormats and before GltfDocumentExtension._SerializeTextureJson. This method is run when saving images separately from the glTF file. When images are embedded, GltfDocumentExtension._SerializeImageToBytes runs instead. Note that these methods only run when this GltfDocumentExtension is selected as the image exporter.

Parameters
NameTypeDefault
stateGltfState—
imageImage—
filePathstring—
imageFormatstring—
lossyQualityfloat—
Returns Error
_SerializeImageToBytesbyte[]
# _SerializeImageToBytes
C#
public virtual byte[] _SerializeImageToBytes(GltfState state, Image image, Reckfell.Collections.Dictionary imageDict, string imageFormat, float lossyQuality);

Part of the export process. This method is run after GltfDocumentExtension._GetSaveableImageFormats and before GltfDocumentExtension._SerializeTextureJson. This method is run when embedding images in the glTF file. When images are saved separately, GltfDocumentExtension._SaveImageAtPath 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 byte[] containing the image data.

Parameters
NameTypeDefault
stateGltfState—
imageImage—
imageDictReckfell.Collections.Dictionary—
imageFormatstring—
lossyQualityfloat—
Returns byte[]
_SerializeTextureJsonError
# _SerializeTextureJson
C#
public virtual Error _SerializeTextureJson(GltfState state, Reckfell.Collections.Dictionary textureJson, GltfTexture gltfTexture, string imageFormat);

Part of the export process. This method is run after GltfDocumentExtension._SaveImageAtPath or GltfDocumentExtension._SerializeImageToBytes, and before GltfDocumentExtension._ExportNode. 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 GltfState.AddUsedExtension, be sure to set required to true if you are not providing a fallback.

Parameters
NameTypeDefault
stateGltfState—
textureJsonReckfell.Collections.Dictionary—
gltfTextureGltfTexture—
imageFormatstring—
Returns Error
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.