Integrating latest 47acbe8

This commit is contained in:
alexpete
2021-03-25 13:57:57 -07:00
parent 448c549698
commit 75dc720198
10312 changed files with 2711566 additions and 671451 deletions
@@ -0,0 +1,158 @@
/*
* 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 <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <SceneAPI/SceneCore/Containers/RuleContainer.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
#include <SceneAPI/SceneData/Rules/CoordinateSystemRule.h>
namespace AZ::SceneAPI::SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(CoordinateSystemRule, AZ::SystemAllocator, 0)
CoordinateSystemRule::CoordinateSystemRule()
: m_targetCoordinateSystem(ZUpPositiveYForward)
{
}
void CoordinateSystemRule::UpdateCoordinateSystemConverter()
{
switch (m_targetCoordinateSystem)
{
case ZUpPositiveYForward:
{
// Source coordinate system, use identity for now, which will currently just assume LY's coordinate system.
const AZ::Vector3 sourceBasisVectors[3] = { AZ::Vector3( 1.0f, 0.0f, 0.0f),
AZ::Vector3( 0.0f, 1.0f, 0.0f),
AZ::Vector3( 0.0f, 0.0f, 1.0f) };
// The target coordinate system, with X and Y inverted (rotate 180 degrees over Z)
const AZ::Vector3 targetBasisVectors[3] = { AZ::Vector3(-1.0f, 0.0f, 0.0f),
AZ::Vector3( 0.0f,-1.0f, 0.0f),
AZ::Vector3( 0.0f, 0.0f, 1.0f) };
// X, Y and Z are all at the same indices inside the target coordinate system, compared to the source coordinate system.
const AZ::u32 targetBasisIndices[3] = { 0, 1, 2 };
m_coordinateSystemConverter = CoordinateSystemConverter::CreateFromBasisVectors(sourceBasisVectors, targetBasisVectors, targetBasisIndices);
}
break;
case ZUpNegativeYForward:
{
// Source coordinate system, use identity for now, which will currently just assume LY's coordinate system.
const AZ::Vector3 sourceBasisVectors[3] = { AZ::Vector3( 1.0f, 0.0f, 0.0f),
AZ::Vector3( 0.0f, 1.0f, 0.0f),
AZ::Vector3( 0.0f, 0.0f, 1.0f) };
// The target coordinate system, which is the same as the source, so basically we won't do anything here.
const AZ::Vector3 targetBasisVectors[3] = { AZ::Vector3( 1.0f, 0.0f, 0.0f),
AZ::Vector3( 0.0f, 1.0f, 0.0f),
AZ::Vector3( 0.0f, 0.0f, 1.0f) };
// X, Y and Z are all at the same indices inside the target coordinate system, compared to the source coordinate system.
const AZ::u32 targetBasisIndices[3] = { 0, 1, 2 };
m_coordinateSystemConverter = CoordinateSystemConverter::CreateFromBasisVectors(sourceBasisVectors, targetBasisVectors, targetBasisIndices);
}
break;
default:
AZ_Assert(false, "Unsupported coordinate system conversion");
};
}
void CoordinateSystemRule::SetTargetCoordinateSystem(CoordinateSystem targetCoordinateSystem)
{
m_targetCoordinateSystem = targetCoordinateSystem;
UpdateCoordinateSystemConverter();
}
CoordinateSystemRule::CoordinateSystem CoordinateSystemRule::GetTargetCoordinateSystem() const
{
return m_targetCoordinateSystem;
}
void CoordinateSystemRule::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<CoordinateSystemRule, IRule>()->Version(1)
->Field("targetCoordinateSystem", &CoordinateSystemRule::m_targetCoordinateSystem);
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<CoordinateSystemRule>("Coordinate system change", "Modify the target coordinate system, applying a transformation to all data (transforms and vertex data if it exists).")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(AZ::Edit::UIHandlers::ComboBox, &CoordinateSystemRule::m_targetCoordinateSystem, "Facing direction", "Change the direction the actor/motion will face by applying a post transformation to the data.")
->EnumAttribute(CoordinateSystem::ZUpNegativeYForward, "Do nothing")
->EnumAttribute(CoordinateSystem::ZUpPositiveYForward, "Rotate 180 degrees around the up axis");
}
}
bool CoordinateSystemRule::ConvertLegacyCoordinateSystemRule(AZ::SerializeContext& serializeContext,
AZ::SerializeContext::DataElementNode& classElement)
{
AZ::SerializeContext::DataElementNode* ruleContainerNode = classElement.FindSubElement(AZ_CRC("rules", 0x899a993c));
if (!ruleContainerNode)
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Can't find rule container.\n");
return false;
}
AZ::SerializeContext::DataElementNode* rulesNode = ruleContainerNode->FindSubElement(AZ_CRC("rules", 0x899a993c));
if (!rulesNode)
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Can't find rules within rule container.\n");
return false;
}
const AZ::Uuid oldCoordSysRuleId("{603207E2-4F55-4C33-9AAB-98CA75C1E351}");
const int numRules = rulesNode->GetNumSubElements();
for (int i = 0; i < numRules; ++i)
{
AZ::SerializeContext::DataElementNode& sharedPointerNode = rulesNode->GetSubElement(i);
if (sharedPointerNode.GetNumSubElements() == 1)
{
AZ::SerializeContext::DataElementNode& currentRuleNode = sharedPointerNode.GetSubElement(0);
// Convert the coordinate system rule
if (currentRuleNode.GetId() == oldCoordSysRuleId)
{
int targetCoordinateSystem = 0;
currentRuleNode.FindSubElementAndGetData(AZ_CRC("targetCoordinateSystem"), targetCoordinateSystem);
AZStd::shared_ptr<CoordinateSystemRule> coordSysRule = AZStd::make_shared<CoordinateSystemRule>();
coordSysRule->SetTargetCoordinateSystem(static_cast<AZ::SceneAPI::DataTypes::ICoordinateSystemRule::CoordinateSystem>(targetCoordinateSystem));
rulesNode->RemoveElement(i);
rulesNode->AddElementWithData<AZStd::shared_ptr<AZ::SceneAPI::DataTypes::IRule>>(serializeContext, "element", coordSysRule);
return true;
}
}
}
return true;
}
} // namespace AZ::SceneAPI::SceneData
@@ -0,0 +1,50 @@
/*
* 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 <SceneAPI/SceneCore/DataTypes/Rules/ICoordinateSystemRule.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
namespace AZ
{
class ReflectContext;
}
namespace AZ::SceneAPI::SceneData
{
class SCENE_DATA_CLASS CoordinateSystemRule
: public DataTypes::ICoordinateSystemRule
{
public:
AZ_RTTI(CoordinateSystemRule, "{53ECEEEA-C489-46DF-9FDB-05251AD960F4}", AZ::SceneAPI::DataTypes::ICoordinateSystemRule);
AZ_CLASS_ALLOCATOR_DECL
SCENE_DATA_API CoordinateSystemRule();
SCENE_DATA_API ~CoordinateSystemRule() override = default;
SCENE_DATA_API void UpdateCoordinateSystemConverter() override;
SCENE_DATA_API void SetTargetCoordinateSystem(CoordinateSystem targetCoordinateSystem) override;
SCENE_DATA_API CoordinateSystem GetTargetCoordinateSystem() const override;
SCENE_DATA_API const CoordinateSystemConverter& GetCoordinateSystemConverter() const override { return m_coordinateSystemConverter; }
static void Reflect(AZ::ReflectContext* context);
SCENE_DATA_API static bool ConvertLegacyCoordinateSystemRule(AZ::SerializeContext& serializeContext,
AZ::SerializeContext::DataElementNode& classElement);
protected:
CoordinateSystemConverter m_coordinateSystemConverter;
CoordinateSystem m_targetCoordinateSystem;
};
} // namespace AZ::SceneAPI::SceneData
@@ -1,119 +0,0 @@
/*
* 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 <AzCore/RTTI/ReflectContext.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <SceneAPI/SceneData/Rules/OriginRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
const AZStd::string OriginRule::c_defaultWorldUIString = "World";
AZ_CLASS_ALLOCATOR_IMPL(OriginRule, SystemAllocator, 0)
OriginRule::OriginRule()
: m_rotation(Quaternion::CreateIdentity())
, m_translation(Vector3::CreateZero())
, m_scale(1.0f)
{
}
const AZStd::string& OriginRule::GetOriginNodeName() const
{
return m_originNodeName;
}
bool OriginRule::UseRootAsOrigin() const
{
return m_originNodeName == c_defaultWorldUIString;
}
const Quaternion& OriginRule::GetRotation() const
{
return m_rotation;
}
const Vector3& OriginRule::GetTranslation() const
{
return m_translation;
}
float OriginRule::GetScale() const
{
return m_scale;
}
void OriginRule::SetOriginNodeName(const AZStd::string& originNodeName)
{
m_originNodeName = originNodeName;
}
void OriginRule::SetRotation(const Quaternion& rotation)
{
m_rotation = rotation;
}
void OriginRule::SetTranslation(const Vector3& translation)
{
m_translation = translation;
}
void OriginRule::SetScale(float scale)
{
m_scale = scale;
}
void OriginRule::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<OriginRule, DataTypes::IOriginRule>()->Version(1)
->Field("originNodeName", &OriginRule::m_originNodeName)
->Field("translation", &OriginRule::m_translation)
->Field("rotation", &OriginRule::m_rotation)
->Field("scale", &OriginRule::m_scale);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<OriginRule>("Origin", "Configure where the mesh will load relative to world origin.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement("NodeListSelection", &OriginRule::m_originNodeName, "Relative Origin Node",
"Select a Node from the scene as the origin for this export. 'World' will export from the Root Scene Node.")
->Attribute("DisabledOption", c_defaultWorldUIString)
->Attribute("DefaultToDisabled", true)
->Attribute("ExcludeEndPoints", true)
->DataElement(Edit::UIHandlers::Default, &OriginRule::m_translation, "Translation", "Moves the group along the given vector.")
->DataElement(Edit::UIHandlers::Default, &OriginRule::m_rotation, "Rotation", "Rotates the group after translation.")
->Attribute(Edit::Attributes::LabelForX, "P")
->Attribute(Edit::Attributes::LabelForY, "R")
->Attribute(Edit::Attributes::LabelForZ, "Y")
->DataElement(Edit::UIHandlers::Default, &OriginRule::m_scale, "Scale", "Scales the group up or down after translation and rotation.")
->Attribute(Edit::Attributes::Min, 0.0001)
->Attribute(Edit::Attributes::Max, 1000.0);
}
}
} // SceneData
} // SceneAPI
} // AZ
@@ -1,66 +0,0 @@
#pragma once
/*
* 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 <AzCore/Memory/Memory.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/Math/Quaternion.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IOriginRule.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace SceneData
{
class OriginRule
: public DataTypes::IOriginRule
{
public:
AZ_RTTI(OriginRule, "{90AECE4A-58D4-411C-9CDE-59B54C59354E}", DataTypes::IOriginRule);
AZ_CLASS_ALLOCATOR_DECL
OriginRule();
~OriginRule() override = default;
const AZStd::string& GetOriginNodeName() const override;
bool UseRootAsOrigin() const override;
const Quaternion& GetRotation() const override;
const Vector3& GetTranslation() const override;
float GetScale() const override;
void SetOriginNodeName(const AZStd::string& originNodeName);
void SetRotation(const Quaternion& rotation);
void SetTranslation(const Vector3& translation);
void SetScale(float scale);
static void Reflect(ReflectContext* context);
static const AZStd::string c_defaultWorldUIString;
protected:
AZStd::string m_originNodeName;
Quaternion m_rotation;
Vector3 m_translation;
float m_scale;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,76 @@
/*
* 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 <AzCore/RTTI/ReflectContext.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <SceneAPI/SceneData/Rules/SkinRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(SkinRule, AZ::SystemAllocator, 0)
SkinRule::SkinRule()
: m_maxWeightsPerVertex(4)
, m_weightThreshold(0.001f)
{
}
AZ::u32 SkinRule::GetMaxWeightsPerVertex() const
{
return m_maxWeightsPerVertex;
}
float SkinRule::GetWeightThreshold() const
{
return m_weightThreshold;
}
void SkinRule::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<ISkinRule, AZ::SceneAPI::DataTypes::IRule>()->Version(1);
serializeContext->Class<SkinRule, ISkinRule>()->Version(2)
->Field("maxWeightsPerVertex", &SkinRule::m_maxWeightsPerVertex)
->Field("weightThreshold", &SkinRule::m_weightThreshold);
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<SkinRule>("Skin", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(AZ::Edit::UIHandlers::Default, &SkinRule::m_maxWeightsPerVertex, "Max weights per vertex", "The maximum number of joints that can influence a single vertex.")
->Attribute(AZ::Edit::Attributes::Min, 1)
->Attribute(AZ::Edit::Attributes::Max, 32)
->DataElement(AZ::Edit::UIHandlers::Default, &SkinRule::m_weightThreshold, "Weight threshold", "Weight value less than this will be ignored during import.")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 0.01f)
->Attribute(AZ::Edit::Attributes::Step, 0.0001f)
->Attribute(AZ::Edit::Attributes::Decimals, 6)
->Attribute(AZ::Edit::Attributes::DisplayDecimals, 6);
}
}
} // Rule
} // Pipeline
} // EMotionFX
@@ -0,0 +1,47 @@
#pragma once
/*
* 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 <AzCore/Memory/Memory.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/ISkinRule.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace SceneData
{
class SkinRule
: public DataTypes::ISkinRule
{
public:
AZ_RTTI(SkinRule, "{B26E7FC9-86A1-4711-8415-8BE4861C08BA}", ISkinRule);
AZ_CLASS_ALLOCATOR_DECL
SkinRule();
~SkinRule() override = default;
AZ::u32 GetMaxWeightsPerVertex() const override;
float GetWeightThreshold() const override;
static void Reflect(AZ::ReflectContext* context);
protected:
AZ::u32 m_maxWeightsPerVertex;
float m_weightThreshold;
};
}
}
}