/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #pragma once #include #include #include #include #include #include namespace EMotionFX { class Actor; class ActorInstance; namespace Integration { /** * Represents an EMotionFX actor asset. * Each asset maintains storage of the original EMotionFX binary asset (via EMotionFXAsset base class). * Initialization of the asset constructs Lumberyard rendering objects, such as the render mesh and material, * directly from the instantiated EMotionFX actor. * An easy future memory optimization is to wipe the EMotionFXAsset buffer after the actor, render meshes, * and materials are created, since it's technically no longer necessary. At this stage it's worth keeping * around for testing. */ class ActorAsset : public EMotionFXAsset { public: friend class ActorAssetHandler; AZ_RTTI(ActorAsset, "{F67CC648-EA51-464C-9F5D-4A9CE41A7F86}", EMotionFXAsset) AZ_CLASS_ALLOCATOR_DECL ActorAsset(AZ::Data::AssetId id = AZ::Data::AssetId()); using MaterialList = AZStd::vector >; using ActorInstancePtr = EMotionFXPtr; ActorInstancePtr CreateInstance(AZ::Entity* entity); Actor* GetActor() const { return m_emfxActor.get(); } RenderActor* GetRenderActor() const { return m_renderActor.get(); } void SetData(AZStd::shared_ptr actor); private: AutoRegisteredActor m_emfxActor; ///< Pointer to shared EMotionFX actor AZStd::unique_ptr m_renderActor; }; /** * Asset handler for loading and initializing actor assets. * The OnInitAsset stage constructs Lumberyard render meshes and materials by extracting * said data from the EMotionFX actor. */ class ActorAssetHandler : public EMotionFXAssetHandler { public: AZ_CLASS_ALLOCATOR_DECL bool OnInitAsset(const AZ::Data::Asset& asset) override; AZ::Data::AssetType GetAssetType() const override; void GetAssetTypeExtensions(AZStd::vector& extensions) override; AZ::Uuid GetComponentTypeId() const override; const char* GetAssetTypeDisplayName() const override; const char* GetBrowserIcon() const override; }; } // namespace Integration } // namespace EMotionFX namespace AZ { AZ_TYPE_INFO_SPECIALIZE(EMotionFX::Integration::EMotionFXPtr, "{3F60D391-F1C8-4A40-9946-A2637D088C48}"); AZ_TYPE_INFO_SPECIALIZE(EMotionFX::Integration::EMotionFXPtr, "{169ACF47-3DEF-482A-AB7D-4CC11934D932}"); AZ_TYPE_INFO_SPECIALIZE(EMotionFX::ActorInstance, "{280A0170-EB6A-4E90-B2F1-E18D8EAEFB36}"); }