Repository navigation
cvc::model keeps the file's node tree; merged() places each mesh by it - #1467
Merged
Merged
Conversation
model_of_scene never read assimp's root node, and the import flags do not bake transforms into vertices, so a glTF, FBX or DAE file that positions its meshes through node transforms drew every mesh at its own origin, and a mesh several nodes share appeared once. Every reader through merged() saw it. - model::nodes (name, row-major 4x4 transform, meshes, children; nodes[0] the root), model::instances() (every drawn copy with its transform, depth first on an explicit stack; cycles and bad indices skipped), and model::placed() (points moved, normals by the inverse transpose, tangents turned, triangles and quads rewound under a mirror). A model without nodes draws each mesh once, as before. - merged(), extents() and lod::partition_model draw instances. - The assimp import reads the tree and keeps the file in its own axes and units (Collada and FBX up direction, Collada unit size ignored); the export writes the tree, so a model round-trips through .glb. - pycvc_model.i ignores the new members for now. - docs/APP_API.md describes the tree. Shipped models: buildings.glb has no node transforms and reads as before. Humvee.glb's nodes turn its raw Z-up mesh to glTF's Y-up; the C++ vehicle fit gives identical output, and pycvc's VehicleModel and the nav demos, which drew it mirrored, now draw it the right way round.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cvc::modelkeeps a file's scene graph, andmerged()places each mesh by its nodes. Until nowmodel_of_scenenever read assimp'smRootNode, and the import flags don't bake transforms into vertices. So a glTF, FBX or DAE file that positions its meshes through node transforms drew every mesh at its own origin, and a mesh several nodes share appeared once. Every reader that goes throughmerged()saw that:read_geometry, a scene node'ssource: { file }, vehicle and boxed model looks, swarms,data:entries,lod::partition_model, the nav demos and pycvc'sload_model.What changes
model::nodes: each node's name, its transform relative to its parent (row-major 4x4), the meshes it draws and its children;nodes[0]is the root. A model without nodes (one built in code) draws each mesh once, as before.model::instances(): every drawn copy of a mesh with its transform into the model's space, depth first. A node two parents list is drawn under each. A cycle or an index out of range is skipped. The walk keeps its own stack, so a deep tree can't overflow the thread's.model::placed(geometry, transform): points moved; normals by the inverse transpose and made unit; tangents turned. Under a mirror (negative determinant), triangles and quads are rewound and tangent handedness flipped, so faces keep facing out.merged()andextents()draw instances.lod::partition_modelpartitions the placed copies.IMPORT_COLLADA_IGNORE_UP_DIRECTION,IMPORT_COLLADA_IGNORE_UNIT_SIZEandIMPORT_FBX_IGNORE_UP_DIRECTION, so assimp's turn of a Z-up file to Y-up (and Collada's scale to metres) doesn't arrive through the root node now that it is applied. Readers already turn models themselves; a glTF file is +Y up..glb.%ignored inpycvc_model.i;merged()already places by them. Exposing the tree to Python is left for later.docs/APP_API.mddescribes the tree under the file handlers.Effect on shipped models
buildings.glb(scene bundles; trimesh output, 11,273 nodes): no node carries a transform, so it reads exactly as before.Humvee.glb(vehicle-humvee): a Sketchfab export whose nodes compose to a proper rotation turning the raw Z-up mesh into glTF's Y-up. I ran both vehicle fits on its vertices, raw and placed:fit_vehicle_geometry(vehicle looks) gives identical output, because it finds its axes from the mesh's shape.VehicleModeland the nav demos'load_vehicle_templateuse the same shape fit without a mirror correction. On the raw mesh's axis order they draw the Humvee mirrored (triangles inside out); placed by its nodes, it comes out correct.fit_into_boxtakes a.glbas +Y up, which the Humvee now is.Tests
New
ModelNodescases inmodel_test:With assimp:
read_model_from_memoryandread_geometry;.glbwrite and read;Verified locally
Windows, MSVC 14.44, assimp 6.0, no cvcGL or pycvc: the full ctest suite, 8,198 tests, all pass (on f310173). That includes
model_test(24, the 12 newModelNodescases among them), the LOD tile tests and the world bundle tests, which write and read.glbfiles.Not verified locally: the cvcGL readers (vehicle looks, swarms, scene sources), pycvc, Linux, macOS and wasm.
Not done
source: { file }expanding a model into child scene nodes, addressable by name and drawn with per-mesh materials. That adds.arikeys, so it waits for Ariadne: a closed .ari schema every load checks, and ari validate #1464's schema.metres_per_source_unitstamped from the file's units.