GltfState
Represents all data of a glTF file.
Represents all data of a glTF file.
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 Reckfell scene. Then the data can either be used to create a Reckfell scene or save to a glTF file. The code that converts to/from a Reckfell 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 Reckfell nodes.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
GltfStateConstructor
public GltfState();Properties31
AccessorsProperty
public Reckfell.Collections.Array<GltfAccessor> Accessors { get; set; }AnimationsProperty
public Reckfell.Collections.Array<GltfAnimation> Animations { get; set; }BakeFpsProperty
public double BakeFps { get; set; }The baking fps of the animation for either import or export.
BasePathProperty
public string BasePath { get; set; }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.
BufferViewsProperty
public Reckfell.Collections.Array<GltfBufferView> BufferViews { get; set; }BuffersProperty
public Reckfell.Collections.Array<byte[]> Buffers { get; set; }CamerasProperty
public Reckfell.Collections.Array<GltfCamera> Cameras { get; set; }CopyrightProperty
public string Copyright { get; set; }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.
CreateAnimationsProperty
public bool CreateAnimations { get; set; }FileNameProperty
public string FileName { get; set; }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.
GlbDataProperty
public byte[] GlbData { get; set; }The binary buffer attached to a .glb file.
HandleBinaryImageProperty
public int HandleBinaryImage { get; set; }HandleBinaryImageModeProperty
public GltfState.HandleBinaryImageModeEnum HandleBinaryImageMode { get; set; }When importing a glTF file with unimported raw binary images embedded inside of binary blob buffers, in data URIs, or separate files not imported by Reckfell, this controls how the images are handled. Images can be discarded, saved as separate files, or embedded in the scene lossily or losslessly. See GltfState.HandleBinaryImageModeEnum for options.
This property does nothing for image files in the asset:// folder imported by Reckfell, as those are handled by Reckfell's image importer directly, and then the Reckfell scene generated from the glTF file will use the images as Reckfell imported them.
ImagesProperty
public Reckfell.Collections.Array<Texture2D> Images { get; set; }ImportAsSkeletonBonesProperty
public bool ImportAsSkeletonBones { get; set; }If true, forces all GLTFNodes in the document to be bones of a single Skeleton3D Reckfell node.
JsonProperty
public Reckfell.Collections.Dictionary Json { get; set; }The original raw JSON document corresponding to this GLTFState.
LightsProperty
public Reckfell.Collections.Array<GltfLight> Lights { get; set; }MajorVersionProperty
public int MajorVersion { get; set; }MaterialsProperty
public Reckfell.Collections.Array<Material> Materials { get; set; }MeshesProperty
public Reckfell.Collections.Array<GltfMesh> Meshes { get; set; }MinorVersionProperty
public int MinorVersion { get; set; }NodesProperty
public Reckfell.Collections.Array<GltfNode> Nodes { get; set; }RootNodesProperty
public int[] RootNodes { get; set; }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 Reckfell scene.
SceneNameProperty
public string SceneName { get; set; }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.
SkeletonsProperty
public Reckfell.Collections.Array<GltfSkeleton> Skeletons { get; set; }SkinsProperty
public Reckfell.Collections.Array<GltfSkin> Skins { get; set; }TextureSamplersProperty
public Reckfell.Collections.Array<GltfTextureSampler> TextureSamplers { get; set; }TexturesProperty
public Reckfell.Collections.Array<GltfTexture> Textures { get; set; }UniqueAnimationNamesProperty
public Reckfell.Collections.Array<string> UniqueAnimationNames { get; set; }UniqueNamesProperty
public Reckfell.Collections.Array<string> UniqueNames { get; set; }UseNamedSkinBindsProperty
public bool UseNamedSkinBinds { get; set; }Methods77
AddUsedExtensionvoid
public void AddUsedExtension(string extensionName, bool required);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 GltfDocumentExtension._ExportPost, as that stage is too late to add extensions. The final list is sorted alphabetically.
| Name | Type | Default |
|---|---|---|
extensionName | string | — |
required | bool | — |
AppendDataToBuffers2 overloads
public int AppendDataToBuffers(byte[] data, bool deduplication);Appends the given byte array data to the buffers and creates a GltfBufferView for it. The index of the destination GltfBufferView is returned. If deduplication is true, the buffers are first searched for duplicate data, otherwise new bytes are always appended.
| Name | Type | Default |
|---|---|---|
data | byte[] | — |
deduplication | bool | — |
intpublic int AppendDataToBuffers(ReadOnlySpan<byte> data, bool deduplication);Appends the given byte array data to the buffers and creates a GltfBufferView for it. The index of the destination GltfBufferView is returned. If deduplication is true, the buffers are first searched for duplicate data, otherwise new bytes are always appended.
| Name | Type | Default |
|---|---|---|
data | ReadOnlySpan<byte> | — |
deduplication | bool | — |
intAppendGltfNodeint
public int AppendGltfNode(GltfNode gltfNode, Entity reckfellSceneNode, int parentNodeIndex);Appends the given GltfNode to the state, and returns its new index. This can be used to export one Reckfell node as multiple glTF nodes, or inject new glTF nodes at import time. On import, this must be called before GltfDocumentExtension._GenerateSceneNode finishes for the parent node. On export, this must be called before GltfDocumentExtension._ExportNode runs for the parent node.
The reckfell_scene_node parameter is the Reckfell scene node that corresponds to this glTF node. This is highly recommended to be set to a valid node, but may be null if there is no corresponding Reckfell scene node. One Reckfell scene node may be used for multiple glTF nodes, so if exporting multiple glTF nodes for one Reckfell scene node, use the same Reckfell scene node for each.
The parent_node_index parameter is the index of the parent GltfNode in the state. If -1, the node will be a root node, otherwise the new node will be added to the parent's list of children. The index will also be written to the GltfNode.Parent property of the new node.
| Name | Type | Default |
|---|---|---|
gltfNode | GltfNode | — |
reckfellSceneNode | Entity | — |
parentNodeIndex | int | — |
intGetAccessorsReckfell.Collections.Array<GltfAccessor>
public Reckfell.Collections.Array<GltfAccessor> GetAccessors();Reckfell.Collections.Array<GltfAccessor>GetAdditionalDataVariant
public Variant GetAdditionalData(StringName extensionName);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.
| Name | Type | Default |
|---|---|---|
extensionName | StringName | — |
VariantGetAnimationPlayerAnimationPlayer
public AnimationPlayer GetAnimationPlayer(int animPlayerIndex);Returns the AnimationPlayer node with the given index. These nodes are only used during the export process when converting Reckfell AnimationPlayer nodes to glTF animations.
| Name | Type | Default |
|---|---|---|
animPlayerIndex | int | — |
AnimationPlayerGetAnimationPlayersCountint
public int GetAnimationPlayersCount(int animPlayerIndex);Returns the number of AnimationPlayer nodes in this GltfState. These nodes are only used during the export process when converting Reckfell AnimationPlayer nodes to glTF animations.
| Name | Type | Default |
|---|---|---|
animPlayerIndex | int | — |
intGetAnimationsReckfell.Collections.Array<GltfAnimation>
public Reckfell.Collections.Array<GltfAnimation> GetAnimations();Returns an array of all GltfAnimations in the glTF file. When importing, these will be generated as animations in an AnimationPlayer node. When exporting, these will be generated from Reckfell AnimationPlayer nodes.
Reckfell.Collections.Array<GltfAnimation>GetBakeFpsdouble
public double GetBakeFps();doubleGetBasePathstring
public string GetBasePath();stringGetBufferViewsReckfell.Collections.Array<GltfBufferView>
public Reckfell.Collections.Array<GltfBufferView> GetBufferViews();Reckfell.Collections.Array<GltfBufferView>GetBuffersReckfell.Collections.Array<byte[]>
public Reckfell.Collections.Array<byte[]> GetBuffers();Reckfell.Collections.Array<byte[]>GetCamerasReckfell.Collections.Array<GltfCamera>
public Reckfell.Collections.Array<GltfCamera> GetCameras();Returns an array of all GltfCameras in the glTF file. These are the cameras that the GltfNode.Camera index refers to.
Reckfell.Collections.Array<GltfCamera>GetCopyrightstring
public string GetCopyright();stringGetCreateAnimationsbool
public bool GetCreateAnimations();boolGetDiscardMeshesAndMaterialsbool
public bool GetDiscardMeshesAndMaterials();boolGetEntityIndexint
public int GetEntityIndex(Entity sceneNode);Returns the index of the GltfNode corresponding to this Reckfell scene node. This is the inverse of GltfState.GetSceneNode. Useful during the export process.
Note: Not every Reckfell 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.
| Name | Type | Default |
|---|---|---|
sceneNode | Entity | — |
intGetExtractPathstring
public string GetExtractPath();stringGetExtractPrefixstring
public string GetExtractPrefix();stringGetFileNamestring
public string GetFileName();stringGetGlbDatabyte[]
public byte[] GetGlbData();byte[]GetHandleBinaryImageint · Deprecated
public int GetHandleBinaryImage();Deprecated untyped alias for GltfState.HandleBinaryImageMode. When importing a glTF file with unimported raw binary images embedded inside of binary blob buffers, in data URIs, or separate files not imported by Reckfell, this controls how the images are handled.
intGetHandleBinaryImageModeGltfState.HandleBinaryImageModeEnum
public GltfState.HandleBinaryImageModeEnum GetHandleBinaryImageMode();GltfState.HandleBinaryImageModeEnumGetImagesReckfell.Collections.Array<Texture2D>
public Reckfell.Collections.Array<Texture2D> GetImages();Gets the images of the glTF file as an array of Texture2Ds. These are the images that the GltfTexture.SrcImage index refers to.
Reckfell.Collections.Array<Texture2D>GetImportAsSkeletonBonesbool
public bool GetImportAsSkeletonBones();boolGetJsonReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary GetJson();Reckfell.Collections.DictionaryGetLightsReckfell.Collections.Array<GltfLight>
public Reckfell.Collections.Array<GltfLight> GetLights();Returns an array of all GltfLights in the glTF file. These are the lights that the GltfNode.Light index refers to.
Reckfell.Collections.Array<GltfLight>GetMajorVersionint
public int GetMajorVersion();intGetMaterialsReckfell.Collections.Array<Material>
public Reckfell.Collections.Array<Material> GetMaterials();Reckfell.Collections.Array<Material>GetMeshesReckfell.Collections.Array<GltfMesh>
public Reckfell.Collections.Array<GltfMesh> GetMeshes();Returns an array of all GltfMeshes in the glTF file. These are the meshes that the GltfNode.Mesh index refers to.
Reckfell.Collections.Array<GltfMesh>GetMinorVersionint
public int GetMinorVersion();intGetNodesReckfell.Collections.Array<GltfNode>
public Reckfell.Collections.Array<GltfNode> GetNodes();Returns an array of all GltfNodes in the glTF file. These are the nodes that GltfNode.Children and GltfState.RootNodes refer to. This includes nodes that may not be generated in the Reckfell scene, or nodes that may generate multiple Reckfell scene nodes.
Reckfell.Collections.Array<GltfNode>GetRootNodesint[]
public int[] GetRootNodes();int[]GetSceneNamestring
public string GetSceneName();stringGetSceneNodeEntity
public Entity GetSceneNode(int gltfNodeIndex);Returns the Reckfell scene node that corresponds to the same index as the GltfNode it was generated from. This is the inverse of GltfState.GetEntityIndex. 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.
| Name | Type | Default |
|---|---|---|
gltfNodeIndex | int | — |
EntityGetSkeletonsReckfell.Collections.Array<GltfSkeleton>
public Reckfell.Collections.Array<GltfSkeleton> GetSkeletons();Returns an array of all GltfSkeletons in the glTF file. These are the skeletons that the GltfNode.Skeleton index refers to.
Reckfell.Collections.Array<GltfSkeleton>GetSkinsReckfell.Collections.Array<GltfSkin>
public Reckfell.Collections.Array<GltfSkin> GetSkins();Returns an array of all GltfSkins in the glTF file. These are the skins that the GltfNode.Skin index refers to.
Reckfell.Collections.Array<GltfSkin>GetTextureSamplersReckfell.Collections.Array<GltfTextureSampler>
public Reckfell.Collections.Array<GltfTextureSampler> GetTextureSamplers();Retrieves the array of texture samplers that are used by the textures contained in the glTF.
Reckfell.Collections.Array<GltfTextureSampler>GetTexturesReckfell.Collections.Array<GltfTexture>
public Reckfell.Collections.Array<GltfTexture> GetTextures();Reckfell.Collections.Array<GltfTexture>GetUniqueAnimationNamesReckfell.Collections.Array<string>
public Reckfell.Collections.Array<string> GetUniqueAnimationNames();Returns an array of unique animation names. This is only used during the import process.
Reckfell.Collections.Array<string>GetUniqueNamesReckfell.Collections.Array<string>
public Reckfell.Collections.Array<string> GetUniqueNames();Returns an array of unique node names. This is used in both the import process and export process.
Reckfell.Collections.Array<string>GetUseNamedSkinBindsbool
public bool GetUseNamedSkinBinds();boolSetAccessorsvoid
public void SetAccessors(Reckfell.Collections.Array<GltfAccessor> accessors);| Name | Type | Default |
|---|---|---|
accessors | Reckfell.Collections.Array<GltfAccessor> | — |
SetAdditionalDatavoid
public void SetAdditionalData(StringName extensionName, Variant additionalData);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.
| Name | Type | Default |
|---|---|---|
extensionName | StringName | — |
additionalData | Variant | — |
SetAnimationsvoid
public void SetAnimations(Reckfell.Collections.Array<GltfAnimation> animations);Sets the GltfAnimations in the state. When importing, these will be generated as animations in an AnimationPlayer node. When exporting, these will be generated from Reckfell AnimationPlayer nodes.
| Name | Type | Default |
|---|---|---|
animations | Reckfell.Collections.Array<GltfAnimation> | — |
SetBakeFpsvoid
public void SetBakeFps(double value);| Name | Type | Default |
|---|---|---|
value | double | — |
SetBasePathvoid
public void SetBasePath(string basePath);| Name | Type | Default |
|---|---|---|
basePath | string | — |
SetBufferViewsvoid
public void SetBufferViews(Reckfell.Collections.Array<GltfBufferView> bufferViews);| Name | Type | Default |
|---|---|---|
bufferViews | Reckfell.Collections.Array<GltfBufferView> | — |
SetBuffersvoid
public void SetBuffers(Reckfell.Collections.Array<byte[]> buffers);| Name | Type | Default |
|---|---|---|
buffers | Reckfell.Collections.Array<byte[]> | — |
SetCamerasvoid
public void SetCameras(Reckfell.Collections.Array<GltfCamera> cameras);Sets the GltfCameras in the state. These are the cameras that the GltfNode.Camera index refers to.
| Name | Type | Default |
|---|---|---|
cameras | Reckfell.Collections.Array<GltfCamera> | — |
SetCopyrightvoid
public void SetCopyright(string copyright);| Name | Type | Default |
|---|---|---|
copyright | string | — |
SetCreateAnimationsvoid
public void SetCreateAnimations(bool createAnimations);| Name | Type | Default |
|---|---|---|
createAnimations | bool | — |
SetFileNamevoid
public void SetFileName(string fileName);| Name | Type | Default |
|---|---|---|
fileName | string | — |
SetGlbData2 overloads
public void SetGlbData(byte[] glbData);| Name | Type | Default |
|---|---|---|
glbData | byte[] | — |
public void SetGlbData(ReadOnlySpan<byte> glbData);| Name | Type | Default |
|---|---|---|
glbData | ReadOnlySpan<byte> | — |
SetHandleBinaryImagevoid · Deprecated
public void SetHandleBinaryImage(int method);Deprecated untyped alias for GltfState.HandleBinaryImageMode. When importing a glTF file with unimported raw binary images embedded inside of binary blob buffers, in data URIs, or separate files not imported by Reckfell, this controls how the images are handled.
| Name | Type | Default |
|---|---|---|
method | int | — |
SetHandleBinaryImageModevoid
public void SetHandleBinaryImageMode(GltfState.HandleBinaryImageModeEnum method);| Name | Type | Default |
|---|---|---|
method | GltfState.HandleBinaryImageModeEnum | — |
SetImagesvoid
public void SetImages(Reckfell.Collections.Array<Texture2D> images);Sets the images in the state stored as an array of Texture2Ds. This can be used during export. These are the images that the GltfTexture.SrcImage index refers to.
| Name | Type | Default |
|---|---|---|
images | Reckfell.Collections.Array<Texture2D> | — |
SetImportAsSkeletonBonesvoid
public void SetImportAsSkeletonBones(bool importAsSkeletonBones);| Name | Type | Default |
|---|---|---|
importAsSkeletonBones | bool | — |
SetJsonvoid
public void SetJson(Reckfell.Collections.Dictionary json);| Name | Type | Default |
|---|---|---|
json | Reckfell.Collections.Dictionary | — |
SetLightsvoid
public void SetLights(Reckfell.Collections.Array<GltfLight> lights);Sets the GltfLights in the state. These are the lights that the GltfNode.Light index refers to.
| Name | Type | Default |
|---|---|---|
lights | Reckfell.Collections.Array<GltfLight> | — |
SetMajorVersionvoid
public void SetMajorVersion(int majorVersion);| Name | Type | Default |
|---|---|---|
majorVersion | int | — |
SetMaterialsvoid
public void SetMaterials(Reckfell.Collections.Array<Material> materials);| Name | Type | Default |
|---|---|---|
materials | Reckfell.Collections.Array<Material> | — |
SetMeshesvoid
public void SetMeshes(Reckfell.Collections.Array<GltfMesh> meshes);Sets the GltfMeshes in the state. These are the meshes that the GltfNode.Mesh index refers to.
| Name | Type | Default |
|---|---|---|
meshes | Reckfell.Collections.Array<GltfMesh> | — |
SetMinorVersionvoid
public void SetMinorVersion(int minorVersion);| Name | Type | Default |
|---|---|---|
minorVersion | int | — |
SetNodesvoid
public void SetNodes(Reckfell.Collections.Array<GltfNode> nodes);Sets the GltfNodes in the state. These are the nodes that GltfNode.Children and GltfState.RootNodes refer to. Some of the nodes set here may not be generated in the Reckfell scene, or may generate multiple Reckfell scene nodes.
| Name | Type | Default |
|---|---|---|
nodes | Reckfell.Collections.Array<GltfNode> | — |
SetRootNodes2 overloads
public void SetRootNodes(int[] rootNodes);| Name | Type | Default |
|---|---|---|
rootNodes | int[] | — |
public void SetRootNodes(ReadOnlySpan<int> rootNodes);| Name | Type | Default |
|---|---|---|
rootNodes | ReadOnlySpan<int> | — |
SetSceneNamevoid
public void SetSceneName(string sceneName);| Name | Type | Default |
|---|---|---|
sceneName | string | — |
SetSkeletonsvoid
public void SetSkeletons(Reckfell.Collections.Array<GltfSkeleton> skeletons);Sets the GltfSkeletons in the state. These are the skeletons that the GltfNode.Skeleton index refers to.
| Name | Type | Default |
|---|---|---|
skeletons | Reckfell.Collections.Array<GltfSkeleton> | — |
SetSkinsvoid
public void SetSkins(Reckfell.Collections.Array<GltfSkin> skins);Sets the GltfSkins in the state. These are the skins that the GltfNode.Skin index refers to.
| Name | Type | Default |
|---|---|---|
skins | Reckfell.Collections.Array<GltfSkin> | — |
SetTextureSamplersvoid
public void SetTextureSamplers(Reckfell.Collections.Array<GltfTextureSampler> textureSamplers);Sets the array of texture samplers that are used by the textures contained in the glTF.
| Name | Type | Default |
|---|---|---|
textureSamplers | Reckfell.Collections.Array<GltfTextureSampler> | — |
SetTexturesvoid
public void SetTextures(Reckfell.Collections.Array<GltfTexture> textures);| Name | Type | Default |
|---|---|---|
textures | Reckfell.Collections.Array<GltfTexture> | — |
SetUniqueAnimationNamesvoid
public void SetUniqueAnimationNames(Reckfell.Collections.Array<string> uniqueAnimationNames);Sets the unique animation names in the state. This is only used during the import process.
| Name | Type | Default |
|---|---|---|
uniqueAnimationNames | Reckfell.Collections.Array<string> | — |
SetUniqueNamesvoid
public void SetUniqueNames(Reckfell.Collections.Array<string> uniqueNames);Sets the unique node names in the state. This is used in both the import process and export process.
| Name | Type | Default |
|---|---|---|
uniqueNames | Reckfell.Collections.Array<string> | — |
SetUseNamedSkinBindsvoid
public void SetUseNamedSkinBinds(bool useNamedSkinBinds);| Name | Type | Default |
|---|---|---|
useNamedSkinBinds | bool | — |
Fields and constants4
HandleBinaryDiscardTexturesField · Deprecated
public const long HandleBinaryDiscardTextures = 0;Discards all embedded textures and uses untextured materials.
HandleBinaryEmbedAsBasisuField · Deprecated
public const long HandleBinaryEmbedAsBasisu = 2;Embeds textures VRAM compressed with Basis Universal into the generated scene.
HandleBinaryEmbedAsUncompressedField · Deprecated
public const long HandleBinaryEmbedAsUncompressed = 3;Embeds textures compressed losslessly into the generated scene, matching old behavior.
HandleBinaryExtractTexturesField · Deprecated
public const long HandleBinaryExtractTextures = 1;Extracts embedded textures to be reimported and compressed. Editor only. Acts as uncompressed at runtime.
GltfState.HandleBinaryImageModeEnum
| Value | Description |
|---|---|
DiscardTextures = 0 | When importing a glTF file with embedded binary images, discards all images and uses untextured materials in their place. Images stored as separate files in the |
EmbedAsBasisu = 2 | When importing a glTF file with embedded binary images, embeds textures VRAM compressed with Basis Universal into the generated scene. Images stored as separate files in the |
EmbedAsUncompressed = 3 | When importing a glTF file with embedded binary images, embeds textures compressed losslessly into the generated scene. Images stored as separate files in the |
ExtractTextures = 1 | When importing a glTF file with embedded binary images, extracts them and saves them to their own files. This allows the image to be imported by Reckfell's image importer, which can then have their import options customized by the user, including optionally compressing the image to VRAM texture formats.
This will save the images' bytes exactly as-is, without recompression. For image formats supplied by glTF extensions, the file will have a filename ending with the file extension supplied by |