Files
cup_edit/thermion_dart/native/include/scene/SceneAsset.hpp
Nick Fisher ed444b0615 feature!:
This is a breaking change needed to fully implement instancing and stencil highlighting.

Previously, users would work directly with entities (on the Dart side, ThermionEntity), e.g.

final entity = await viewer.loadGlb("some.glb");

However, Filament "entities" are a lower-level abstraction.

Loading a glTF file, for example, inserts multiple entities into the scene.

For example, each mesh, light, and camera within a glTF asset will be assigned an entity. A top-level (non-renderable) entity will also be created for the glTF asset, which can be used to transform the entire hierarchy.

"Asset" is a better representation for loading/inserting objects into the scene; think of this as a bundle of entities.

Unless you need to work directly with transforms, instancing, materials and renderables, you can work directly with ThermionAsset.
2024-11-27 15:02:37 +11:00

53 lines
1.4 KiB
C++

#pragma once
#include <memory>
#include <utils/Entity.h>
#include <gltfio/FilamentAsset.h>
#include <filament/Scene.h>
#include "CustomGeometry.hpp"
#include "Log.hpp"
namespace thermion {
using namespace filament;
using namespace utils;
class SceneAsset {
public:
enum SceneAssetType { Gltf, Geometry, Light, Skybox, Ibl, Image, Gizmo };
virtual ~SceneAsset() {
}
virtual SceneAssetType getType() = 0;
virtual utils::Entity getEntity() {
return utils::Entity::import(0);
}
virtual bool isInstance() = 0;
virtual SceneAsset* createInstance(MaterialInstance **materialInstances, size_t materialInstanceCount) = 0;
virtual MaterialInstance **getMaterialInstances() = 0;
virtual size_t getMaterialInstanceCount() = 0;
virtual void addAllEntities(Scene *scene) = 0;
virtual void removeAllEntities(Scene *scene) = 0;
virtual size_t getInstanceCount() = 0;
virtual SceneAsset *getInstanceByEntity(utils::Entity entity) = 0;
virtual SceneAsset *getInstanceAt(size_t index) = 0;
virtual size_t getChildEntityCount() = 0;
virtual const Entity* getChildEntities() = 0;
virtual Entity findEntityByName(const char* name) = 0;
virtual void setPriority(RenderableManager& rm, int mask) = 0;
virtual void setLayer(RenderableManager& rm, int layer) = 0;
};
}