allow adding AnimationComponent/morph target animations to arbitrary entities

This commit is contained in:
Nick Fisher
2024-04-26 10:51:38 +08:00
parent 6fe436a5cc
commit f2efb0d7d1
2 changed files with 616 additions and 471 deletions

View File

@@ -30,10 +30,9 @@ namespace flutter_filament
using namespace filament; using namespace filament;
using namespace filament::gltfio; using namespace filament::gltfio;
using namespace utils; using namespace utils;
using std::vector;
using std::unique_ptr;
using std::string; using std::string;
using std::unique_ptr;
using std::vector;
class SceneManager class SceneManager
{ {
@@ -44,7 +43,6 @@ namespace flutter_filament
const char *uberArchivePath); const char *uberArchivePath);
~SceneManager(); ~SceneManager();
EntityId loadGltf(const char *uri, const char *relativeResourcePath); EntityId loadGltf(const char *uri, const char *relativeResourcePath);
//// ////
@@ -81,14 +79,13 @@ namespace flutter_filament
bool setMorphAnimationBuffer( bool setMorphAnimationBuffer(
EntityId entityId, EntityId entityId,
const char *entityName,
const float *const morphData, const float *const morphData,
const int *const morphIndices, const int *const morphIndices,
int numMorphTargets, int numMorphTargets,
int numFrames, int numFrames,
float frameLengthInMs); float frameLengthInMs);
void setMorphTargetWeights(EntityId entityId, const char *const entityName, const float *const weights, int count); bool setMorphTargetWeights(EntityId entityId, const float *const weights, int count);
/// @brief Set the local transform for the bone at boneIndex/skinIndex in the given entity. /// @brief Set the local transform for the bone at boneIndex/skinIndex in the given entity.
/// @param entityId the parent entity /// @param entityId the parent entity
@@ -135,7 +132,7 @@ namespace flutter_filament
void addCollisionComponent(EntityId entity, void (*onCollisionCallback)(const EntityId entityId1, const EntityId entityId2), bool affectsCollidingTransform); void addCollisionComponent(EntityId entity, void (*onCollisionCallback)(const EntityId entityId1, const EntityId entityId2), bool affectsCollidingTransform);
void removeCollisionComponent(EntityId entityId); void removeCollisionComponent(EntityId entityId);
void setParent(EntityId child, EntityId parent); void setParent(EntityId child, EntityId parent);
void addAnimationComponent(EntityId entity); bool addAnimationComponent(EntityId entity);
/// @brief returns the number of instances of the FilamentAsset represented by the given entity. /// @brief returns the number of instances of the FilamentAsset represented by the given entity.
/// @param entityId /// @param entityId
@@ -151,17 +148,14 @@ namespace flutter_filament
/// ///
void setPriority(EntityId entity, int priority); void setPriority(EntityId entity, int priority);
/// @brief returns the gizmo entity, used to manipulate the global transform for entities /// @brief returns the gizmo entity, used to manipulate the global transform for entities
/// @param out a pointer to an array of three EntityId {x, y, z} /// @param out a pointer to an array of three EntityId {x, y, z}
/// @return /// @return
/// ///
void getGizmo(EntityId *out); void getGizmo(EntityId *out);
friend class FilamentViewer; friend class FilamentViewer;
private: private:
gltfio::AssetLoader *_assetLoader = nullptr; gltfio::AssetLoader *_assetLoader = nullptr;
const ResourceLoaderWrapper *const _resourceLoaderWrapper; const ResourceLoaderWrapper *const _resourceLoaderWrapper;
@@ -178,7 +172,8 @@ namespace flutter_filament
tsl::robin_map< tsl::robin_map<
EntityId, EntityId,
gltfio::FilamentInstance*> _instances; gltfio::FilamentInstance *>
_instances;
tsl::robin_map<EntityId, gltfio::FilamentAsset *> _assets; tsl::robin_map<EntityId, gltfio::FilamentAsset *> _assets;
tsl::robin_map<EntityId, std::tuple<math::float3, bool, math::quatf, bool, float>> _transformUpdates; tsl::robin_map<EntityId, std::tuple<math::float3, bool, math::quatf, bool, float>> _transformUpdates;
@@ -196,6 +191,5 @@ namespace flutter_filament
utils::Entity _gizmoX; utils::Entity _gizmoX;
utils::Entity _gizmoY; utils::Entity _gizmoY;
utils::Entity _gizmoZ; utils::Entity _gizmoZ;
}; };
} }

File diff suppressed because it is too large Load Diff