Class Interface
Inherited Members
Namespace: glTFLoader
Assembly: Evergine.Assets.dll
Syntax
public static class Interface
Methods
DeserializeModel(string)
Parses a JSON formatted text content
Declaration
public static Gltf DeserializeModel(string fileData)
Parameters
Type | Name | Description |
---|---|---|
string | fileData | JSON text content |
Returns
Type | Description |
---|---|
Gltf |
model
|
LoadBinaryBuffer(Stream)
Reads the binary buffer chunk of a glb stream
Declaration
public static byte[] LoadBinaryBuffer(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | Readable stream to a glb model |
Returns
Type | Description |
---|---|
byte[] | Byte array of the buffer |
LoadBinaryBuffer(string)
Loads the binary buffer chunk of a glb file
Declaration
public static byte[] LoadBinaryBuffer(string filePath)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | Source file path to a glb model |
Returns
Type | Description |
---|---|
byte[] | Byte array of the buffer |
LoadBinaryBuffer(Gltf, int, Func<string, byte[]>)
Gets a binary buffer referenced by a specific
Schema.Buffer
Declaration
public static byte[] LoadBinaryBuffer(this Gltf model, int bufferIndex, Func<string, byte[]> externalReferenceSolver)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model | The model containing the
|
int | bufferIndex | The index of the buffer |
Func<string, byte[]> | externalReferenceSolver | An user provided lambda function to resolve external assets |
Returns
Type | Description |
---|---|
byte[] | Byte array of the buffer |
Remarks
Binary buffers can be stored in three different ways:
- As stand alone files.
- As a binary chunk within a glb file.
- Encoded to Base64 within the JSON.
The external reference solver funcion is called when the buffer is stored in an external file, or when the buffer is in the glb binary chunk, in which case, the Argument of the function will be Null.
The Lambda function must return the byte array of the requested file or buffer.
LoadBinaryBuffer(Gltf, int, string)
Gets a binary buffer referenced by a specific
Schema.Buffer
Declaration
public static byte[] LoadBinaryBuffer(this Gltf model, int bufferIndex, string gltfFilePath)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model | The model containing the
|
int | bufferIndex | The index of the buffer |
string | gltfFilePath | Source file path used to load the model |
Returns
Type | Description |
---|---|
byte[] | Byte array of the buffer |
LoadModel(Stream)
Reads a
Schema.Gltf
model from a stream
Declaration
public static Gltf LoadModel(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | Readable stream to a gltf/glb model |
Returns
Type | Description |
---|---|
Gltf |
model
|
LoadModel(string)
Loads a
Schema.Gltf
model from a file
Declaration
public static Gltf LoadModel(string filePath)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | Source file path to a gltf/glb model |
Returns
Type | Description |
---|---|
Gltf |
model
|
OpenImageFile(Gltf, int, Func<string, byte[]>)
Opens a stream to the image referenced by a specific
Schema.Image
Declaration
public static Stream OpenImageFile(this Gltf model, int imageIndex, Func<string, byte[]> externalReferenceSolver)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model | The model containing the
|
int | imageIndex | The index of the image |
Func<string, byte[]> | externalReferenceSolver | An user provided lambda function to resolve external assets |
Returns
Type | Description |
---|---|
Stream | An open stream to the image |
Remarks
Images can be stored in three different ways:
- As stand alone files.
- As a part of binary buffer accessed via bufferView.
- Encoded to Base64 within the JSON.
The external reference solver funcion is called when the image is stored in an external file, or when the image is in the glb binary chunk, in which case, the Argument of the function will be Null.
The Lambda function must return the byte array of the requested file or buffer.
OpenImageFile(Gltf, int, string)
Opens a stream to the image referenced by a specific
Schema.Image
Declaration
public static Stream OpenImageFile(this Gltf model, int imageIndex, string gltfFilePath)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model | The model containing the
|
int | imageIndex | The index of the image |
string | gltfFilePath | Source file path used to load the model |
Returns
Type | Description |
---|---|
Stream | An open stream to the image |
Pack(string, string)
Converts a glTF file and its associated resources to a packed GLB binary file
Declaration
public static void Pack(string inputGltfFilePath, string outputGlbFile)
Parameters
Type | Name | Description |
---|---|---|
string | inputGltfFilePath | glTF file (.gltf) to pack |
string | outputGlbFile | Path where the GLB file should be generated |
SaveBinaryModel(Gltf, byte[], BinaryWriter)
Writes a
Schema.Gltf
model to a writable binary writer
Declaration
public static void SaveBinaryModel(this Gltf model, byte[] buffer, BinaryWriter binaryWriter)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model |
model
|
byte[] | buffer | Binary buffer to embed in the file, or null |
BinaryWriter | binaryWriter | Binary Writer |
SaveBinaryModel(Gltf, byte[], Stream)
Writes a
Schema.Gltf
model to a writable stream
Declaration
public static void SaveBinaryModel(this Gltf model, byte[] buffer, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model |
model
|
byte[] | buffer | Binary buffer to embed in the file, or null |
Stream | stream | Writable stream |
SaveBinaryModel(Gltf, byte[], string)
Saves a
Schema.Gltf
model to a glb file
Declaration
public static void SaveBinaryModel(this Gltf model, byte[] buffer, string filePath)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model |
model
|
byte[] | buffer | Binary buffer to embed in the file, or null |
string | filePath | Destination file path |
SaveBinaryModelPacked(Gltf, BinaryWriter, string, byte[])
Writes a
Schema.Gltf
model to a writable binary writer and pack all data into the model
Declaration
public static void SaveBinaryModelPacked(this Gltf model, BinaryWriter binaryWriter, string gltfFilePath, byte[] glbBinChunck = null)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model |
model
|
BinaryWriter | binaryWriter | Binary Writer |
string | gltfFilePath | Source file path used to load the model |
byte[] | glbBinChunck | optional GLB-stored Buffer (BIN data file). If null, then the first buffer Uri must point to a BIN file. |
SaveBinaryModelPacked(Gltf, string, string, byte[])
Writes a
Schema.Gltf
model to a writable binary writer and pack all data into the model
Declaration
public static void SaveBinaryModelPacked(this Gltf model, string outputFile, string gltfFilePath, byte[] glbBinChunck = null)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model |
model
|
string | outputFile | GLB output file path |
string | gltfFilePath | Source file path used to load the model |
byte[] | glbBinChunck | optional GLB-stored Buffer (BIN data file). If null, then the first buffer Uri must point to a BIN file. |
SaveModel(Gltf, Stream)
Writes a
Schema.Gltf
model to a writable stream
Declaration
public static void SaveModel(this Gltf model, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model |
model
|
Stream | stream | Writable stream |
SaveModel(Gltf, string)
Saves a
Schema.Gltf
model to a gltf file
Declaration
public static void SaveModel(this Gltf model, string path)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model |
model
|
string | path | Destination file path |
SerializeModel(Gltf)
Serializes a
Schema.Gltf
model to text
Declaration
public static string SerializeModel(this Gltf model)
Parameters
Type | Name | Description |
---|---|---|
Gltf | model |
model
|
Returns
Type | Description |
---|---|
string | JSON formatted text |
Unpack(string, string)
Converts self contained GLB to glTF file and associated textures and data
Declaration
public static void Unpack(string inputFilePath, string outputDirectoryPath)
Parameters
Type | Name | Description |
---|---|---|
string | inputFilePath | glTF binary file (.glb) to unpack |
string | outputDirectoryPath | Directory where the files will be extracted |