gltfio: allow zero-instance assets.

This is a feature request from Google. It allows users to "preload" an
asset, ie you can now create all VertexBuffer objects, Texture objects,
etc, without actually creating any entities or renderable components.

In the past we used TransformManager to help out with computing the big
asset-level bounding box, but now we use `gltf_node_transform_world()`
because entities might not yet exist.

One minor side effect is that `FilamentAsset::getBoundingBox()` now
returns the AABB that was determined at load time, and does not account
for instances. As a result, our `gltf_instances` sample app looks
slightly different but this is expected.
This commit is contained in:
Philip Rideout
2022-09-14 16:40:47 -07:00
parent ad6a5eb4e1
commit c4abe4f46a
9 changed files with 88 additions and 32 deletions
+3 -1
View File
@@ -457,7 +457,9 @@ void ViewerGui::updateRootTransform() {
auto root = tcm.getInstance(mAsset->getRoot());
filament::math::mat4f transform;
if (mSettings.viewer.autoScaleEnabled) {
transform = fitIntoUnitCube(mAsset->getInstance()->getBoundingBox(), 4);
FilamentInstance* instance = mAsset->getInstance();
Aabb aabb = instance ? instance->getBoundingBox() : mAsset->getBoundingBox();
transform = fitIntoUnitCube(aabb, 4);
}
tcm.setTransform(root, transform);
}