pub struct ObjDecoder { /* private fields */ }Expand description
Wavefront OBJ decoder.
Decodes a self-contained OBJ document into a Scene3D. Companion
MTL files referenced by mtllib directives are not auto-resolved
(the decoder has no file-system context); the material names land
in Primitive::extras["obj:usemtl"] and the library file names
land in Scene3D::extras["obj:mtllibs"] so the caller can fetch
them and merge via crate::mtl::merge_materials_into_scene.
Use obj::parse_obj_with_resolver directly when MTL bytes are
already available.
Implementations§
Source§impl ObjDecoder
impl ObjDecoder
Sourcepub fn with_curve_tessellation(self, samples: u32) -> Self
pub fn with_curve_tessellation(self, samples: u32) -> Self
Enable tessellation of cstype free-form curves and surf
surfaces:
cstype bezier/cstype rat bezier— de Casteljau evaluation on the[0, 1]basis domain (1Dcurvcurves and 2Dsurfsurfaces via tensor-product de Casteljau).cstype bspline/cstype rat bspline— Cox-deBoor recursive basis on the knot vector supplied by the most- recentparm u …directive (1Dcurvand 2Dsurfsurfaces via tensor-product Cox-deBoor).cstype cardinal/cstype rat cardinal— cubic Catmull-Rom (1Dcurvand 2Dsurfsurfaces via tensor-product Cardinal evaluation).cstype taylor/cstype bmatrix— 1Dcurvonly.
samples is the number of intervals. A curv curve yields a
LineStrip of samples + 1 vertices; a Bezier surf surface
yields a Topology::Triangles grid of (samples + 1)² vertices
(so samples == 32 produces a 33×33 lattice, smooth enough for
diagnostic display without overwhelming the buffer).
Curve primitives land on a synthetic mesh named "obj:curves";
Bezier surface primitives land on "obj:surfaces". Each carries
extras["obj:tessellated_curve"] == true (surfaces also carry
extras["obj:tessellated_surface"] == true) so downstream
consumers that don’t want the derived geometry can filter it
out. The free-form directive sequence remains preserved in
Scene3D::extras["obj:freeform_directives"] so re-encoding
regenerates the original cstype / deg / curv / surf /
parm / end section.
samples == 0 (the default) disables tessellation, matching
the round 1-6 behaviour. Bezier / B-spline / Cardinal surf
surfaces are tessellated; Taylor / basis-matrix surfaces remain
captured-only.