Integrating up through commit 90f050496
This commit is contained in:
@@ -53,19 +53,19 @@ namespace AZ
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// AzToolsFramework::EditorPythonConsoleNotifications
|
||||
void OnTraceMessage(AZStd::string_view message) override
|
||||
void OnTraceMessage([[maybe_unused]] AZStd::string_view message) override
|
||||
{
|
||||
using namespace AZ::SceneAPI::Utilities;
|
||||
AZ_TracePrintf(LogWindow, "%.*s \n", AZ_STRING_ARG(message));
|
||||
}
|
||||
|
||||
void OnErrorMessage(AZStd::string_view message) override
|
||||
void OnErrorMessage([[maybe_unused]] AZStd::string_view message) override
|
||||
{
|
||||
using namespace AZ::SceneAPI::Utilities;
|
||||
AZ_TracePrintf(ErrorWindow, "[ERROR] %.*s \n", AZ_STRING_ARG(message));
|
||||
}
|
||||
|
||||
void OnExceptionMessage(AZStd::string_view message) override
|
||||
void OnExceptionMessage([[maybe_unused]] AZStd::string_view message) override
|
||||
{
|
||||
using namespace AZ::SceneAPI::Utilities;
|
||||
AZ_TracePrintf(ErrorWindow, "[EXCEPTION] %.*s \n", AZ_STRING_ARG(message));
|
||||
|
||||
@@ -30,6 +30,61 @@ namespace AZ
|
||||
return static_cast<unsigned int>(m_positions.size()-1);
|
||||
}
|
||||
|
||||
void BlendShapeData::AddTangentAndBitangent(const Vector4& tangent, const Vector3& bitangent)
|
||||
{
|
||||
m_tangents.push_back(tangent);
|
||||
m_bitangents.push_back(bitangent);
|
||||
}
|
||||
|
||||
void BlendShapeData::AddUV(const Vector2& uv, AZ::u8 uvSetIndex)
|
||||
{
|
||||
if (uvSetIndex >= MaxNumUVSets)
|
||||
{
|
||||
AZ_ErrorOnce("SceneGraphData", false, "uvSetIndex %zu is greater or equal than the maximum uv sets %zu.", uvSetIndex, MaxNumUVSets);
|
||||
return;
|
||||
}
|
||||
m_uvs[uvSetIndex].push_back(uv);
|
||||
}
|
||||
|
||||
void BlendShapeData::AddColor(const SceneAPI::DataTypes::Color& color, AZ::u8 colorSetIndex)
|
||||
{
|
||||
if (colorSetIndex >= MaxNumColorSets)
|
||||
{
|
||||
AZ_ErrorOnce("SceneGraphData", false, "colorSetIndex %zu is greater or equal than the maximum color sets %zu.", colorSetIndex, MaxNumColorSets);
|
||||
return;
|
||||
}
|
||||
m_colors[colorSetIndex].push_back(color);
|
||||
}
|
||||
|
||||
void BlendShapeData::ReserveData(
|
||||
unsigned int numVertices, bool reserveTangents, const AZStd::bitset<MaxNumUVSets>& uvSetUsedFlags,
|
||||
const AZStd::bitset<MaxNumColorSets>& colorSetUsedFlags)
|
||||
{
|
||||
m_positions.reserve(numVertices);
|
||||
m_normals.reserve(numVertices);
|
||||
if (reserveTangents)
|
||||
{
|
||||
m_tangents.reserve(numVertices);
|
||||
m_bitangents.reserve(numVertices);
|
||||
}
|
||||
|
||||
for (AZ::u8 uvSetIndex = 0; uvSetIndex < MaxNumUVSets; ++uvSetIndex)
|
||||
{
|
||||
if (uvSetUsedFlags[uvSetIndex])
|
||||
{
|
||||
m_uvs[uvSetIndex].reserve(numVertices);
|
||||
}
|
||||
}
|
||||
|
||||
for (AZ::u8 colorSetIndex = 0; colorSetIndex < MaxNumColorSets; ++colorSetIndex)
|
||||
{
|
||||
if (colorSetUsedFlags[colorSetIndex])
|
||||
{
|
||||
m_colors[colorSetIndex].reserve(numVertices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlendShapeData::AddFace(const Face& face)
|
||||
{
|
||||
m_faces.push_back(face);
|
||||
@@ -47,7 +102,7 @@ namespace AZ
|
||||
int BlendShapeData::GetControlPointIndex(int vertexIndex) const
|
||||
{
|
||||
auto iter = m_vertexIndexToControlPointIndexMap.find(vertexIndex);
|
||||
AZ_Assert(iter != m_vertexIndexToControlPointIndexMap.end(), "Vertex index %i doesn't exist", vertexIndex);
|
||||
AZ_Assert(iter != m_vertexIndexToControlPointIndexMap.end(), "Vertex index %i doesn't exist.", vertexIndex);
|
||||
// Note: AZStd::unordered_map's operator [] doesn't have const version...
|
||||
return iter->second;
|
||||
}
|
||||
@@ -92,6 +147,45 @@ namespace AZ
|
||||
return m_normals[index];
|
||||
}
|
||||
|
||||
const Vector2& BlendShapeData::GetUV(unsigned int vertexIndex, unsigned int uvSetIndex) const
|
||||
{
|
||||
AZ_Assert(uvSetIndex < MaxNumUVSets, "uvSet index out of range");
|
||||
AZ_Assert(vertexIndex < m_uvs[uvSetIndex].size(), "uvSet index out of range");
|
||||
return m_uvs[uvSetIndex][vertexIndex];
|
||||
}
|
||||
|
||||
AZStd::vector<Vector4>& BlendShapeData::GetTangents()
|
||||
{
|
||||
return m_tangents;
|
||||
}
|
||||
|
||||
const AZStd::vector<Vector4>& BlendShapeData::GetTangents() const
|
||||
{
|
||||
return m_tangents;
|
||||
}
|
||||
|
||||
AZStd::vector<Vector3>& BlendShapeData::GetBitangents()
|
||||
{
|
||||
return m_bitangents;
|
||||
}
|
||||
|
||||
const AZStd::vector<Vector3>& BlendShapeData::GetBitangents() const
|
||||
{
|
||||
return m_bitangents;
|
||||
}
|
||||
|
||||
const AZStd::vector<Vector2>& BlendShapeData::GetUVs(AZ::u8 uvSetIndex) const
|
||||
{
|
||||
AZ_Assert(uvSetIndex < MaxNumUVSets, "uvSet index out of range");
|
||||
return m_uvs[uvSetIndex];
|
||||
}
|
||||
|
||||
const AZStd::vector<SceneAPI::DataTypes::Color>& BlendShapeData::GetColors(AZ::u8 colorSetIndex) const
|
||||
{
|
||||
AZ_Assert(colorSetIndex < MaxNumColorSets, "colorSet index out of range");
|
||||
return m_colors[colorSetIndex];
|
||||
}
|
||||
|
||||
unsigned int BlendShapeData::GetFaceVertexIndex(unsigned int face, unsigned int vertexIndex) const
|
||||
{
|
||||
AZ_Assert(face < m_faces.size(), "GetFaceVertexPositionIndex face index not in range");
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
|
||||
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h>
|
||||
#include <SceneAPI/SceneCore/DataTypes/GraphData/IBlendShapeData.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -30,8 +31,19 @@ namespace AZ
|
||||
public:
|
||||
AZ_RTTI(BlendShapeData, "{FF875C22-2E4F-4CE3-BA49-09BF78C70A09}", SceneAPI::DataTypes::IBlendShapeData)
|
||||
|
||||
// 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)
|
||||
static constexpr AZ::u8 MaxNumUVSets = 8;
|
||||
|
||||
SCENE_DATA_API ~BlendShapeData() override;
|
||||
SCENE_DATA_API virtual unsigned int AddVertex(const Vector3& position, const Vector3& normal);
|
||||
SCENE_DATA_API void AddTangentAndBitangent(const Vector4& tangent, const Vector3& bitangent);
|
||||
SCENE_DATA_API void AddUV(const Vector2& uv, AZ::u8 uvSetIndex);
|
||||
SCENE_DATA_API void AddColor(const SceneAPI::DataTypes::Color& color, AZ::u8 colorSetIndex);
|
||||
SCENE_DATA_API void ReserveData(
|
||||
unsigned int numVertices, bool reserveTangents, const AZStd::bitset<MaxNumUVSets>& uvSetUsedFlags,
|
||||
const AZStd::bitset<MaxNumColorSets>& colorSetUsedFlags);
|
||||
|
||||
//assume consistent winding - no stripping or fanning expected (3 index per face)
|
||||
SCENE_DATA_API virtual void AddFace(const Face& face);
|
||||
@@ -48,6 +60,14 @@ namespace AZ
|
||||
|
||||
SCENE_DATA_API const Vector3& GetPosition(unsigned int index) const override;
|
||||
SCENE_DATA_API const Vector3& GetNormal(unsigned int index) const override;
|
||||
SCENE_DATA_API const Vector2& GetUV(unsigned int vertexIndex, unsigned int uvSetIndex) const;
|
||||
|
||||
SCENE_DATA_API AZStd::vector<Vector4>& GetTangents();
|
||||
SCENE_DATA_API const AZStd::vector<Vector4>& GetTangents() const;
|
||||
SCENE_DATA_API AZStd::vector<Vector3>& GetBitangents();
|
||||
SCENE_DATA_API const AZStd::vector<Vector3>& GetBitangents() const;
|
||||
SCENE_DATA_API const AZStd::vector<Vector2>& GetUVs(AZ::u8 uvSetIndex) const;
|
||||
SCENE_DATA_API const AZStd::vector<SceneAPI::DataTypes::Color>& GetColors(AZ::u8 colorSetIndex) const;
|
||||
|
||||
SCENE_DATA_API unsigned int GetFaceVertexIndex(unsigned int face, unsigned int vertexIndex) const override;
|
||||
|
||||
@@ -56,6 +76,11 @@ namespace AZ
|
||||
protected:
|
||||
AZStd::vector<Vector3> m_positions;
|
||||
AZStd::vector<Vector3> m_normals;
|
||||
AZStd::vector<Vector4> m_tangents;
|
||||
AZStd::vector<Vector3> m_bitangents;
|
||||
AZStd::vector<AZ::Vector2> m_uvs[MaxNumUVSets];
|
||||
AZStd::vector<SceneAPI::DataTypes::Color> m_colors[MaxNumColorSets];
|
||||
|
||||
AZStd::vector<Face> m_faces;
|
||||
|
||||
AZStd::unordered_map<int, int> m_vertexIndexToControlPointIndexMap;
|
||||
|
||||
@@ -30,49 +30,56 @@ namespace AZ::SceneAPI::SceneData
|
||||
|
||||
void CoordinateSystemRule::UpdateCoordinateSystemConverter()
|
||||
{
|
||||
switch (m_targetCoordinateSystem)
|
||||
if (m_useAdvancedData)
|
||||
{
|
||||
case ZUpPositiveYForward:
|
||||
m_coordinateSystemConverter = {};
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (m_targetCoordinateSystem)
|
||||
{
|
||||
// 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) };
|
||||
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) };
|
||||
// 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 };
|
||||
// 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;
|
||||
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) };
|
||||
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) };
|
||||
// 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 };
|
||||
// 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;
|
||||
m_coordinateSystemConverter = CoordinateSystemConverter::CreateFromBasisVectors(sourceBasisVectors, targetBasisVectors, targetBasisIndices);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
AZ_Assert(false, "Unsupported coordinate system conversion");
|
||||
};
|
||||
default:
|
||||
AZ_Assert(false, "Unsupported coordinate system conversion");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void CoordinateSystemRule::SetTargetCoordinateSystem(CoordinateSystem targetCoordinateSystem)
|
||||
@@ -94,22 +101,74 @@ namespace AZ::SceneAPI::SceneData
|
||||
return;
|
||||
}
|
||||
|
||||
serializeContext->Class<CoordinateSystemRule, IRule>()->Version(1)
|
||||
->Field("targetCoordinateSystem", &CoordinateSystemRule::m_targetCoordinateSystem);
|
||||
serializeContext->Class<CoordinateSystemRule, IRule>()->Version(2) // LYN-2442
|
||||
->Field("targetCoordinateSystem", &CoordinateSystemRule::m_targetCoordinateSystem)
|
||||
->Field("useAdvancedData", &CoordinateSystemRule::m_useAdvancedData)
|
||||
->Field("originNodeName", &CoordinateSystemRule::m_originNodeName)
|
||||
->Field("rotation", &CoordinateSystemRule::m_rotation)
|
||||
->Field("translation", &CoordinateSystemRule::m_translation)
|
||||
->Field("scale", &CoordinateSystemRule::m_scale);
|
||||
|
||||
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).")
|
||||
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.")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CoordinateSystemRule::m_useAdvancedData,
|
||||
"Use Advanced Settings",
|
||||
"Toggles on the advanced settings for transforming the mesh group.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
|
||||
->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");
|
||||
->EnumAttribute(CoordinateSystem::ZUpPositiveYForward, "Rotate 180 degrees around the up axis")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, &CoordinateSystemRule::GetBasicVisibility)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::AttributesAndValues)
|
||||
->DataElement("NodeListSelection", &CoordinateSystemRule::m_originNodeName,
|
||||
"Relative Origin Node",
|
||||
"Select a Node from the scene as the origin for this export.")
|
||||
->Attribute("DisabledOption", "")
|
||||
->Attribute("DefaultToDisabled", false)
|
||||
->Attribute("ExcludeEndPoints", true)
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, &CoordinateSystemRule::GetAdvancedVisibility)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CoordinateSystemRule::m_translation,
|
||||
"Translation",
|
||||
"Moves the group along the given vector.")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, &CoordinateSystemRule::GetAdvancedVisibility)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::AttributesAndValues)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CoordinateSystemRule::m_rotation,
|
||||
"Rotation",
|
||||
"Sets the orientation offset of the processed mesh in degrees. Rotates the group after translation.")
|
||||
->Attribute(Edit::Attributes::LabelForX, "P")
|
||||
->Attribute(Edit::Attributes::LabelForY, "R")
|
||||
->Attribute(Edit::Attributes::LabelForZ, "Y")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, &CoordinateSystemRule::GetAdvancedVisibility)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::AttributesAndValues)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CoordinateSystemRule::m_scale,
|
||||
"Scale",
|
||||
"Sets the scale offset of the processed mesh.")
|
||||
->Attribute(Edit::Attributes::Min, 0.0001)
|
||||
->Attribute(Edit::Attributes::Max, 1000.0)
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, &CoordinateSystemRule::GetAdvancedVisibility)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::AttributesAndValues);
|
||||
}
|
||||
}
|
||||
|
||||
AZ::Crc32 CoordinateSystemRule::GetBasicVisibility() const
|
||||
{
|
||||
return (m_useAdvancedData) ? AZ::Edit::PropertyVisibility::Hide : AZ::Edit::PropertyVisibility::Show;
|
||||
}
|
||||
|
||||
AZ::Crc32 CoordinateSystemRule::GetAdvancedVisibility() const
|
||||
{
|
||||
return (m_useAdvancedData) ? AZ::Edit::PropertyVisibility::Show : AZ::Edit::PropertyVisibility::Hide;
|
||||
}
|
||||
|
||||
bool CoordinateSystemRule::ConvertLegacyCoordinateSystemRule(AZ::SerializeContext& serializeContext,
|
||||
AZ::SerializeContext::DataElementNode& classElement)
|
||||
{
|
||||
@@ -155,4 +214,54 @@ namespace AZ::SceneAPI::SceneData
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CoordinateSystemRule::GetUseAdvancedData() const
|
||||
{
|
||||
return m_useAdvancedData;
|
||||
}
|
||||
|
||||
void CoordinateSystemRule::SetUseAdvancedData(bool useAdvancedData)
|
||||
{
|
||||
m_useAdvancedData = useAdvancedData;
|
||||
}
|
||||
|
||||
const AZStd::string& CoordinateSystemRule::GetOriginNodeName() const
|
||||
{
|
||||
return m_originNodeName;
|
||||
}
|
||||
|
||||
void CoordinateSystemRule::SetOriginNodeName(const AZStd::string& originNodeName)
|
||||
{
|
||||
m_originNodeName = originNodeName;
|
||||
}
|
||||
|
||||
const Quaternion& CoordinateSystemRule::GetRotation() const
|
||||
{
|
||||
return m_rotation;
|
||||
}
|
||||
|
||||
void CoordinateSystemRule::SetRotation(const Quaternion& rotation)
|
||||
{
|
||||
m_rotation = rotation;
|
||||
}
|
||||
|
||||
const Vector3& CoordinateSystemRule::GetTranslation() const
|
||||
{
|
||||
return m_translation;
|
||||
}
|
||||
|
||||
void CoordinateSystemRule::SetTranslation(const Vector3& translation)
|
||||
{
|
||||
m_translation = translation;
|
||||
}
|
||||
|
||||
float CoordinateSystemRule::GetScale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
|
||||
void CoordinateSystemRule::SetScale(float scale)
|
||||
{
|
||||
m_scale = scale;
|
||||
}
|
||||
} // namespace AZ::SceneAPI::SceneData
|
||||
|
||||
@@ -39,12 +39,34 @@ namespace AZ::SceneAPI::SceneData
|
||||
|
||||
SCENE_DATA_API const CoordinateSystemConverter& GetCoordinateSystemConverter() const override { return m_coordinateSystemConverter; }
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
SCENE_DATA_API static void Reflect(AZ::ReflectContext* context);
|
||||
SCENE_DATA_API static bool ConvertLegacyCoordinateSystemRule(AZ::SerializeContext& serializeContext,
|
||||
AZ::SerializeContext::DataElementNode& classElement);
|
||||
|
||||
// advanced coordinate settings
|
||||
SCENE_DATA_API bool GetUseAdvancedData() const override;
|
||||
SCENE_DATA_API void SetUseAdvancedData(bool useAdvancedData);
|
||||
SCENE_DATA_API const AZStd::string& GetOriginNodeName() const override;
|
||||
SCENE_DATA_API void SetOriginNodeName(const AZStd::string& originNodeName);
|
||||
SCENE_DATA_API const Quaternion& GetRotation() const override;
|
||||
SCENE_DATA_API void SetRotation(const Quaternion& rotation);
|
||||
SCENE_DATA_API const Vector3& GetTranslation() const override;
|
||||
SCENE_DATA_API void SetTranslation(const Vector3& translation);
|
||||
SCENE_DATA_API float GetScale() const override;
|
||||
SCENE_DATA_API void SetScale(float scale);
|
||||
|
||||
protected:
|
||||
AZ::Crc32 GetBasicVisibility() const;
|
||||
AZ::Crc32 GetAdvancedVisibility() const;
|
||||
|
||||
CoordinateSystemConverter m_coordinateSystemConverter;
|
||||
CoordinateSystem m_targetCoordinateSystem;
|
||||
|
||||
// advanced coordinate settings
|
||||
bool m_useAdvancedData = false;
|
||||
AZStd::string m_originNodeName;
|
||||
AZ::Quaternion m_rotation = AZ::Quaternion::CreateIdentity();
|
||||
AZ::Vector3 m_translation = AZ::Vector3::CreateZero();
|
||||
float m_scale = 1.0f;
|
||||
};
|
||||
} // namespace AZ::SceneAPI::SceneData
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <SceneAPI/SceneCore/Containers/SceneManifest.h>
|
||||
#include <SceneAPI/SceneData/ReflectionRegistrar.h>
|
||||
#include <SceneAPI/SceneData/Rules/CommentRule.h>
|
||||
#include <SceneAPI/SceneData/Rules/CoordinateSystemRule.h>
|
||||
|
||||
#include <AzCore/Name/NameDictionary.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
@@ -87,6 +87,7 @@ namespace AZ
|
||||
AZ::SceneAPI::RegisterDataTypeReflection(m_serializeContext.get());
|
||||
AZ::SceneAPI::Containers::SceneManifest::Reflect(m_serializeContext.get());
|
||||
AZ::SceneAPI::DataTypes::IManifestObject::Reflect(m_serializeContext.get());
|
||||
m_serializeContext->Class<AZ::SceneAPI::DataTypes::IRule, AZ::SceneAPI::DataTypes::IManifestObject>()->Version(1);
|
||||
AZ::SceneAPI::MockRotationRule::Reflect(m_serializeContext.get());
|
||||
|
||||
m_jsonRegistrationContext = AZStd::make_unique<AZ::JsonRegistrationContext>();
|
||||
@@ -174,5 +175,53 @@ namespace AZ
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"(0.27)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"(0.65)"));
|
||||
}
|
||||
|
||||
TEST_F(SceneManifest_JSON, LoadFromString_CoordinateSystemRule_ReturnsTrue)
|
||||
{
|
||||
AZ::SceneAPI::SceneData::CoordinateSystemRule foo;
|
||||
EXPECT_FALSE(foo.GetUseAdvancedData());
|
||||
|
||||
using namespace SceneAPI::Containers;
|
||||
|
||||
constexpr const char* jsonCoordinateSystemRule = { R"JSON(
|
||||
{
|
||||
"values": [
|
||||
{
|
||||
"$type": "CoordinateSystemRule",
|
||||
"useAdvancedData": true,
|
||||
"originNodeName": "test_origin_name",
|
||||
"translation": [1.0, 2.0, 3.0],
|
||||
"rotation": { "yaw" : 45.0, "pitch" : 18.5, "roll" : 215.0 },
|
||||
"scale": 10.0
|
||||
}
|
||||
]
|
||||
})JSON" };
|
||||
|
||||
SceneManifest loaded;
|
||||
auto loadFromStringResult = loaded.LoadFromString(jsonCoordinateSystemRule, m_serializeContext.get(), m_jsonRegistrationContext.get());
|
||||
EXPECT_TRUE(loadFromStringResult.IsSuccess());
|
||||
EXPECT_FALSE(loaded.IsEmpty());
|
||||
|
||||
auto writeToJsonResult =
|
||||
SceneManifestContainer::SaveToJsonDocumentHelper(loaded, m_serializeContext.get(), m_jsonRegistrationContext.get());
|
||||
ASSERT_TRUE(writeToJsonResult.IsSuccess());
|
||||
|
||||
AZStd::string jsonText;
|
||||
auto writeToStringResult = AzFramework::FileFunc::WriteJsonToString(writeToJsonResult.GetValue(), jsonText);
|
||||
ASSERT_TRUE(writeToStringResult.IsSuccess());
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("$type": "CoordinateSystemRule")"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("useAdvancedData": true,)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("originNodeName": "test_origin_name",)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("rotation": [)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"(0.028)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"(-0.40)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"(0.85)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"(-0.33)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("translation": [)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"(1.0)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"(2.0)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"(3.0)"));
|
||||
EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("scale": 10.0)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user