{LYN-2074} Add Animation data types Behavior for the scene graph (#253)
{LYN-2074} Add Animation data types Behavior for the scene graph (#253)
* https://jira.agscollab.com/browse/LYN-2074
* moved scene API color to centeralized location
BlendShapeDataFace
BlendShapeData
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
|
||||
#include <SceneAPI/SceneData/GraphData/AnimationData.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -18,6 +20,31 @@ namespace AZ
|
||||
{
|
||||
namespace GraphData
|
||||
{
|
||||
void AnimationData::Reflect(ReflectContext* context)
|
||||
{
|
||||
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
|
||||
if (serializeContext)
|
||||
{
|
||||
serializeContext->Class<AnimationData, SceneAPI::DataTypes::IAnimationData>()
|
||||
->Version(1);
|
||||
}
|
||||
|
||||
BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context);
|
||||
if (behaviorContext)
|
||||
{
|
||||
behaviorContext->Class<SceneAPI::DataTypes::IAnimationData>()
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "scene")
|
||||
->Method("GetKeyFrameCount", &SceneAPI::DataTypes::IAnimationData::GetKeyFrameCount)
|
||||
->Method("GetKeyFrame", &SceneAPI::DataTypes::IAnimationData::GetKeyFrame)
|
||||
->Method("GetTimeStepBetweenFrames", &SceneAPI::DataTypes::IAnimationData::GetTimeStepBetweenFrames);
|
||||
|
||||
behaviorContext->Class<AnimationData>()
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "scene");
|
||||
}
|
||||
}
|
||||
|
||||
AnimationData::AnimationData()
|
||||
: m_timeStepBetweenFrames(1.0/30.0) // default value
|
||||
{
|
||||
@@ -61,6 +88,32 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
void BlendShapeAnimationData::Reflect(ReflectContext* context)
|
||||
{
|
||||
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
|
||||
if (serializeContext)
|
||||
{
|
||||
serializeContext->Class<BlendShapeAnimationData, SceneAPI::DataTypes::IBlendShapeAnimationData>()
|
||||
->Version(1);
|
||||
}
|
||||
|
||||
BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context);
|
||||
if (behaviorContext)
|
||||
{
|
||||
behaviorContext->Class<SceneAPI::DataTypes::IBlendShapeAnimationData>()
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "scene")
|
||||
->Method("GetBlendShapeName", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetBlendShapeName)
|
||||
->Method("GetKeyFrameCount", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetKeyFrameCount)
|
||||
->Method("GetKeyFrame", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetKeyFrame)
|
||||
->Method("GetTimeStepBetweenFrames", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetTimeStepBetweenFrames);
|
||||
|
||||
behaviorContext->Class<BlendShapeAnimationData>()
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "scene");
|
||||
}
|
||||
}
|
||||
|
||||
BlendShapeAnimationData::BlendShapeAnimationData()
|
||||
: m_timeStepBetweenFrames(1 / 30.0) // default value
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace AZ
|
||||
public:
|
||||
AZ_RTTI(AnimationData, "{D350732E-4727-41C8-95E0-FBAF5F2AC074}", SceneAPI::DataTypes::IAnimationData);
|
||||
|
||||
static void Reflect(ReflectContext* context);
|
||||
|
||||
SCENE_DATA_API AnimationData();
|
||||
SCENE_DATA_API ~AnimationData() override = default;
|
||||
SCENE_DATA_API virtual void AddKeyFrame(const SceneAPI::DataTypes::MatrixType& keyFrameTransform);
|
||||
@@ -53,6 +55,8 @@ namespace AZ
|
||||
public:
|
||||
AZ_RTTI(BlendShapeAnimationData, "{02766CCF-BDA7-46B6-9BB1-58A90C1AD6AA}", SceneAPI::DataTypes::IBlendShapeAnimationData);
|
||||
|
||||
static void Reflect(ReflectContext* context);
|
||||
|
||||
SCENE_DATA_API BlendShapeAnimationData();
|
||||
SCENE_DATA_API ~BlendShapeAnimationData() override = default;
|
||||
SCENE_DATA_API void CloneAttributesFrom(const IGraphObject* sourceObject) override;
|
||||
|
||||
@@ -12,9 +12,13 @@
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <SceneAPI/SceneData/GraphData/BlendShapeData.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
AZ_TYPE_INFO_SPECIALIZE(SceneAPI::DataTypes::IBlendShapeData::Face, "{C972EC9A-3A5C-47CD-9A92-ECB4C0C0451C}");
|
||||
|
||||
namespace SceneData
|
||||
{
|
||||
namespace GraphData
|
||||
@@ -23,6 +27,82 @@ namespace AZ
|
||||
|
||||
BlendShapeData::~BlendShapeData() = default;
|
||||
|
||||
void BlendShapeData::Reflect(ReflectContext* context)
|
||||
{
|
||||
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
|
||||
if (serializeContext)
|
||||
{
|
||||
serializeContext->Class<BlendShapeData, SceneAPI::DataTypes::IBlendShapeData>()
|
||||
->Version(1);
|
||||
}
|
||||
|
||||
BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context);
|
||||
if (behaviorContext)
|
||||
{
|
||||
behaviorContext->Class<SceneAPI::DataTypes::IBlendShapeData>()
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "scene")
|
||||
->Method("GetUsedControlPointCount", &SceneAPI::DataTypes::IBlendShapeData::GetUsedControlPointCount)
|
||||
->Method("GetControlPointIndex", &SceneAPI::DataTypes::IBlendShapeData::GetControlPointIndex)
|
||||
->Method("GetUsedPointIndexForControlPoint", &SceneAPI::DataTypes::IBlendShapeData::GetUsedPointIndexForControlPoint)
|
||||
->Method("GetVertexCount", &SceneAPI::DataTypes::IBlendShapeData::GetVertexCount)
|
||||
->Method("GetFaceCount", &SceneAPI::DataTypes::IBlendShapeData::GetFaceCount)
|
||||
->Method("GetFaceInfo", &SceneAPI::DataTypes::IBlendShapeData::GetFaceInfo)
|
||||
->Method("GetPosition", &SceneAPI::DataTypes::IBlendShapeData::GetPosition)
|
||||
->Method("GetNormal", &SceneAPI::DataTypes::IBlendShapeData::GetNormal)
|
||||
->Method("GetFaceVertexIndex", &SceneAPI::DataTypes::IBlendShapeData::GetFaceVertexIndex);
|
||||
|
||||
behaviorContext->Class<SceneAPI::DataTypes::IBlendShapeData::Face>("BlendShapeDataFace")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "scene")
|
||||
->Method("GetVertexIndex", [](const SceneAPI::DataTypes::IBlendShapeData::Face& self, int index)
|
||||
{
|
||||
if (index >= 0 && index < 3)
|
||||
{
|
||||
return self.vertexIndex[index];
|
||||
}
|
||||
return aznumeric_cast<unsigned int>(0);
|
||||
});
|
||||
|
||||
behaviorContext->Class<BlendShapeData>()
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "scene")
|
||||
->Method("GetUV", &BlendShapeData::GetUV)
|
||||
->Method("GetTangent", [](const BlendShapeData& self, size_t index)
|
||||
{
|
||||
if (index < self.GetTangents().size())
|
||||
{
|
||||
return self.GetTangents().at(index);
|
||||
}
|
||||
AZ_Error("SceneGraphData", false, "Cannot get to tangent at index(%zu)", index);
|
||||
return Vector4::CreateZero();
|
||||
})
|
||||
->Method("GetBitangent", [](const BlendShapeData& self, size_t index)
|
||||
{
|
||||
if (index < self.GetBitangents().size())
|
||||
{
|
||||
return self.GetBitangents().at(index);
|
||||
}
|
||||
AZ_Error("SceneGraphData", false, "Cannot get to bitangents at index(%zu)", index);
|
||||
return Vector3::CreateZero();
|
||||
})
|
||||
->Method("GetColor", [](const BlendShapeData& self, AZ::u8 colorSetIndex, AZ::u8 colorIndex)
|
||||
{
|
||||
SceneAPI::DataTypes::Color color(0,0,0,0);
|
||||
if (colorSetIndex < MaxNumColorSets)
|
||||
{
|
||||
const AZStd::vector<SceneAPI::DataTypes::Color>& colorChannel = self.GetColors(colorSetIndex);
|
||||
if (colorIndex < colorChannel.size())
|
||||
{
|
||||
return colorChannel[colorIndex];
|
||||
}
|
||||
}
|
||||
AZ_Error("SceneGraphData", false, "Cannot get to color setIndex(%d) at colorIndex(%d)", colorSetIndex, colorIndex);
|
||||
return color;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void BlendShapeData::AddPosition(const Vector3& position)
|
||||
{
|
||||
m_positions.push_back(position);
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace AZ
|
||||
public:
|
||||
AZ_RTTI(BlendShapeData, "{FF875C22-2E4F-4CE3-BA49-09BF78C70A09}", SceneAPI::DataTypes::IBlendShapeData)
|
||||
|
||||
SCENE_DATA_API static void Reflect(ReflectContext* context);
|
||||
|
||||
// Maximum number of color sets matches limitation set in assImp (AI_MAX_NUMBER_OF_COLOR_SETS)
|
||||
static constexpr AZ::u8 MaxNumColorSets = 8;
|
||||
// Maximum number of uv sets matches limitation set in assImp (AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
AZ_TYPE_INFO_SPECIALIZE(SceneAPI::DataTypes::Color, "{937E3BF8-5204-4D40-A8DA-C8F083C89F9F}");
|
||||
|
||||
namespace SceneData
|
||||
{
|
||||
namespace GraphData
|
||||
@@ -40,7 +38,7 @@ namespace AZ
|
||||
->Method("GetCount", &MeshVertexColorData::GetCount )
|
||||
->Method("GetColor", &MeshVertexColorData::GetColor);
|
||||
|
||||
behaviorContext->Class<AZ::SceneAPI::DataTypes::Color>("MeshVertexColor")
|
||||
behaviorContext->Class<AZ::SceneAPI::DataTypes::Color>("VertexColor")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "scene")
|
||||
->Property("red", BehaviorValueGetter(&AZ::SceneAPI::DataTypes::Color::red), nullptr)
|
||||
|
||||
Reference in New Issue
Block a user