Reads a 3MF package into the crate's Scene: mesh objects, component
objects and build items with their transforms (as a node hierarchy; an
object placed several times is one mesh), the unit, base materials,
colour groups, texture coordinate groups and their textures.
The package is opened with craft-opc (3MF is an OPC package) and the model
part is read with craft-xml's pull reader, so a large part never becomes a
tree. read_model_part reads a model part on its own.
Ported from storytold/deckcraft#743 (crates/mesh/src/threemf.rs). What
that reader did for DeckCraft and stays there: baking placements into
world-space triangles, the turn to Y-up, scaling to metres, and decoding
the textures. Here placements stay nodes, positions stay in the file's
unit and axes (Model::unit says which), and a texture is its bytes.
Co-authored-by: uvxszi <uvxszi@gmail.com>
* craft-mesh: FBX 7.x reader from EffectCraft (`fbx`)
EffectCraft's FBX reader (crates/model/src/fbx.rs: binary with 32- and 64-bit
record offsets and zlib arrays, ASCII, geometry layer elements, the Model
transform chain, Lambert/Phong materials, textures) onto the crate's Scene.
The reader was written by vangel76 (EffectCraft #736); its memory budget and
shared instanced meshes by DWAA1660 (EffectCraft #1234).
It includes the fixes of the open EffectCraft PR #2955: a binary child record
must end within its parent, a failed array inflate reports only its status,
textures that end at one image share it and its bytes are charged to the
budget, and material slots and connections are found through maps.
What differs from the app's copy, because the model here is neutral:
polygons stay whole and layer elements stay indexed pools (no vertex
unification, no computed normals or tangents); images are bytes, not decoded
pixels; the axis system is not applied (Document::axes_to_y_up gives it);
the memory budget is Limits::max_data_bytes; a file without meshes is a
scene, not an error. base64_decode moves from the gltf module to the crate
root so both formats share it (gltf re-exports it).
* craft-mesh: read FBX 6.x
FBX 6.1 files differ from 7.x in how the scene is laid out, not in the
record syntax: a Model holds its own Vertices and layer elements, properties
are Properties60/Property (no label field), Connect lines name objects by
Class::Name instead of by id, and GlobalSettings sits among the objects.
The reader now takes all four, and NormalIndex beside NormalsIndex, so 6.x
geometry, transforms, the hierarchy and materials are read. 6.x textures
(connected to Models) are not.
Ported from storytold/deckcraft#1380 (crates/mesh/src/fbx), whose reader
took 6.1 to 7.7; its mesh building, axis turn and rasteriser stay in
DeckCraft.
* craft-mesh: glTF sparse accessors, specular-glossiness and WebP textures; PLY per-corner texture coordinates and TextureFile
glTF:
- Sparse accessors are read instead of refused: the values replace the
elements the indices name, over the buffer view's values or over zeros.
An index past the accessor, more entries than elements, or a read past a
view is Malformed.
- KHR_materials_pbrSpecularGlossiness becomes the nearest
metallic-roughness material: diffuse factor and texture, no metal,
roughness 1 - glossiness.
- A texture whose image is only in EXT_texture_webp uses it; one with a
fallback source keeps the fallback.
Both extensions may now be required without a warning.
PLY:
- A face's `texcoord` list (u v per corner, as MeshLab writes wedge
coordinates) becomes the UV set, indexed per corner, instead of the
vertices' own s/t.
- `comment TextureFile <name>` gives the mesh a material whose base colour
texture is that file, named and listed in Scene::external, never opened.
Ported from storytold/deckcraft#743 (crates/mesh/src/gltf.rs, ply.rs).
---------
Co-authored-by: Ethan Dale <ethandale@Ethans-MacBook-Pro.local>
Co-authored-by: uvxszi <uvxszi@gmail.com>
* craft-mesh: FBX 7.x reader from EffectCraft (`fbx`)
EffectCraft's FBX reader (crates/model/src/fbx.rs: binary with 32- and 64-bit
record offsets and zlib arrays, ASCII, geometry layer elements, the Model
transform chain, Lambert/Phong materials, textures) onto the crate's Scene.
The reader was written by vangel76 (EffectCraft #736); its memory budget and
shared instanced meshes by DWAA1660 (EffectCraft #1234).
It includes the fixes of the open EffectCraft PR #2955: a binary child record
must end within its parent, a failed array inflate reports only its status,
textures that end at one image share it and its bytes are charged to the
budget, and material slots and connections are found through maps.
What differs from the app's copy, because the model here is neutral:
polygons stay whole and layer elements stay indexed pools (no vertex
unification, no computed normals or tangents); images are bytes, not decoded
pixels; the axis system is not applied (Document::axes_to_y_up gives it);
the memory budget is Limits::max_data_bytes; a file without meshes is a
scene, not an error. base64_decode moves from the gltf module to the crate
root so both formats share it (gltf re-exports it).
* craft-mesh: read FBX 6.x
FBX 6.1 files differ from 7.x in how the scene is laid out, not in the
record syntax: a Model holds its own Vertices and layer elements, properties
are Properties60/Property (no label field), Connect lines name objects by
Class::Name instead of by id, and GlobalSettings sits among the objects.
The reader now takes all four, and NormalIndex beside NormalsIndex, so 6.x
geometry, transforms, the hierarchy and materials are read. 6.x textures
(connected to Models) are not.
Ported from storytold/deckcraft#1380 (crates/mesh/src/fbx), whose reader
took 6.1 to 7.7; its mesh building, axis turn and rasteriser stay in
DeckCraft.
---------
Co-authored-by: Ethan Dale <ethandale@Ethans-MacBook-Pro.local>
* craft-mesh OBJ: map_* options are passed over by their argument counts
A map line with options named its image by its final token, so
'map_Kd -o 0.5 0.5 my checker.png' named 'checker.png'. Options are now
skipped by the arguments they take (-o, -s and -t take one to three
numbers), so a name with spaces after options is one name. After an option
the reader does not know, the name is still the final token.
Ported from storytold/effectcraft#1324.
* craft-mesh OBJ: a material library named again is read once
Exporters repeat the mtllib line for every object. Each repeat asked the
resolver again, read the library again, added its materials and images a
second time, and counted its bytes against max_data_bytes once per line, so
a legitimate file with many objects could reach the limit.
Ported from storytold/effectcraft#2965 (its OBJ part: 'a library already
loaded is skipped').
---------
Co-authored-by: Lloyd Nicholson <nichlloyd@gmail.com>
* Add craft-mesh: neutral mesh model with STL, OBJ/MTL and PLY
* craft-mesh: glTF 2.0 and GLB
* craft-mesh: README, crate list entry, a test for the UV set bound