Class AssimpLibrary
Singleton that governs access to the unmanaged Assimp library functions.
Inherited Members
Namespace: SharpAssimp.Unmanaged
Assembly: SharpAssimp.dll
Syntax
public sealed class AssimpLibrary : UnmanagedLibrary
Properties
| Edit this page View SourceInstance
Gets the AssimpLibrary instance.
Declaration
public static AssimpLibrary Instance { get; }
Property Value
Type | Description |
---|---|
AssimpLibrary |
IsMultithreadingSupported
Gets if the Assimp unmanaged library supports multithreading. If it was compiled for single threading only, then it will not utilize multiple threads during import.
Declaration
public bool IsMultithreadingSupported { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceApplyPostProcessing(nint, PostProcessSteps)
Applies a post-processing step on an already imported scene.
Declaration
public nint ApplyPostProcessing(nint scene, PostProcessSteps flags)
Parameters
Type | Name | Description |
---|---|---|
nint | scene | Pointer to the unmanaged scene data structure. |
PostProcessSteps | flags | Post processing steps to run. |
Returns
Type | Description |
---|---|
nint | Pointer to the unmanaged scene data structure. |
AttachLogStream(nint)
Attaches a log stream callback to catch Assimp messages.
Declaration
public void AttachLogStream(nint logStreamPtr)
Parameters
Type | Name | Description |
---|---|---|
nint | logStreamPtr | Pointer to an instance of AiLogStream. |
CopyScene(nint)
Creates a modifyable copy of a scene, useful for copying the scene that was imported so its topology can be modified and the scene be exported.
Declaration
public nint CopyScene(nint sceneToCopy)
Parameters
Type | Name | Description |
---|---|---|
nint | sceneToCopy | Valid scene to be copied |
Returns
Type | Description |
---|---|
nint | Modifyable copy of the scene |
CreatePropertyStore()
Create an empty property store. Property stores are used to collect import settings.
Declaration
public nint CreatePropertyStore()
Returns
Type | Description |
---|---|
nint | Pointer to property store |
DetachAllLogStreams()
Detaches all logstream callbacks currently attached to Assimp.
Declaration
public void DetachAllLogStreams()
DetachLogStream(nint)
Detaches a logstream callback.
Declaration
public ReturnCode DetachLogStream(nint logStreamPtr)
Parameters
Type | Name | Description |
---|---|---|
nint | logStreamPtr | Pointer to an instance of AiLogStream. |
Returns
Type | Description |
---|---|
ReturnCode | A return code signifying if the function was successful or not. |
EnableVerboseLogging(bool)
Enables verbose logging.
Declaration
public void EnableVerboseLogging(bool enable)
Parameters
Type | Name | Description |
---|---|---|
bool | enable | True if verbose logging is to be enabled or not. |
ExportScene(nint, string, string, PostProcessSteps)
Exports the given scene to a chosen file format and writes the result file(s) to disk.
Declaration
public ReturnCode ExportScene(nint scene, string formatId, string fileName, PostProcessSteps preProcessing)
Parameters
Type | Name | Description |
---|---|---|
nint | scene | The scene to export, which needs to be freed by the caller. The scene is expected to conform to Assimp's Importer output format. In short, this means the model data should use a right handed coordinate system, face winding should be counter clockwise, and the UV coordinate origin assumed to be upper left. If the input is different, specify the pre processing flags appropiately. |
string | formatId | Format id describing which format to export to. |
string | fileName | Output filename to write to |
PostProcessSteps | preProcessing | Pre processing flags - accepts any post processing step flag. In reality only a small subset are actually supported, e.g. to ensure the input conforms to the standard Assimp output format. Some may be redundant, such as triangulation, which some exporters may have to enforce due to the export format. |
Returns
Type | Description |
---|---|
ReturnCode | Return code specifying if the operation was a success. |
ExportScene(nint, string, string, nint, PostProcessSteps)
Exports the given scene to a chosen file format and writes the result file(s) to disk.
Declaration
public ReturnCode ExportScene(nint scene, string formatId, string fileName, nint fileIO, PostProcessSteps preProcessing)
Parameters
Type | Name | Description |
---|---|---|
nint | scene | The scene to export, which needs to be freed by the caller. The scene is expected to conform to Assimp's Importer output format. In short, this means the model data should use a right handed coordinate system, face winding should be counter clockwise, and the UV coordinate origin assumed to be upper left. If the input is different, specify the pre processing flags appropiately. |
string | formatId | Format id describing which format to export to. |
string | fileName | Output filename to write to |
nint | fileIO | Pointer to an instance of AiFileIO, a custom file IO system used to open the model and any associated file the loader needs to open, passing NULL uses the default implementation. |
PostProcessSteps | preProcessing | Pre processing flags - accepts any post processing step flag. In reality only a small subset are actually supported, e.g. to ensure the input conforms to the standard Assimp output format. Some may be redundant, such as triangulation, which some exporters may have to enforce due to the export format. |
Returns
Type | Description |
---|---|
ReturnCode | Return code specifying if the operation was a success. |
ExportSceneToBlob(nint, string, PostProcessSteps)
Exports the given scene to a chosen file format. Returns the exported data as a binary blob which you can embed into another data structure or file.
Declaration
public ExportDataBlob? ExportSceneToBlob(nint scene, string formatId, PostProcessSteps preProcessing)
Parameters
Type | Name | Description |
---|---|---|
nint | scene | Scene to export, it is the responsibility of the caller to free this when finished. |
string | formatId | Format id describing which format to export to. |
PostProcessSteps | preProcessing | Pre processing flags to operate on the scene during the export. |
Returns
Type | Description |
---|---|
ExportDataBlob | Exported binary blob, or null if there was an error. |
GetBranchName()
Returns the branchname of the Assimp runtime.
Declaration
public string GetBranchName()
Returns
Type | Description |
---|---|
string | The current branch name. |
GetCompileFlags()
Get the compilation flags that describe how the native Assimp DLL was compiled.
Declaration
public CompileFlags GetCompileFlags()
Returns
Type | Description |
---|---|
CompileFlags | Compilation flags |
GetEmbeddedTexture(nint, string)
Gets an embedded texture.
Declaration
public nint GetEmbeddedTexture(nint scene, string filename)
Parameters
Type | Name | Description |
---|---|---|
nint | scene | Input asset. |
string | filename | Texture path extracted from GetMaterialString(ref AiMaterial, string, TextureType, uint). |
Returns
Type | Description |
---|---|
nint | An embedded texture, or nullptr. |
GetErrorString()
Gets the last error logged in Assimp.
Declaration
public string GetErrorString()
Returns
Type | Description |
---|---|
string | The last error message logged. |
GetExportFormatDescriptions()
Gets all supported export formats.
Declaration
public ExportFormatDescription[] GetExportFormatDescriptions()
Returns
Type | Description |
---|---|
ExportFormatDescription[] | Array of supported export formats. |
GetExtensionList()
Gets all the model format extensions that are currently supported by Assimp.
Declaration
public string[] GetExtensionList()
Returns
Type | Description |
---|---|
string[] | Array of supported format extensions |
GetImporterDescriptions()
Gets a collection of importer descriptions that detail metadata and feature support for each importer.
Declaration
public ImporterDescription[] GetImporterDescriptions()
Returns
Type | Description |
---|---|
ImporterDescription[] | Collection of importer descriptions |
GetLegalString()
Gets the Assimp legal info.
Declaration
public string GetLegalString()
Returns
Type | Description |
---|---|
string | String containing Assimp legal info. |
GetMaterialColor(ref AiMaterial, string, TextureType, uint)
Retrieves a color value from the material property table.
Declaration
public Vector4 GetMaterialColor(ref AiMaterial mat, string key, TextureType texType, uint texIndex)
Parameters
Type | Name | Description |
---|---|---|
AiMaterial | mat | Material to retrieve the data from |
string | key | Ai mat key (base) name to search for |
TextureType | texType | Texture Type semantic, always zero for non-texture properties |
uint | texIndex | Texture index, always zero for non-texture properties |
Returns
Type | Description |
---|---|
Vector4 | The color if it exists. If not, the default Vector4 value is returned. |
GetMaterialFloatArray(ref AiMaterial, string, TextureType, uint, uint)
Retrieves an array of float values with the specific key from the material.
Declaration
public float[]? GetMaterialFloatArray(ref AiMaterial mat, string key, TextureType texType, uint texIndex, uint floatCount)
Parameters
Type | Name | Description |
---|---|---|
AiMaterial | mat | Material to retrieve the data from |
string | key | Ai mat key (base) name to search for |
TextureType | texType | Texture Type semantic, always zero for non-texture properties |
uint | texIndex | Texture index, always zero for non-texture properties |
uint | floatCount | The maximum number of floats to read. This may not accurately describe the data returned, as it may not exist or be smaller. If this value is less than the available floats, then only the requested number is returned (e.g. 1 or 2 out of a 4 float array). |
Returns
Type | Description |
---|---|
float[] | The float array, if it exists |
GetMaterialIntegerArray(ref AiMaterial, string, TextureType, uint, uint)
Retrieves an array of integer values with the specific key from the material.
Declaration
public int[]? GetMaterialIntegerArray(ref AiMaterial mat, string key, TextureType texType, uint texIndex, uint intCount)
Parameters
Type | Name | Description |
---|---|---|
AiMaterial | mat | Material to retrieve the data from |
string | key | Ai mat key (base) name to search for |
TextureType | texType | Texture Type semantic, always zero for non-texture properties |
uint | texIndex | Texture index, always zero for non-texture properties |
uint | intCount | The maximum number of integers to read. This may not accurately describe the data returned, as it may not exist or be smaller. If this value is less than the available integers, then only the requested number is returned (e.g. 1 or 2 out of a 4 float array). |
Returns
Type | Description |
---|---|
int[] | The integer array, if it exists |
GetMaterialProperty(ref AiMaterial, string, TextureType, uint)
Retrieves a material property with the specific key from the material.
Declaration
public AiMaterialProperty GetMaterialProperty(ref AiMaterial mat, string key, TextureType texType, uint texIndex)
Parameters
Type | Name | Description |
---|---|---|
AiMaterial | mat | Material to retrieve the property from |
string | key | Ai mat key (base) name to search for |
TextureType | texType | Texture Type semantic, always zero for non-texture properties |
uint | texIndex | Texture index, always zero for non-texture properties |
Returns
Type | Description |
---|---|
AiMaterialProperty | The material property, if found. |
GetMaterialString(ref AiMaterial, string, TextureType, uint)
Retrieves a string from the material property table.
Declaration
public string GetMaterialString(ref AiMaterial mat, string key, TextureType texType, uint texIndex)
Parameters
Type | Name | Description |
---|---|---|
AiMaterial | mat | Material to retrieve the data from |
string | key | Ai mat key (base) name to search for |
TextureType | texType | Texture Type semantic, always zero for non-texture properties |
uint | texIndex | Texture index, always zero for non-texture properties |
Returns
Type | Description |
---|---|
string | The string, if it exists. If not, an empty string is returned. |
GetMaterialTexture(ref AiMaterial, TextureType, uint)
Gets all values pertaining to a particular texture from a material.
Declaration
public TextureSlot GetMaterialTexture(ref AiMaterial mat, TextureType type, uint index)
Parameters
Type | Name | Description |
---|---|---|
AiMaterial | mat | Material to retrieve the data from |
TextureType | type | Texture type semantic |
uint | index | Texture index |
Returns
Type | Description |
---|---|
TextureSlot | Returns the texture slot struct containing all the information. |
GetMaterialTextureCount(ref AiMaterial, TextureType)
Gets the number of textures contained in the material for a particular texture type.
Declaration
public uint GetMaterialTextureCount(ref AiMaterial mat, TextureType type)
Parameters
Type | Name | Description |
---|---|---|
AiMaterial | mat | Material to retrieve the data from |
TextureType | type | Texture Type semantic |
Returns
Type | Description |
---|---|
uint | The number of textures for the type. |
GetMaterialTextureFilePath(ref AiMaterial, TextureType, uint)
Gets the texture filepath contained in the material.
Declaration
public string GetMaterialTextureFilePath(ref AiMaterial mat, TextureType type, uint index)
Parameters
Type | Name | Description |
---|---|---|
AiMaterial | mat | Material to retrieve the data from |
TextureType | type | Texture type semantic |
uint | index | Texture index |
Returns
Type | Description |
---|---|
string | The texture filepath, if it exists. If not an empty string is returned. |
GetMemoryRequirements(nint)
Gets the memory requirements of the scene.
Declaration
public AiMemoryInfo GetMemoryRequirements(nint scene)
Parameters
Type | Name | Description |
---|---|---|
nint | scene | Pointer to the unmanaged scene data structure. |
Returns
Type | Description |
---|---|
AiMemoryInfo | The memory information about the scene. |
GetVerboseLoggingEnabled()
Gets if verbose logging is enabled.
Declaration
public bool GetVerboseLoggingEnabled()
Returns
Type | Description |
---|---|
bool | True if verbose logging is enabled, false otherwise. |
GetVersion()
Gets the native Assimp DLL's current version number as "major.minor.revision" string. This is the version of Assimp that this wrapper is currently using.
Declaration
public string GetVersion()
Returns
Type | Description |
---|---|
string | Unmanaged DLL version |
GetVersionAsVersion()
Gets the native Assimp DLL's current version number as a .NET version object.
Declaration
public Version GetVersionAsVersion()
Returns
Type | Description |
---|---|
Version | Unmanaged DLL version |
GetVersionMajor()
Gets the native Assimp DLL's major version number.
Declaration
public uint GetVersionMajor()
Returns
Type | Description |
---|---|
uint | Assimp major version number |
GetVersionMinor()
Gets the native Assimp DLL's minor version number.
Declaration
public uint GetVersionMinor()
Returns
Type | Description |
---|---|
uint | Assimp minor version number |
GetVersionRevision()
Gets the native Assimp DLL's revision version number.
Declaration
public uint GetVersionRevision()
Returns
Type | Description |
---|---|
uint | Assimp revision version number |
ImportFile(string, PostProcessSteps, nint)
Imports a file.
Declaration
public nint ImportFile(string file, PostProcessSteps flags, nint propStore)
Parameters
Type | Name | Description |
---|---|---|
string | file | Valid filename |
PostProcessSteps | flags | Post process flags specifying what steps are to be run after the import. |
nint | propStore | Property store containing config name-values, may be null. |
Returns
Type | Description |
---|---|
nint | Pointer to the unmanaged data structure. |
ImportFile(string, PostProcessSteps, nint, nint)
Imports a file.
Declaration
public nint ImportFile(string file, PostProcessSteps flags, nint fileIO, nint propStore)
Parameters
Type | Name | Description |
---|---|---|
string | file | Valid filename |
PostProcessSteps | flags | Post process flags specifying what steps are to be run after the import. |
nint | fileIO | Pointer to an instance of AiFileIO, a custom file IO system used to open the model and any associated file the loader needs to open, passing NULL uses the default implementation. |
nint | propStore | Property store containing config name-values, may be null. |
Returns
Type | Description |
---|---|
nint | Pointer to the unmanaged data structure. |
ImportFileFromStream(Stream, PostProcessSteps, string?, nint)
Imports a scene from a stream. This uses the "aiImportFileFromMemory" function. The stream can be from anyplace, not just a memory stream. It is up to the caller to dispose of the stream.
Declaration
public nint ImportFileFromStream(Stream stream, PostProcessSteps flags, string? formatHint, nint propStore)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | Stream containing the scene data |
PostProcessSteps | flags | Post processing flags |
string | formatHint | A hint to Assimp to decide which importer to use to process the data |
nint | propStore | Property store containing the config name-values, may be null. |
Returns
Type | Description |
---|---|
nint | Pointer to the unmanaged data structure. |
IsExtensionSupported(string)
Checks whether the model format extension is supported by Assimp.
Declaration
public bool IsExtensionSupported(string extension)
Parameters
Type | Name | Description |
---|---|---|
string | extension | Model format extension, e.g. ".3ds" |
Returns
Type | Description |
---|---|
bool | True if the format is supported, false otherwise. |
ReleaseImport(nint)
Releases the unmanaged scene data structure. This should NOT be used for unmanaged scenes that were marshaled from the managed scene structure - only for scenes whose memory was allocated by the native library!
Declaration
public void ReleaseImport(nint scene)
Parameters
Type | Name | Description |
---|---|---|
nint | scene | Pointer to the unmanaged scene data structure. |
ReleasePropertyStore(nint)
Deletes a property store.
Declaration
public void ReleasePropertyStore(nint propertyStore)
Parameters
Type | Name | Description |
---|---|---|
nint | propertyStore | Pointer to property store |
SetImportPropertyFloat(nint, string, float)
Sets a float property value.
Declaration
public void SetImportPropertyFloat(nint propertyStore, string name, float value)
Parameters
Type | Name | Description |
---|---|---|
nint | propertyStore | Pointer to property store |
string | name | Property name |
float | value | Property value |
SetImportPropertyInteger(nint, string, int)
Sets an integer property value.
Declaration
public void SetImportPropertyInteger(nint propertyStore, string name, int value)
Parameters
Type | Name | Description |
---|---|---|
nint | propertyStore | Pointer to property store |
string | name | Property name |
int | value | Property value |
SetImportPropertyMatrix(nint, string, Matrix4x4)
Sets a matrix property value.
Declaration
public void SetImportPropertyMatrix(nint propertyStore, string name, Matrix4x4 value)
Parameters
Type | Name | Description |
---|---|---|
nint | propertyStore | Pointer to property store |
string | name | Property name |
Matrix4x4 | value | Property value |
SetImportPropertyString(nint, string, string)
Sets a string property value.
Declaration
public void SetImportPropertyString(nint propertyStore, string name, string value)
Parameters
Type | Name | Description |
---|---|---|
nint | propertyStore | Pointer to property store |
string | name | Property name |
string | value | Property value |