// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. #pragma once #include "../BinaryAsset.h" #include "Engine/Animations/Graph/AnimGraph.h" /// /// The Animation Graph is used to evaluate a final pose for the animated model for the current frame. /// API_CLASS(NoSpawn) class FLAXENGINE_API AnimationGraph : public BinaryAsset { DECLARE_BINARY_ASSET_HEADER(AnimationGraph, 1); public: /// /// The animation graph. /// AnimGraph Graph; /// /// The animation graph runtime executor. /// AnimGraphExecutor GraphExecutor; public: /// /// Gets the base model asset used for the animation preview and the skeleton layout source. /// API_PROPERTY() SkinnedModel* GetBaseModel() const { return Graph.BaseModel.Get(); } /// /// Initializes virtual Anim Graph to play a single animation. /// /// The base model asset. /// The animation to play. /// True if play animation in a loop. /// True if apply root motion. Otherwise it will be ignored. /// True if failed, otherwise false. API_FUNCTION() bool InitAsAnimation(SkinnedModel* baseModel, Animation* anim, bool loop = true, bool rootMotion = false); /// /// Tries to load surface graph from the asset. /// /// The surface data or empty if failed to load it. API_FUNCTION() BytesContainer LoadSurface(); #if USE_EDITOR /// /// Updates the animation graph surface (save new one, discard cached data, reload asset). /// /// Stream with graph data. /// True if cannot save it, otherwise false. API_FUNCTION() bool SaveSurface(BytesContainer& data); private: void FindDependencies(AnimGraphBase* graph); #endif public: // [BinaryAsset] #if USE_EDITOR void GetReferences(Array& output) const override; #endif protected: // [BinaryAsset] LoadResult load() override; void unload(bool isReloading) override; AssetChunksFlag getChunksToPreload() const override; #if USE_EDITOR void OnDependencyModified(BinaryAsset* asset) override; #endif };