### Run Asset Importer Example Source: https://github.com/latias94/asset-importer/blob/main/asset-importer/examples/README.md General command to run an asset-importer example. Replace `` with the example's name and `` with any necessary arguments. ```bash cargo run -p asset-importer --example -- ``` -------------------------------- ### Install Build Tools on Windows Source: https://github.com/latias94/asset-importer/blob/main/asset-importer-sys/README.md Installs necessary build tools on Windows using Chocolatey. Ensure Chocolatey is installed first. ```cmd choco install cmake visualstudio2022buildtools ``` -------------------------------- ### Get Mesh Normals Example Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-mesh.md Example demonstrating how to check for normals and then iterate over them if they exist. ```rust if let Some(normals) = mesh.normals() { for n in &normals { println!("Normal: ({}, {}, {})", n.x, n.y, n.z); } } ``` -------------------------------- ### System Library Dependency Source: https://github.com/latias94/asset-importer/blob/main/README.md Integrate with an existing system installation of Assimp. This is lightweight but requires manual setup and may vary based on the system library version. ```toml asset-importer = { version = "0.8", features = ["system"] } ``` -------------------------------- ### Install Build Tools on CentOS/RHEL Source: https://github.com/latias94/asset-importer/blob/main/asset-importer-sys/README.md Installs development tools, CMake, and Git on CentOS or RHEL-based Linux distributions. ```bash sudo yum groupinstall "Development Tools" sudo yum install cmake3 git ``` -------------------------------- ### Install Build Tools on macOS Source: https://github.com/latias94/asset-importer/blob/main/asset-importer-sys/README.md Installs Xcode Command Line Tools and CMake on macOS. CMake is recommended to be installed via Homebrew. ```bash xcode-select --install brew install cmake ``` -------------------------------- ### Initialize PropertyStore Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Create a new, empty property store. This is the starting point for configuring import/export settings. ```rust pub struct PropertyStore { properties: Vec<(String, PropertyValue)> } ``` ```rust pub fn new() -> Self ``` ```rust let mut store = PropertyStore::new(); store.set_int("key", 42); ``` -------------------------------- ### Install Build Tools on Ubuntu/Debian Source: https://github.com/latias94/asset-importer/blob/main/asset-importer-sys/README.md Installs essential build tools including CMake and Git on Ubuntu or Debian-based Linux distributions. ```bash sudo apt update sudo apt install build-essential cmake git ``` -------------------------------- ### Vector2D Construction Example Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Demonstrates how to create Vector2D instances using `new`, `splat`, and the `ZERO` constant. ```rust let v = Vector2D::new(1.0, 2.0); let splat = Vector2D::splat(5.0); let zero = Vector2D::ZERO; ``` -------------------------------- ### Example usage of Matrix3x3 Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Demonstrates creating identity and zero matrices for 3x3 transformations. ```rust let identity = Matrix3x3::identity(); let zero = Matrix3x3::zero(); ``` -------------------------------- ### Example usage of Matrix4x4 methods Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Demonstrates creating an identity matrix and then calling `transpose` and `determinant` methods. ```rust let identity = Matrix4x4::identity(); let transposed = identity.transpose(); let det = identity.determinant(); // 1.0 ``` -------------------------------- ### Start import from memory buffer Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Use `read_from_memory` to start building an import operation from a byte slice. This method copies the data into an owned buffer. ```rust let bytes: Vec = std::fs::read("model.obj")?; let builder = importer.read_from_memory(&bytes); ``` -------------------------------- ### Iterate Mesh Normals Example Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-mesh.md Example showing how to use the iterator to process each normal without allocating. ```rust for normal in mesh.normals_iter() { println!("N: ({}, {}, {})", normal.x, normal.y, normal.z); } ``` -------------------------------- ### Vector2D Operations Example Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Illustrates basic arithmetic operations and the dot product for Vector2D. ```rust let v1 = Vector2D::new(1.0, 2.0); let v2 = Vector2D::new(3.0, 4.0); let sum = v1 + v2; // (4.0, 6.0) let diff = v1 - v2; // (-2.0, -2.0) let scaled = v1 * 2.0; // (2.0, 4.0) let dot = v1.dot(v2); // 11.0 ``` -------------------------------- ### Check Supported Formats Source: https://github.com/latias94/asset-importer/blob/main/asset-importer/examples/README.md Lists all import and export formats supported by the asset-importer library. This example does not require any arguments. ```bash cargo run -p asset-importer --example 02_formats ``` -------------------------------- ### PropertyStore::new Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Creates a new, empty PropertyStore instance. This is the starting point for configuring import/export settings. ```APIDOC ## PropertyStore::new ### Description Create a new empty property store. ### Method `new()` ### Returns `PropertyStore` - Empty property store ### Example ```rust let mut store = PropertyStore::new(); store.set_int("key", 42); ``` ``` -------------------------------- ### ImportBuilder::new Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Creates a new instance of the ImportBuilder with default configurations. This is the starting point for setting up an asset import. ```APIDOC ## ImportBuilder::new ### Description Create a new import builder. ### Method `new()` ### Returns `ImportBuilder` - Builder with default configuration ### Example ```rust let builder = ImportBuilder::new(); ``` ``` -------------------------------- ### Quaternion Usage Example Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Demonstrates how to create and use Quaternion instances, including composing rotations and normalizing. ```rust let q1 = Quaternion::identity(); let q2 = Quaternion::new(1.0, 0.0, 0.0, 0.0); let combined = q1 * q2; // Compose rotations let normalized = q1.normalize(); ``` -------------------------------- ### Example Usage of NodeAnimation Name Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Demonstrates how to print the name of a node animation channel. ```rust println!("Node animation: {}", channel.name()); ``` -------------------------------- ### Importer::new Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Creates a new, default instance of the Importer. This is the starting point for all import operations. ```APIDOC ## Importer::new ### Description Creates a new, default instance of the Importer. This is the starting point for all import operations. ### Method `new()` ### Returns `Self` (Importer instance) ### Example ```rust use asset_importer::Importer; let importer = Importer::new(); ``` ``` -------------------------------- ### Create a new ImportBuilder Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Initializes a new ImportBuilder with default settings. Use this as the starting point for configuring imports. ```rust pub fn new() -> Self ``` ```rust let builder = ImportBuilder::new(); ``` -------------------------------- ### Example usage of Color4D Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Demonstrates creating Color4D instances for opaque white and a semi-transparent red color using the `new` constructor. ```rust let opaque_white = Color4D::new(1.0, 1.0, 1.0, 1.0); let transparent_red = Color4D::new(1.0, 0.0, 0.0, 0.5); ``` -------------------------------- ### Example usage of Color3D Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Demonstrates creating Color3D instances for common colors like white, black, and red using the `new` constructor. ```rust let white = Color3D::new(1.0, 1.0, 1.0); let black = Color3D::new(0.0, 0.0, 0.0); let red = Color3D::new(1.0, 0.0, 0.0); ``` -------------------------------- ### Create Export Builder Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Initializes a new ExportBuilder for a specified file format. Use this to start configuring export settings. ```rust pub struct ExportBuilder ``` ```rust pub fn new>(format_id: S) -> Self ``` ```rust let exporter = ExportBuilder::new("obj"); ``` -------------------------------- ### Build Asset Importer with System Assimp Source: https://github.com/latias94/asset-importer/blob/main/asset-importer/examples/README.md Builds and runs an example using a system-installed Assimp via the `system` feature. Requires `pkg-config`/`vcpkg` and `libclang`/`bindgen`. A model path is required. ```bash cargo run -p asset-importer --example 01_quickstart --features system -- ``` -------------------------------- ### Import Scene with Post-Processing Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Initiate the scene import process with specified post-processing steps. This example demonstrates triangulating the mesh as a post-processing step. ```rust use asset_importer::postprocess::PostProcessSteps; let scene = ImportBuilder::new() .with_source_file("model.obj") .with_post_process(PostProcessSteps::TRIANGULATE) .import()?; ``` -------------------------------- ### Get Number of Cameras in Scene Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Returns the total count of cameras defined within the scene. Useful for scene setup or analysis. ```rust pub fn num_cameras(&self) -> usize ``` ```rust println!("Scene has {} cameras", scene.num_cameras()); ``` -------------------------------- ### ExportBuilder::new Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Creates a new export builder for a specified format. This is the starting point for configuring scene exports. ```APIDOC ## ExportBuilder::new ### Description Create a new export builder for the specified format. ### Method `new>(format_id: S) -> Self` ### Parameters #### Path Parameters - **format_id** (string) - Required - Format identifier (e.g., "obj", "fbx", "gltf2") ### Returns `ExportBuilder` - Builder with default configuration ### Example ```rust let exporter = ExportBuilder::new("obj"); ``` ``` -------------------------------- ### Build Asset Importer with Prebuilt Package Source: https://github.com/latias94/asset-importer/blob/main/asset-importer/examples/README.md Builds and runs an example using a prebuilt Assimp package via the `prebuilt` feature. Requires a model path as an argument. ```bash cargo run -p asset-importer --example 01_quickstart --features prebuilt -- ``` -------------------------------- ### Create a new Importer instance Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Use `Importer::new()` to create a new importer instance. This is the starting point for all import operations. ```rust use asset_importer::Importer; let importer = Importer::new(); ``` -------------------------------- ### Build Asset Importer with Default Source Build Source: https://github.com/latias94/asset-importer/blob/main/asset-importer/examples/README.md Builds and runs an example using the default source build for Assimp. Requires a model path as an argument. ```bash cargo run -p asset-importer --example 01_quickstart -- ``` -------------------------------- ### Vector3D Operations Example Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Shows common Vector3D operations including dot product, cross product, normalization, and linear interpolation. ```rust let v1 = Vector3D::new(1.0, 2.0, 3.0); let v2 = Vector3D::new(4.0, 5.0, 6.0); let dot = v1.dot(v2); // 32.0 let cross = v1.cross(v2); // (-3.0, 6.0, -3.0) let normalized = v1.normalize(); // Unit vector let lerped = v1.lerp(v2, 0.5); // Midpoint ``` -------------------------------- ### Start import from owned memory buffer Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Use `read_from_memory_owned` for importing from an owned `Vec`. This avoids an extra data copy. ```rust let bytes = std::fs::read("model.fbx")?; let builder = importer.read_from_memory_owned(bytes); ``` -------------------------------- ### Working with Matrices in Rust Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Shows how to obtain a transformation matrix from a node and check for its invertibility by calculating the determinant and attempting to get the inverse. ```rust use asset_importer::types::Matrix4x4; let transform = node.transformation(); let det = transform.determinant(); if let Some(inverse) = transform.inverse() { println!("Matrix is invertible"); } ``` -------------------------------- ### Prebuilt Binaries Configuration Source: https://github.com/latias94/asset-importer/blob/main/asset-importer-sys/README.md Configure the asset-importer-sys crate to use prebuilt Assimp libraries. This is the fastest option for development as it avoids compilation and has no build dependencies, but requires a matching Assimp version. ```toml [dependencies] asset-importer-sys = { version = "0.8", features = ["prebuilt"] } ``` -------------------------------- ### Start import from file path Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Use `read_file` to begin building an import operation from a file. You can chain `.with_post_process()` to specify post-processing steps. ```rust let builder = importer.read_file("model.fbx") .with_post_process(PostProcessSteps::TRIANGULATE); ``` -------------------------------- ### Basic Scene Export to File Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Demonstrates how to import a scene from a file (e.g., OBJ) and then export it to another file format (e.g., FBX). Requires importing the Importer and ExportBuilder. ```rust use asset_importer::{Importer, exporter::ExportBuilder}; let scene = Importer::new().import_file("model.obj")?; ExportBuilder::new("fbx") .export_to_file(&scene, "output.fbx")?; ``` -------------------------------- ### Get String Property (Convenience with &str) Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-material.md A convenience method to get a string property using a standard string slice (`&str`). It handles potential errors during key validation. ```rust pub fn get_string_property_str(&self, key: &str) -> Result> ``` -------------------------------- ### Build Asset Importer with Explicit Source Build Source: https://github.com/latias94/asset-importer/blob/main/asset-importer/examples/README.md Builds and runs an example with an explicit source build for Assimp using the `build-assimp` feature. Requires a model path as an argument. ```bash cargo run -p asset-importer --example 01_quickstart --features build-assimp -- ``` -------------------------------- ### num_vertices Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-mesh.md Gets the total number of vertices present in the mesh. ```APIDOC ## num_vertices ### Description Get the number of vertices in the mesh. ### Method `num_vertices(&self) -> usize` ### Returns `usize` - Number of vertices ### Example ```rust let mesh = scene.mesh(0).unwrap(); println!("Vertices: {}", mesh.num_vertices()); ``` ``` -------------------------------- ### total_mb Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get the total memory usage of the scene in megabytes. ```APIDOC ## total_mb() ### Description Get the total memory usage in megabytes. ### Method GET (conceptual) ### Endpoint N/A (SDK method) ### Parameters None ### Returns `f64` - Total megabytes ### Example ```rust let info = scene.memory_info(); println!("Total: {:.2} MB", info.total_mb()); ``` ``` -------------------------------- ### Get All Supported Export Formats Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Retrieves a vector containing descriptions of all supported export formats. This method allocates memory for the vector. ```rust pub fn get_export_formats() -> Vec ``` ```rust use asset_importer::get_export_formats; for format in get_export_formats() { println!("Supported: {} ({})", format.id(), format.description()); } ``` -------------------------------- ### total_kb Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get the total memory usage of the scene in kilobytes. ```APIDOC ## total_kb() ### Description Get the total memory usage in kilobytes. ### Method GET (conceptual) ### Endpoint N/A (SDK method) ### Parameters None ### Returns `f64` - Total kilobytes ### Example ```rust let info = scene.memory_info(); println!("Total: {:.2} KB", info.total_kb()); ``` ``` -------------------------------- ### total_bytes Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get the total memory usage of the scene in bytes. ```APIDOC ## total_bytes() ### Description Get the total memory usage in bytes. ### Method GET (conceptual) ### Endpoint N/A (SDK method) ### Parameters None ### Returns `u32` - Total bytes ### Example ```rust let info = scene.memory_info(); println!("Total: {} bytes", info.total_bytes()); ``` ``` -------------------------------- ### List All Export Formats with Details Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Iterates through all supported export formats and prints their ID, description, and file extension. This example uses the iterator version to avoid memory allocation. ```rust use asset_importer::get_export_formats_iter; println!("Supported export formats:"); for format in get_export_formats_iter() { println!(" {} - {} ({})", format.id(), format.description(), format.file_extension() ); } ``` -------------------------------- ### Get Number of Lights Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Returns the total count of lights within the scene. ```rust println!("Scene has {} lights", scene.num_lights()); ``` -------------------------------- ### Start import from shared memory buffer Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Use `read_from_memory_shared` to import from an `Arc<[u8]>`. This is suitable for shared memory scenarios. ```rust use std::sync::Arc; let bytes = Arc::from(vec![/* data */].into_boxed_slice()); let builder = importer.read_from_memory_shared(bytes); ``` -------------------------------- ### Configure Import with Post-Processing Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/README.md This example shows how to configure the importer with post-processing steps, such as applying quality enhancements, before importing a file. The `PostProcessSteps::QUALITY` enum is used here. ```rust use asset_importer::{Importer, postprocess::PostProcessSteps}; let scene = Importer::new() .read_file("model.fbx") .with_post_process(PostProcessSteps::QUALITY) .import()?; ``` -------------------------------- ### Get Material Name Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-material.md Retrieves the name of the material. This method allocates a new String. ```rust pub fn name(&self) -> String ``` ```rust let material = scene.material(0).unwrap(); println!("Material: {}", material.name()); ``` -------------------------------- ### Load and Inspect a Model Source: https://github.com/latias94/asset-importer/blob/main/asset-importer/examples/README.md Demonstrates loading a model and printing a concise summary of its contents. This is a basic usage pattern. ```bash cargo run -p asset-importer --example 01_quickstart -- path/to/model.fbx ``` -------------------------------- ### Get Children Iterator Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Provides an iterator to traverse all child nodes of the current node. ```APIDOC ## children ### Description Get an iterator over all child nodes. ### Method `children(&self) -> NodeIterator` ### Returns `NodeIterator` - Iterator over all children ### Example ```rust for child in node.children() { println!("Child: {}", child.name()); } ``` ``` -------------------------------- ### System Library Configuration Source: https://github.com/latias94/asset-importer/blob/main/asset-importer-sys/README.md Configure the asset-importer-sys crate to use a system-installed Assimp library. This requires Assimp to be installed via a package manager and may involve specific configurations for Windows with vcpkg. ```toml asset-importer-sys = { version = "0.8", features = ["system", "generate-bindings"] } ``` -------------------------------- ### Get Child Node by Index Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Retrieves a specific child node using its index. ```APIDOC ## child ### Description Get a child node by index. ### Method `child(&self, index: usize) -> Option` ### Parameters #### Path Parameters - **index** (`usize`) - Required - Child index (0 to num_children-1) ### Returns `Option` - Child node at the given index ### Example ```rust if let Some(child) = node.child(0) { println!("First child: {}", child.name()); } ``` ``` -------------------------------- ### Get Number of Children Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Returns the count of direct child nodes attached to this node. ```rust pub fn num_children(&self) -> usize ``` ```rust println!("Children: {}", node.num_children()); ``` -------------------------------- ### Build from Source Configuration Source: https://github.com/latias94/asset-importer/blob/main/asset-importer-sys/README.md Configure the asset-importer-sys crate to build Assimp from its bundled source. This method ensures maximum compatibility across platforms but requires build tools like CMake and a C++ compiler. ```toml [dependencies] asset-importer-sys = "0.8" # Equivalent explicit source-build mode: asset-importer-sys = { version = "0.8", features = ["build-assimp"] } ``` -------------------------------- ### Quick import file with default settings Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Use `import_file` for a convenient, quick import of a file using default settings. It returns a `Result`. ```rust let scene = importer.import_file("model.obj")?; println!("Loaded {} meshes", scene.num_meshes()); ``` -------------------------------- ### Get Node Animation Name Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Retrieves the name of the node associated with this animation data. ```rust pub fn name(&self) -> String ``` -------------------------------- ### Get Number of Textures Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Returns the total count of embedded textures within the scene. ```rust println!("Scene has {} embedded textures", scene.num_textures()); ``` -------------------------------- ### animations Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get an iterator over all animations in the scene. This provides a way to loop through all animation components. ```APIDOC ## animations ### Description Get an iterator over all animations. ### Method `&self` ### Parameters None ### Returns `AnimationIterator` - Iterator over all animations ### Example ```rust for anim in scene.animations() { println!("Animation: {}", anim.name()); } ``` ``` -------------------------------- ### List All Supported Import Extensions Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/index.md Retrieves and prints a list of all file extensions that the asset importer can handle. ```rust use asset_importer::get_import_extensions_list; let extensions = get_import_extensions_list(); for ext in extensions.iter() { println!("Supported: {}", ext); } ``` -------------------------------- ### materials Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get an iterator over all materials in the scene. This provides a way to loop through all material definitions. ```APIDOC ## materials ### Description Get an iterator over all materials. ### Method `&self` ### Parameters None ### Returns `MaterialIterator` - Iterator over all materials ### Example ```rust for material in scene.materials() { println!("Material: {}", material.name()); } ``` ``` -------------------------------- ### meshes Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get an iterator over all meshes in the scene. This provides a way to loop through all mesh components. ```APIDOC ## meshes ### Description Get an iterator over all meshes. ### Method `&self` ### Parameters None ### Returns `MeshIterator` - Iterator over all meshes ### Example ```rust for mesh in scene.meshes() { println!("Mesh: {} vertices, {} faces", mesh.num_vertices(), mesh.num_faces()); } ``` ``` -------------------------------- ### as_raw(self) -> u32 Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-postprocess.md Get the raw bitflags value for use with the C API. ```APIDOC ## as_raw(self) -> u32 ### Description Get the raw value for use with the C API. ### Returns `u32` - Raw bitflags value ### Example ```rust let steps = PostProcessSteps::TRIANGULATE | PostProcessSteps::FLIP_UVS; let raw = steps.as_raw(); ``` ``` -------------------------------- ### Basic Model Import Source: https://github.com/latias94/asset-importer/blob/main/README.md Import a model file using the Importer and print the number of meshes and vertices. This example demonstrates basic file loading and accessing mesh data. ```rust use asset_importer::Importer; use asset_importer::postprocess::PostProcessSteps; fn main() -> Result<(), Box> { let scene = Importer::new().import_file("model.obj")?; println!("Loaded {} meshes", scene.num_meshes()); for mesh in scene.meshes() { // Zero-copy options are available: // - mesh.vertices_raw(): &[asset_importer::raw::AiVector3D] // - mesh.vertices_iter(): Iterator let vertices = mesh.vertices(); println!("Mesh has {} vertices (copied)", vertices.len()); } Ok(()) } ``` -------------------------------- ### Get Node Name Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Retrieves the name of the node as a String. Use this when a String representation is needed. ```rust pub fn name(&self) -> String ``` ```rust let node = scene.root_node().unwrap(); println!("Node: {}", node.name()); ``` -------------------------------- ### Get Number of Scaling Keyframes Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Returns the count of scaling keyframes stored for this node animation. ```rust pub fn num_scaling_keys(&self) -> usize ``` -------------------------------- ### Get Number of Rotation Keyframes Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Returns the count of rotation keyframes stored for this node animation. ```rust pub fn num_rotation_keys(&self) -> usize ``` -------------------------------- ### Get Number of Position Keyframes Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Returns the count of position keyframes stored for this node animation. ```rust pub fn num_position_keys(&self) -> usize ``` -------------------------------- ### Default Dependency: Build from Source Source: https://github.com/latias94/asset-importer/blob/main/README.md Use this configuration for the most reliable build, as it utilizes bundled Assimp source code. It requires CMake, a C++ compiler, and Git. ```toml asset-importer = "0.8" ``` -------------------------------- ### breakdown Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get a breakdown of memory usage by component, returned as a vector of (name, bytes) tuples. ```APIDOC ## breakdown() ### Description Get a breakdown of memory usage by component. ### Method GET (conceptual) ### Endpoint N/A (SDK method) ### Parameters None ### Returns `Vec<(&'static str, u32)>` - Vector of (name, bytes) tuples ### Example ```rust let info = scene.memory_info(); for (name, bytes) in info.breakdown() { println!("{}: {} bytes", name, bytes); } ``` ``` -------------------------------- ### Configure Post-Processing with Direct Import Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-postprocess.md Utilize `Importer::new` with a closure to configure post-processing steps for direct file import. This method is useful for applying a set of configurations concisely. ```rust let scene = Importer::new() .import_file_with("model.fbx", |b| { b.with_post_process(PostProcessSteps::QUALITY) })?; ``` -------------------------------- ### Get Scene Metadata Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Retrieves the scene-level metadata if it exists. Returns None if no metadata is present. ```rust if let Some(metadata) = scene.metadata() { println!("Metadata keys: {}", metadata.num_properties()); } ``` -------------------------------- ### num_cameras Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get the total number of cameras in the scene. This method returns the count of all camera components. ```APIDOC ## num_cameras ### Description Get the total number of cameras in the scene. ### Method `&self` ### Parameters None ### Returns `usize` - Number of cameras ### Example ```rust println!("Scene has {} cameras", scene.num_cameras()); ``` ``` -------------------------------- ### Implement Custom File System for Asset Import Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/index.md Shows how to implement the `FileSystem` trait for custom I/O operations and use it with `ImportBuilder`. ```rust use asset_importer::io::FileSystem; struct MyFileSystem { // Custom state } impl FileSystem for MyFileSystem { // Implement required trait methods } let scene = ImportBuilder::new() .with_source_file("model.obj") .with_file_system(MyFileSystem {}) .import()?; ``` -------------------------------- ### Loading a 3D Model with Assimp in Rust Source: https://github.com/latias94/asset-importer/blob/main/asset-importer-sys/README.md Demonstrates how to use the `asset-importer-sys` crate to load a 3D model file. This snippet shows the creation of an importer, importing a file with specific processing flags, and basic scene information retrieval. Remember to handle null pointers and release resources properly. ```rust use asset_importer_sys as sys; use std::ffi::CString; use std::ptr; unsafe { let importer = sys::aiCreateImporter(); let filename = CString::new("model.obj").unwrap(); let scene = sys::aiImportFile( filename.as_ptr(), sys::aiProcess_Triangulate | sys::aiProcess_FlipUVs ); if !scene.is_null() { let scene_ref = &*scene; println!("Loaded {} meshes", scene_ref.mNumMeshes); sys::aiReleaseImporter(importer); } } ``` -------------------------------- ### num_animations Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get the total number of animations in the scene. This method returns the count of all animation components. ```APIDOC ## num_animations ### Description Get the total number of animations in the scene. ### Method `&self` ### Parameters None ### Returns `usize` - Number of animations ### Example ```rust println!("Scene has {} animations", scene.num_animations()); ``` ``` -------------------------------- ### Test Mint Math Library Integration Source: https://github.com/latias94/asset-importer/blob/main/asset-importer/examples/README.md Tests the interoperability between asset-importer and the `mint` math library. Requires the `mint` feature to be enabled. ```bash cargo run -p asset-importer --example 07_mint_integration --features mint ``` -------------------------------- ### num_materials Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get the total number of materials in the scene. This method returns the count of all material definitions. ```APIDOC ## num_materials ### Description Get the total number of materials in the scene. ### Method `&self` ### Parameters None ### Returns `usize` - Number of materials ### Example ```rust println!("Scene has {} materials", scene.num_materials()); ``` ``` -------------------------------- ### Set Properties from PropertyStore Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Use `with_property_store` to set multiple properties at once from a `PropertyStore` object. This is efficient for bulk configuration. ```rust pub fn with_property_store(self, store: PropertyStore) -> Self ``` ```rust let mut props = PropertyStore::new(); props.set_bool("flag", true); let scene = ImportBuilder::new() .with_source_file("model.obj") .with_property_store(props) .import()?; ``` -------------------------------- ### Prebuilt Binaries Dependency Source: https://github.com/latias94/asset-importer/blob/main/README.md Opt-in to use prebuilt binaries for faster builds without native Assimp compilation. This requires matching release artifacts from GitHub releases. ```toml asset-importer = { version = "0.8", features = ["prebuilt"] } ``` -------------------------------- ### Add Properties from PropertyStore Reference Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Add properties from a `PropertyStore` using a reference. This is useful when the `PropertyStore` is managed elsewhere or needs to be shared. ```rust pub fn with_property_store_ref(self, store: &PropertyStore) -> Self ``` ```rust let props = PropertyStore::new(); let exporter = ExportBuilder::new("obj") .with_property_store_ref(&props); ``` -------------------------------- ### Importer::read_from_memory Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Starts an import operation from a byte slice in memory. The data is copied into an owned buffer. ```APIDOC ## Importer::read_from_memory ### Description Starts an import operation from a byte slice in memory. The data is copied into an owned buffer. ### Method `read_from_memory(&self, data: &[u8]) -> ImportBuilder` ### Parameters #### Path Parameters - **data** (`&[u8]`) - Required - Memory buffer containing asset data ### Returns `ImportBuilder` - Builder for further configuration ### Note This copies `data` into an owned buffer so the builder can be `'static`. For owned buffers, prefer `read_from_memory_owned()`. ### Example ```rust let bytes: Vec = std::fs::read("model.obj")?; let builder = importer.read_from_memory(&bytes); ``` ``` -------------------------------- ### Get Number of Properties Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Return the count of properties currently stored. This can be used to check the size of the configuration. ```rust pub fn len(&self) -> usize ``` ```rust let mut store = PropertyStore::new(); store.set_int("a", 1).set_int("b", 2); assert_eq!(store.len(), 2); ``` -------------------------------- ### Static Linking Configuration Source: https://github.com/latias94/asset-importer/blob/main/asset-importer-sys/README.md Configure the asset-importer-sys crate for static linking, combining Assimp with your executable to reduce external runtime dependencies at the cost of a larger binary size. ```toml asset-importer-sys = { version = "0.8", features = ["static-link", "build-assimp"] } ``` -------------------------------- ### get_string_property_str Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-material.md A convenience method to get a string property, accepting a standard Rust string slice (`&str`). ```APIDOC ## get_string_property_str ### Description Get a string property from the material (convenience, accepts `&str`). ### Method `get_string_property_str` ### Parameters #### Path Parameters - **key** (`&str`) - Required - Property key as string ### Returns `Result>` - Property value, or error if key is invalid ``` -------------------------------- ### Get ExportFormatDesc Description Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Retrieves a human-readable description of the export format. Useful for displaying options to the user. ```rust pub fn description(&self) -> &str ``` ```rust for format in get_export_formats_iter() { println!("{}: {}", format.id(), format.description()); } ``` -------------------------------- ### Get Animation Name Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Retrieves the name of an animation. Useful for identifying specific animations within a scene. ```rust let anim = scene.animation(0).unwrap(); println!("Animation: {}", anim.name()); ``` -------------------------------- ### Basic Post-Processing Steps Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-postprocess.md Applies basic post-processing steps like triangulating meshes and flipping UV coordinates. ```rust use asset_importer::{Importer, postprocess::PostProcessSteps}; let scene = Importer::new() .read_file("model.obj") .with_post_process(PostProcessSteps::TRIANGULATE | PostProcessSteps::FLIP_UVS) .import()?; ``` -------------------------------- ### Get Root Node Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Retrieves the root node of the scene hierarchy. Returns None if the scene is empty. ```rust if let Some(root) = scene.root_node() { println!("Root node: {}", root.name()); for child in root.children() { println!(" Child: {}", child.name()); } } ``` -------------------------------- ### Configure Preprocessing Steps Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Sets the preprocessing steps to be applied before exporting. The `steps` parameter uses bitflags to define the operations. ```rust pub fn with_preprocessing(self, steps: u32) -> Self ``` ```rust let exporter = ExportBuilder::new("fbx") .with_preprocessing(0x1); // Example flags ``` -------------------------------- ### Construct Color3D instances Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Provides methods to create Color3D instances. Use `new` for specific RGB values and `splat` to create a uniform color. ```rust impl Color3D { pub const fn new(r: f32, g: f32, b: f32) -> Self pub const fn splat(v: f32) -> Self } ``` -------------------------------- ### Clear All Properties Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Remove all properties from the store, resetting it to an empty state. This is useful for starting a new configuration or cleaning up. ```rust pub fn clear(&mut self) ``` ```rust let mut store = PropertyStore::new(); store.set_int("key", 42); store.clear(); ``` -------------------------------- ### Working with Vectors in Rust Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Demonstrates basic vector operations including creation, subtraction to find an edge, calculating length, and normalizing to get a direction vector. ```rust use asset_importer::types::Vector3D; let vertex_a = Vector3D::new(0.0, 0.0, 0.0); let vertex_b = Vector3D::new(1.0, 0.0, 0.0); let edge = vertex_b - vertex_a; let length = edge.length(); let direction = edge.normalize(); println!("Edge length: {}", length); println!("Direction: ({}, {}, {})", direction.x, direction.y, direction.z); ``` -------------------------------- ### Hierarchy Traversal of Scene Nodes Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/README.md Traverse the node hierarchy of a scene, starting from the root node and iterating through its children. ```rust if let Some(root) = scene.root_node() { for child in root.children() { // Recursive traversal } } ``` -------------------------------- ### Face::vertex_indices Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-mesh.md Get a slice containing all vertex indices that define this face. This provides a zero-copy view of the indices. ```APIDOC ## Face::vertex_indices ### Description Get all vertex indices in the face (zero-copy). ### Method `vertex_indices(&self) -> &[u32]` ### Returns `&[u32]` - Slice of vertex indices ### Example ```rust let face = mesh.face(0).unwrap(); for &v_idx in face.vertex_indices() { println!("Vertex: {}", v_idx); } ``` ``` -------------------------------- ### Create New MemoryInfo Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Initializes a new MemoryInfo struct with all memory usage fields set to zero. Use this to start tracking memory allocation. ```rust pub fn new() -> Self ``` ```rust let info = scene.memory_info(); println!("Total: {} bytes", info.total_bytes()); ``` -------------------------------- ### Face::vertex_index Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-mesh.md Get a specific vertex index from the face by its position within the face's vertex list. ```APIDOC ## Face::vertex_index ### Description Get a vertex index from the face. ### Method `vertex_index(&self, index: usize) -> Option` ### Parameters #### Path Parameters - **index** (`usize`) - Required - Index into the face's vertex list ### Returns `Option` - Vertex index, or `None` if out of bounds ### Example ```rust let face = mesh.face(0).unwrap(); if let Some(v_idx) = face.vertex_index(0) { println!("First vertex index: {}", v_idx); } ``` ``` -------------------------------- ### Get Bone by Index Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-mesh.md Retrieves a specific bone from the mesh using its index. Returns `None` if the index is out of bounds. ```rust pub fn bone(&self, index: usize) -> Option ``` ```rust if let Some(bone) = mesh.bone(0) { println!("Bone: {}", bone.name()); } ``` -------------------------------- ### Set post-processing steps for import Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Specifies the post-processing steps to be applied after the initial import. Steps are provided as bitflags. ```rust pub fn with_post_process(self, steps: PostProcessSteps) -> Self ``` ```rust use asset_importer::postprocess::PostProcessSteps; let scene = ImportBuilder::new() .with_source_file("model.obj") .with_post_process(PostProcessSteps::TRIANGULATE | PostProcessSteps::GEN_SMOOTH_NORMALS) .import()?; ``` -------------------------------- ### Get Face by Index Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-mesh.md Retrieves a specific face from the mesh using its index. Returns None if the index is out of bounds. ```rust if let Some(face) = mesh.face(0) { for &vertex_idx in face.vertex_indices() { println!("Vertex index: {}", vertex_idx); } } ``` -------------------------------- ### Construct Color4D instances Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/types.md Provides methods to create Color4D instances. Use `new` for specific RGBA values and `splat` for uniform color and alpha. ```rust impl Color4D { pub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self pub const fn splat(v: f32) -> Self } ``` -------------------------------- ### Import Scene from File Path Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Use this method to import a 3D scene from a local file. It requires a path to the asset file. Ensure the file exists and is accessible. ```rust pub fn import_file>(self, path: P) -> Result ``` ```rust let scene = ImportBuilder::new() .with_post_process(PostProcessSteps::TRIANGULATE) .import_file("model.obj")?; ``` -------------------------------- ### Get Specific Scaling Keyframe Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Retrieves a scaling keyframe at a specified index. Returns None if the index is invalid. ```rust pub fn scaling_key(&self, index: usize) -> Option ``` -------------------------------- ### Get Specific Rotation Keyframe Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Retrieves a rotation keyframe at a specified index. Returns None if the index is invalid. ```rust pub fn rotation_key(&self, index: usize) -> Option ``` -------------------------------- ### MemoryInfo::new Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Create a new empty memory info structure. All fields will be initialized to zero. ```APIDOC ## MemoryInfo::new() ### Description Create a new empty memory info. ### Method POST (conceptual) ### Endpoint N/A (SDK method) ### Parameters None ### Returns `MemoryInfo` - Empty memory info with all fields set to 0 ### Example ```rust let memory_info = MemoryInfo::new(); ``` ``` -------------------------------- ### Get ExportBlob Name Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Retrieves the suggested filename for the exported data. Useful for saving files with appropriate names. ```rust pub fn name(&self) -> &str ``` ```rust let blob = ExportBuilder::new("obj").export_to_blob(&scene)?; println!("Suggested name: {}", blob.name()); ``` -------------------------------- ### from_raw(value: u32) -> Self Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-postprocess.md Create a PostProcessSteps instance from a raw u32 bitflags value. ```APIDOC ## from_raw(value: u32) -> Self ### Description Create from raw value. ### Parameters #### Path Parameters - **value** (u32) - Required - Raw bitflags value ### Returns `PostProcessSteps` - Constructed flags ### Example ```rust let steps = PostProcessSteps::from_raw(0x0001); ``` ``` -------------------------------- ### Get Specific Position Keyframe Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Retrieves a position keyframe at a specified index. Returns None if the index is invalid. ```rust pub fn position_key(&self, index: usize) -> Option ``` -------------------------------- ### Import Scene from File with Custom Configuration (Rust) Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-importer.md Imports a 3D scene from a file path using a closure to configure the import process. This allows for fine-grained control over post-processing steps. ```rust pub fn import_file_with(&self, path: P, f: F) -> Result where P: AsRef, F: FnOnce(ImportBuilder) -> ImportBuilder ``` ```rust use asset_importer::postprocess::PostProcessSteps; let scene = importer.import_file_with("model.fbx", |b| { b.with_post_process(PostProcessSteps::TRIANGULATE | PostProcessSteps::FLIP_UVS) })?; ``` -------------------------------- ### Builder Configuration for Asset Import Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/README.md Configure import settings using a builder pattern, specifying source files, post-processing steps, and properties. ```rust ImportBuilder::new() .with_source_file("model.fbx") .with_post_process(PostProcessSteps::TRIANGULATE) .with_property_bool("MATERIAL_FLAG", true) .import()? ``` -------------------------------- ### Get Animation Duration in Seconds Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-animation-node.md Calculates and retrieves the duration of an animation in seconds. This provides a more human-readable time measurement. ```rust let duration_sec = anim.duration_in_seconds(); println!("Duration: {:.2} seconds", duration_sec); ``` -------------------------------- ### Get Light by Index Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Retrieves a specific light from the scene using its index. Returns None if the index is out of bounds. ```rust if let Some(light) = scene.light(0) { println!("Light: {}", light.name()); } ``` -------------------------------- ### Import a 3D Model Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/index.md Import a 3D model file using the default importer settings. This is the most basic way to load a file. ```rust use asset_importer::Importer; let scene = Importer::new().import_file("model.obj")?; println!("Loaded {} meshes", scene.num_meshes()); ``` -------------------------------- ### Get Camera by Index Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Retrieves a specific camera from the scene using its index. Returns None if the index is out of bounds. ```rust if let Some(camera) = scene.camera(0) { println!("Camera: {}", camera.name()); } ``` -------------------------------- ### Additional Build Feature Options Source: https://github.com/latias94/asset-importer/blob/main/asset-importer-sys/README.md Enable additional features for the asset-importer-sys crate, such as export functionality, disabling zlib linking, math library interop with 'mint', or convenience type extensions. ```toml asset-importer-sys = { version = "0.8", features = [ "build-assimp", "export", # Enable export functionality "nozlib", # Don't link zlib "mint", # Math library interop "type-extensions" # Convenience methods ] } ``` -------------------------------- ### animation Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get an animation by its index. This method allows retrieving a specific animation component from the scene if the index is valid. ```APIDOC ## animation ### Description Get an animation by index. ### Method `&self` ### Parameters #### Path Parameters - **index** (`usize`) - Required - Animation index (0 to num_animations-1) ### Returns `Option` - Animation at the given index, or `None` if out of bounds ### Example ```rust if let Some(anim) = scene.animation(0) { println!("Animation duration: {} ticks", anim.duration()); } ``` ``` -------------------------------- ### with_file_system Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Sets a custom file system for exporting. This allows for integration with different storage backends. ```APIDOC ## with_file_system(self, file_system: F) -> Self ### Description Set a custom file system for exporting. ### Method This is a builder method, typically called on an `ExportBuilder` instance. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **file_system** (F) - Required - Custom file system implementation ### Returns `Self` - Builder for method chaining ### Example ```rust struct MyFileSystem { /* ... */ } impl FileSystem for MyFileSystem { /* ... */ } let exporter = ExportBuilder::new("obj") .with_file_system(MyFileSystem { }); ``` ``` -------------------------------- ### material Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-scene.md Get a material by its index. This method allows retrieving a specific material definition from the scene if the index is valid. ```APIDOC ## material ### Description Get a material by index. ### Method `&self` ### Parameters #### Path Parameters - **index** (`usize`) - Required - Material index (0 to num_materials-1) ### Returns `Option` - Material at the given index, or `None` if out of bounds ### Example ```rust if let Some(material) = scene.material(0) { println!("Material: {}", material.name()); } ``` ``` -------------------------------- ### Add Properties from PropertyStore Source: https://github.com/latias94/asset-importer/blob/main/_autodocs/api-exporter.md Incorporate properties from a pre-configured `PropertyStore` into the export settings. This allows for batch setting of export options. ```rust pub fn with_property_store(self, store: PropertyStore) -> Self ``` ```rust let mut props = PropertyStore::new(); props.set_bool("embedded", true); let exporter = ExportBuilder::new("gltf2") .with_property_store(props); ```