Struct gltfgen::config::Config

source ·
pub struct Config {
Show 17 fields pub pattern: String, pub output: PathBuf, pub quiet: bool, pub fps: u32, pub time_step: Option<f32>, pub reverse: bool, pub invert_tets: bool, pub step: u32, pub colors: AttributeInfo, pub attributes: AttributeInfo, pub texcoords: TextureAttributeInfo, pub textures: Vec<TextureInfo>, pub materials: Vec<MaterialInfo>, pub material_attribute: String, pub insert_vanishing_frames: bool, pub no_animated_normals: bool, pub no_animated_tangents: bool,
}
Expand description

Output configuration for the generated glTF.

Fields§

§pattern: String

A glob pattern matching input mesh files.

Use # to match a frame number. If more than one ‘#’ is used, the first match will correspond to the frame number. Note that the glob pattern should generally by provided as a quoted string to prevent the terminal from evaluating it.

Strings within between braces (i.e. ‘{’ and ‘}’) will be used as names for unique animations. This means that a single output can contain multiple animations. If more than one group is specified, the matched strings within will be concatenated to produce a unique name. Note that for the time being, ‘{’ ‘}’ are ignored when the glob pattern is matched.

§output: PathBuf

Output glTF file.

§quiet: bool

Silence all output.

§fps: u32

Frames per second.

1/fps gives the time step between discrete frames. If ‘time_step’ is also provided, this parameter is ignored.

§time_step: Option<f32>

Time step in seconds between discrete frames.

Specifying this option overrides the time step that would be computed from ‘fps’, which is set to 24 by default. This means that the default ‘time_step’ is equivalently 1/24.

§reverse: bool

Reverse polygon orientations on output meshes.

§invert_tets: bool

Invert tetrahedra orientations on input meshes.

§step: u32

Step by the given number of frames.

In other words, read frames in increments of ‘step’. Note that this does not affect the value for ‘fps’ or ‘time_step’ options. This number must be at least 1.

For example for frames 1 to 10, a ‘step’ value of 3 will read frames 1, 4, 7, and 10.

§colors: AttributeInfo

A dictionary of color attributes and their types.

The dictionary string should have the following pattern:

‘{“color0”:type0(component_type0), “color1”:type1(component_type1), ..}’

The color attribute names should appear exactly how they are named in the input mesh files. On the output, these names will be converted to COLOR_# where # corresponds to the index (starting from 0) in the order they are provided on the command line.

The associated types must have the format ‘type(component)’ where ‘type’ is one of [Vec3, Vec4].

The component type can be one of [U8, U16, F32].

which correspond to ‘GL_UNSIGNED_BYTE’, ‘GL_UNSIGNED_SHORT’, and ‘GL_FLOAT’ respectively.

Note that component type names may be specified in lower case as well.

LIMITATIONS:

See LIMITATIONS section for the ‘–attributes’ flag.

EXAMPLES:

The following is a valid texture coordinate attribute list:

‘{“diffuse”: Vec3(f32), “bump”: Vec3(F32)}’

§attributes: AttributeInfo

A dictionary of vertex attributes and their types.

The dictionary string should have the following pattern:

‘{“attribute1”:type1(component1), “attribute2”:type2(component2), ..}’

Use this to specify custom attributes as well as special attributes like normals and tangents, which are expected to be named “N” and “T” respectively. If an input file does not have a specific way to specify these attributes, make sure that they are appropriately named on the input and have single precision floating point component type (f32).

For custom attributes, the attribute names should appear exactly how the attribute is named in the input mesh files. On the output, the attribute names will be converted to SCREAMING_SNAKE case prefixed with an underscore as required by the glTF 2.0 specifications.

For example an attribute named “temperatureKelvin” will be stored as “_TEMPERATURE_KELVIN” in the output. There are no guarantees for collision resolution resulting from this conversion.

The associated types must have the format ‘type(component)’ where ‘type’ is one of [Scalar, Vec2, Vec3, Vec4, Mat2, Mat3, or Mat4].

and ‘component’ is one of [I8, U8, I16, U16, U32, F32].

which correspond to ‘GL_BYTE’, ‘GL_UNSIGNED_BYTE’, ‘GL_SHORT’, ‘GL_UNSIGNED_SHORT’, ‘GL_UNSIGNED_INT’ and ‘GL_FLOAT’ respectively.

Scalar types may be specified without the ‘Scalar(..)’, but with the component type directly as ‘attribute: F32’ instead of ‘attribute: Scalar(F32)’.

If this flag is omitted, then gltfgen looks for normal vertex attributes named “N” by default. This will pick up dedicated normal attributes in formats like ‘vn’ in ‘.obj’ files and NORMALS in ‘.vtk’ files.

Note that type and component names may be specified in all lower case as well.

LIMITATIONS:

Component types are not converted from the input to the output, so it’s important that they are stored in the input files exactly in the types supported by glTF 2.0. This means that double precision float attribute will not be transferred to a single precision float attribute in glTF, but will simply be ignored.

EXAMPLES:

The following is a valid attribute list demonstrating different ways to specify types and component types:

‘{“temperature”:F32, “force”:Vec3(F32), “material”:Scalar(u32)}’

§texcoords: TextureAttributeInfo

A dictionary of texture coordinate attributes and their types.

The dictionary string should have the following pattern:

‘{“texcoord0”:component_type1, “texcoord1”:component_type2, ..}’

The texture coordinate attribute names should appear exactly how they are named in the input mesh files. On the output, these names will be converted to TEXCOORD_# where # corresponds to the index (starting from 0) in the order they are provided on the command line.

The component type can be one of [U8, U16, F32].

which correspond to ‘GL_UNSIGNED_BYTE’, ‘GL_UNSIGNED_SHORT’, and ‘GL_FLOAT’ respectively.

If this flag is omitted, then gltfgen looks for texture attributes named “uv” by default. This will pick up dedicated texture attributes in formats like ‘vt’ in ‘.obj’ files and TEXTURE_COORDINATES in ‘.vtk’ files.

Note that component type names may be specified in lower case as well.

LIMITATIONS:

See LIMITATIONS section for the ‘–attributes’ flag.

EXAMPLES:

The following is a valid texture coordinate attribute list:

‘{“uv”: f32, “bump”: F32}’

§textures: Vec<TextureInfo>

A tuple of texture parameters.

Each struct should have the following pattern:

“( image: Image, [wrap_s: WrappingMode,] [wrap_t: WrappingMode,] [mag_filter: MagFilter,] [min_filter: MinFilter,] ) ..”

where the fields in brackets ‘[]’ are optional. ‘Image’, ‘WrappingMode’, ‘MagFilter’ and ‘MinFilter’ are enums (variants) that take on the following values:

‘Image’ is one of{n} * Auto(path_to_image){n} * Uri(path_to_image){n} * Embed(path_to_image){n}

where ‘path_to_image’ is the path to a ‘png’ or a ‘jpeg’ image which will be either referenced (‘Uri’) or embedded (‘Embed’) into the gltf file itself. Images specified ‘Auto’ will be referenced for .gltf outputs and embedded for .glb outputs.

The remaining optional fields describe the sampler and can take on the following values:

‘WrappingMode’ is one of [ClampedToEdge, MirroredRepeat, Repeat (default)].

‘MagFilter’ is one of [Nearest, Linear].

‘MinFilter’ is one of [Nearest, Linear, NearestMipmapNearest, LinearMipmapNearest, NearestMipmapLinear, or LinearMipmapLinear].

See the glTF 2.0 specifications for more details https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture-data

Note that all options may be specified in snake_case as well.

EXAMPLES:

The following is a valid texture list:

‘(image: Uri(“./texture.png”)) (image: Embed(“./texture2.png”), wrap_s: Repeat wrap_t: mirrored_repeat)’

§materials: Vec<MaterialInfo>

A tuple of material properties.

Each struct should have the following pattern:

“(name:String, base_color:[f32; 4], base_texture:(index:u32,texcoord:u32), metallic:f32, roughness:f32) ..”

where ‘f32’ indicates a single precision floating point value, and ‘u32’ a 32 bit unsigned integer. All fields are optional. The type ‘[f32; 4]’ is an array of 4 floats corresponding to red, green, blue and alpha values between 0.0 and 1.0. ‘metallic’ and ‘roughness’ factors are expected to be between 0.0 and 1.0.

‘base_texture’ specifies the texture to be used by the material. ‘index’ specifies the 0-based index of the texture provided by the ‘–textures’ (or ‘-x’) flag. ‘texcoord’ specifies the index of the texture attribute specified by the ‘–texcoords’ (or ‘-u’) flag. ‘base_texture’ is not set by default.

Default values are 0.0 for ‘metallic’, 0.5 for ‘roughness’, and [0.5, 0.5, 0.5, 1.0] for ‘base_color’.

If a texture is specified with the -x or –textures flag in ‘Auto’ mode (default), then gltfgen will create a default binding to each ‘Auto’ image found. Note that the ‘index’ specified in ‘base_texture’ will be in the order the ‘Auto’ images are found, which is unspecified. This means that it is best to place the ‘Auto’ image reference at the end of the list if used.

EXAMPLES:

The following are examples of valid material specifications:

“()”

produces a default material.

‘(name:“material0”, base_color:[0.1, 0.2, 0.3, 1.0], metallic:0.0)’

produces a material named “material0” with the specified base_color and metallic factor.

§material_attribute: String

Name of the material attribute on mesh faces or cells.

This is used for determining which materials should be assigned to which meshes.

This attribute must be an integer (at most 64 bit) and must index materials specified by the ‘-m’ or ‘–materials’ flag.

§insert_vanishing_frames: bool

Inserts additional frames before and after an animation sequence with all vertex positions at the origin.

This effectively hides meshes before and after each animation sequence, giving the illusion of continuous animation to sequences with varying topology. This depends heavily on glTF viewers implementing framed animation correctly (e.g. this will work in Blender but not in most web viewers).

CAVEATS: When viewing the animation at a higher frame rate than what was originally specified (to gltfgen) the meshes will blend in and out of the origin between frames which have different topologies, which breaks the illusion.

§no_animated_normals: bool

Skip animated normals to reduce file size.

Normals are still transferred for the base mesh for each output node if ‘“N”: Vec3(f32)’ is specified in the ‘–attributes’ option.

§no_animated_tangents: bool

Skip animated tangents to reduce file size.

Tangents are still transferred for the base mesh for each output node if ‘“T”: Vec3(f32)’ is specified in the ‘–attributes’ option.

Implementations§

source§

impl Config

source

pub fn load_with_override( path: impl AsRef<Path>, other: &Config, matches: &ArgMatches ) -> Result<Config, Error>

source

pub fn override_from_matches(&mut self, other: &Config, matches: &ArgMatches)

Override this configuration with matches from the command line.

Trait Implementations§

source§

impl Args for Config

source§

fn group_id() -> Option<Id>

Report the [ArgGroup::id][crate::ArgGroup::id] for this set of arguments
source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate Self. Read more
source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to [Command] so it can update self. Read more
source§

impl CommandFactory for Config

source§

fn command<'b>() -> Command

Build a [Command] that can instantiate Self. Read more
source§

fn command_for_update<'b>() -> Command

Build a [Command] that can update self. Read more
source§

impl Debug for Config

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Config

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl FromArgMatches for Config

source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches ) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches ) -> Result<(), Error>

Assign values from ArgMatches to self.
source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches ) -> Result<(), Error>

Assign values from ArgMatches to self.
source§

impl Parser for Config

§

fn parse() -> Self

Parse from std::env::args_os(), exit on error
§

fn try_parse() -> Result<Self, Error>

Parse from std::env::args_os(), return Err on error.
§

fn parse_from<I, T>(itr: I) -> Selfwhere I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, exit on error
§

fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, return Err on error.
§

fn update_from<I, T>(&mut self, itr: I)where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, exit on error
§

fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, return Err on error.
source§

impl Serialize for Config

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Bytes for T

source§

fn as_bytes(&self) -> &[u8]

Get a slice of bytes representing Self.
source§

fn interpret_bytes(bytes: &[u8]) -> &Self

Panics if the size of the given bytes slice is not equal to the size of Self.
§

impl<T> DebugBytes for Twhere T: Debug + 'static,

§

unsafe fn fmt_bytes( bytes: &[MaybeUninit<u8>], f: &mut Formatter<'_> ) -> Result<(), Error>

§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DropBytes for Twhere T: 'static,

§

unsafe fn drop_bytes(bytes: &mut [MaybeUninit<u8>])

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<'a, S, I> Get<'a, I> for Swhere I: GetIndex<'a, S>,

§

type Output = <I as GetIndex<'a, S>>::Output

§

fn get(&self, idx: I) -> Option<<I as GetIndex<'a, S>>::Output>

§

fn at(&self, idx: I) -> Self::Output

Return a value at the given index. This is provided as the checked version of get that will panic if the equivalent get call is None, which typically means that the given index is out of bounds. Read more
§

unsafe fn at_unchecked(&self, idx: I) -> Self::Output

Return a value at the given index. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<S, I> Isolate<I> for Swhere I: IsolateIndex<S>,

§

type Output = <I as IsolateIndex<S>>::Output

§

unsafe fn isolate_unchecked(self, idx: I) -> <S as Isolate<I>>::Output

Unchecked version of isolate. Read more
§

fn try_isolate(self, idx: I) -> Option<<S as Isolate<I>>::Output>

§

fn isolate(self, idx: I) -> Self::Outputwhere Self: Sized,

Return a value at the given index. This is provided as the checked version of try_isolate that will panic if the equivalent try_isolate call is None, which typically means that the given index is out of bounds. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

§

impl<T> Elem for Twhere T: Any + DropBytes,