This repository was archived by the owner on Oct 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 548
Expand file tree
/
Copy pathMotionAsset.cpp
More file actions
81 lines (67 loc) · 3.03 KB
/
MotionAsset.cpp
File metadata and controls
81 lines (67 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* 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.
*
*/
#include "EMotionFX_precompiled.h"
#include <Integration/Assets/MotionAsset.h>
namespace EMotionFX
{
namespace Integration
{
AZ_CLASS_ALLOCATOR_IMPL(MotionAsset, EMotionFXAllocator, 0);
AZ_CLASS_ALLOCATOR_IMPL(MotionAssetHandler, EMotionFXAllocator, 0);
//////////////////////////////////////////////////////////////////////////
MotionAsset::MotionAsset()
{
}
//////////////////////////////////////////////////////////////////////////
void MotionAsset::SetData(EMotionFX::SkeletalMotion* motion)
{
m_emfxMotion.reset(motion);
m_status = static_cast<int>(AZ::Data::AssetData::AssetStatus::Ready);
}
//////////////////////////////////////////////////////////////////////////
bool MotionAssetHandler::OnInitAsset(const AZ::Data::Asset<AZ::Data::AssetData>& asset)
{
MotionAsset* assetData = asset.GetAs<MotionAsset>();
assetData->m_emfxMotion = EMotionFXPtr<EMotionFX::SkeletalMotion>::MakeFromNew(EMotionFX::GetImporter().LoadSkeletalMotion(
assetData->m_emfxNativeData.data(),
assetData->m_emfxNativeData.size(),
nullptr));
if (assetData->m_emfxMotion)
{
assetData->m_emfxMotion->SetIsOwnedByRuntime(true);
}
assetData->ReleaseEmotionFXData();
AZ_Error("EMotionFX", assetData->m_emfxMotion, "Failed to initialize motion asset %s", asset.GetHint().c_str());
return (assetData->m_emfxMotion);
}
//////////////////////////////////////////////////////////////////////////
AZ::Data::AssetType MotionAssetHandler::GetAssetType() const
{
return azrtti_typeid<MotionAsset>();
}
//////////////////////////////////////////////////////////////////////////
void MotionAssetHandler::GetAssetTypeExtensions(AZStd::vector<AZStd::string>& extensions)
{
extensions.push_back("motion");
}
//////////////////////////////////////////////////////////////////////////
const char* MotionAssetHandler::GetAssetTypeDisplayName() const
{
return "EMotion FX Motion";
}
//////////////////////////////////////////////////////////////////////////
const char* MotionAssetHandler::GetBrowserIcon() const
{
return "Editor/Images/AssetBrowser/Motion_16.svg";
}
} // namespace Integration
} // namespace EMotionFX