assimp/import/structs.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
//! Argument structs for `Importer` post-processing configuration.
use ffi::config::*;
use math::Matrix4x4;
/// Enumerates components of the Scene and Mesh data structures that can be excluded from the import
/// using the `remove_component` step.
///
/// See `Importer::remove_component` for more details.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ComponentType {
Normals,
TangentsAndBitangents,
Colors,
TexCoords,
BoneWeights,
Animations,
Textures,
Lights,
Cameras,
Meshes,
Materials
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum UVTransformFlag {
Scaling,
Rotation,
Translation,
All
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PrimitiveType {
Point,
Line,
Triangle,
Polygon
}
// Macro to simplify defining and structs and implementing Default trait
// NOTE: pub keyword in field definition is to workaround rust issue #24189
macro_rules! struct_with_defaults {
($(#[$struct_attr:meta])* struct $i:ident {
$($(#[$field_attr:meta])* pub $n:ident: $t:ty = $v:expr),*
}) => (
$(#[$struct_attr])*
pub struct $i {
/// Whether to enable the step. Default: false
pub enable: bool,
$($(#[$field_attr])* pub $n: $t),*
}
impl Default for $i {
fn default() -> $i {
$i {
enable: false,
$($n: $v),*
}
}
}
)
}
struct_with_defaults! {
/// Arguments for `calc_tangent_space` post-process step.
struct CalcTangentSpace {
/// Maximum angle between two vertex tangents used for smoothing. Default: 45.0
pub max_smoothing_angle: f32 = 45.0,
/// Source UV channel for tangent space computation. Default: 0
pub texture_channel: i32 = 0
}
}
struct_with_defaults! {
/// Arguments for `remove_component` post-process step.
struct RemoveComponent {
/// Specify which components to remove. Default: none
pub components: Vec<ComponentType> = Vec::new()
}
}
struct_with_defaults! {
/// Arguments for `generate_normals` post-process step.
struct GenerateNormals {
/// Whether the generated normals are smoothed or not. Default: false
pub smooth: bool = false,
/// Maximum angle between two vertex normals used for smoothing. Default: 175.0
/// Only applies if `smooth` is `true`.
pub max_smoothing_angle: f32 = 175.0
}
}
struct_with_defaults! {
/// Arguments for `split_large_meshes` post-process step.
struct SplitLargeMeshes {
/// Maximum number of vertices per mesh. Default: 1000000
pub vertex_limit: i32 = AI_SLM_DEFAULT_MAX_VERTICES,
/// Maximum number of triangles per mesh. Default: 1000000
pub triangle_limit: i32 = AI_SLM_DEFAULT_MAX_TRIANGLES
}
}
struct_with_defaults! {
/// Arguments for `pre_transform_vertices` post-process step.
struct PreTransformVertices {
/// Whether to keep the existing scene hierarchy. Default: false
pub keep_hierarchy: bool = false,
/// Whether to normalize all vertices into the [-1, 1] range. Default: false
pub normalize: bool = false,
/// Whether to pre-transform all vertices using the matrix specified in the
/// `root_transformation` field. Default: false
pub add_root_transformation: bool = false,
/// Transformation matrix to use.
pub root_transformation: Matrix4x4 = Matrix4x4::new(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0)
}
}
struct_with_defaults! {
/// Arguments for `limit_bone_weights` post-process step.
struct LimitBoneWeights {
/// Maximum number of bones that affect a single vertex. Default: 4
pub max_weights: i32 = AI_LMW_MAX_WEIGHTS
}
}
struct_with_defaults! {
/// Arguments for `improve_cache_locality` post-process step.
struct ImproveCacheLocality {
/// Set the size of the post-transform vertex cache. Default: 12
pub cache_size: i32 = PP_ICL_DEFAULT_PTCACHE_SIZE
}
}
struct_with_defaults! {
/// Arguments for `remove_redundant_materials` post-process step.
struct RemoveRedundantMaterials {
/// Space-delimited list of materials to keep. Identifiers containing whitespace must be
/// enclosed in single quotes. e.g. `material1 'material 2' material3`.
pub exclude_list: String = String::new()
}
}
struct_with_defaults! {
/// Arguments for `sort_by_primitive_type` post-process step.
struct SortByPrimitiveType {
/// List of primitive types to remove. Default: none
pub remove: Vec<PrimitiveType> = Vec::new()
}
}
struct_with_defaults! {
/// Arguments for `find_degenerates` post-process step.
struct FindDegenerates {
/// Whether to remove any found degenerates. Default: true
pub remove: bool = false
}
}
struct_with_defaults! {
/// Arguments for `find_invalid_data` post-process step.
struct FindInvalidData {
/// Specify the accuracy for considering animation values as invalid. Default: 0
pub accuracy: f32 = 0.0
}
}
struct_with_defaults! {
/// Arguments for `transform_uv_coords` post-process step.
struct TransformUVCoords {
/// Specify which UV transforms to evaluate. Default: all
pub flags: Vec<UVTransformFlag> = vec![UVTransformFlag::All]
}
}
struct_with_defaults! {
/// Arguments for `optimize_graph` post-process step.
struct OptimizeGraph {
/// Space-delimited list of nodes to keep. Identifiers containing whitespace must be
/// enclosed in single quotes. e.g. `node1 'node 2' node3`.
pub exclude_list: String = String::new()
}
}
struct_with_defaults! {
/// Arguments for `split_by_bone_count` post-process step.
struct SplitByBoneCount {
/// Maximum number of bones per mesh. Default: 60
pub max_bones: i32 = AI_SBBC_DEFAULT_MAX_BONES
}
}
struct_with_defaults! {
/// Arguments for `debone` post-process step.
struct Debone {
/// Threshold for considering bone necessary. Default: 1.0
pub threshold: f32 = AI_DEBONE_THRESHOLD,
/// Whether to require all bones to meet the threshold before removing any. Default: false
pub all_or_none: bool = false
}
}