FBX -> Scene, part 2. Code changes, file renames (#1704)
* First pass FBX -> Scene File conversion. This is the simple pass, minimizing code changes and focused on comments. Signed-off-by: stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * Step 1 of part 2 of the FBX -> Scene rename Signed-off-by: stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * Renaming FbxSceneBuilder folder to SceneBuilder Signed-off-by: stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * Renamed files Signed-off-by: stankowi <4838196+AMZN-stankowi@users.noreply.github.com> * More FBX -> Scene Signed-off-by: stankowi <4838196+AMZN-stankowi@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/std/smart_ptr/make_shared.h>
|
||||
#include <AzCore/std/smart_ptr/shared_ptr.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <SceneAPI/SceneBuilder/Importers/ImporterUtilities.h>
|
||||
#include <SceneAPI/SceneCore/Containers/Scene.h>
|
||||
#include <SceneAPI/SceneCore/DataTypes/IGraphObject.h>
|
||||
#include <SceneAPI/SceneData/GraphData/MeshData.h>
|
||||
#include <SceneAPI/SceneData/GraphData/BoneData.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace SceneAPI
|
||||
{
|
||||
namespace SceneBuilder
|
||||
{
|
||||
TEST(SceneImporterUtilityTests, AreSceneGraphsEqual_EmptySceneGraphs_ReturnsTrue)
|
||||
{
|
||||
Containers::SceneGraph lhsGraph;
|
||||
Containers::SceneGraph rhsGraph;
|
||||
|
||||
bool sceneGraphsEqual =
|
||||
(AreSceneGraphsEqual(lhsGraph, rhsGraph) && AreSceneGraphsEqual(rhsGraph, lhsGraph));
|
||||
|
||||
EXPECT_TRUE(sceneGraphsEqual);
|
||||
}
|
||||
|
||||
TEST(SceneImporterUtilityTests, AreSceneGraphsEqual_SameNameSingleNodeBothNull_ReturnsTrue)
|
||||
{
|
||||
Containers::SceneGraph lhsGraph;
|
||||
lhsGraph.AddChild(lhsGraph.GetRoot(), "testChild");
|
||||
Containers::SceneGraph rhsGraph;
|
||||
rhsGraph.AddChild(rhsGraph.GetRoot(), "testChild");
|
||||
|
||||
bool sceneGraphsEqual =
|
||||
(AreSceneGraphsEqual(lhsGraph, rhsGraph) && AreSceneGraphsEqual(rhsGraph, lhsGraph));
|
||||
|
||||
EXPECT_TRUE(sceneGraphsEqual);
|
||||
}
|
||||
|
||||
TEST(SceneImporterUtilityTests, AreSceneGraphsEqual_SameNameSingleNodeSameType_ReturnsTrue)
|
||||
{
|
||||
Containers::SceneGraph lhsGraph;
|
||||
AZStd::shared_ptr<DataTypes::IGraphObject> lhsData = AZStd::make_shared<SceneData::GraphData::MeshData>();
|
||||
lhsGraph.AddChild(lhsGraph.GetRoot(), "testChild", AZStd::move(lhsData));
|
||||
Containers::SceneGraph rhsGraph;
|
||||
AZStd::shared_ptr<DataTypes::IGraphObject> rhsData = AZStd::make_shared<SceneData::GraphData::MeshData>();
|
||||
rhsGraph.AddChild(rhsGraph.GetRoot(), "testChild", AZStd::move(rhsData));
|
||||
|
||||
bool sceneGraphsEqual =
|
||||
(AreSceneGraphsEqual(lhsGraph, rhsGraph) && AreSceneGraphsEqual(rhsGraph, lhsGraph));
|
||||
|
||||
EXPECT_TRUE(sceneGraphsEqual);
|
||||
}
|
||||
|
||||
TEST(SceneImporterUtilityTests, AreSceneGraphsEqual_SameNameSingleNodeOneNull_ReturnsFalse)
|
||||
{
|
||||
Containers::SceneGraph lhsGraph;
|
||||
AZStd::shared_ptr<DataTypes::IGraphObject> lhsData = AZStd::make_shared<SceneData::GraphData::MeshData>();
|
||||
lhsGraph.AddChild(lhsGraph.GetRoot(), "testChild", AZStd::move(lhsData));
|
||||
Containers::SceneGraph rhsGraph;
|
||||
rhsGraph.AddChild(rhsGraph.GetRoot(), "testChild");
|
||||
|
||||
bool sceneGraphsEqual =
|
||||
(AreSceneGraphsEqual(lhsGraph, rhsGraph) && AreSceneGraphsEqual(rhsGraph, lhsGraph));
|
||||
|
||||
EXPECT_FALSE(sceneGraphsEqual);
|
||||
}
|
||||
|
||||
TEST(SceneImporterUtilityTests, AreSceneGraphsEqual_SameNameSingleNodeDifferentTypes_ReturnsFalse)
|
||||
{
|
||||
Containers::SceneGraph lhsGraph;
|
||||
AZStd::shared_ptr<DataTypes::IGraphObject> lhsData = AZStd::make_shared<SceneData::GraphData::MeshData>();
|
||||
lhsGraph.AddChild(lhsGraph.GetRoot(), "testChild", AZStd::move(lhsData));
|
||||
Containers::SceneGraph rhsGraph;
|
||||
AZStd::shared_ptr<DataTypes::IGraphObject> rhsData = AZStd::make_shared<SceneData::GraphData::BoneData>();
|
||||
rhsGraph.AddChild(rhsGraph.GetRoot(), "testChild", AZStd::move(rhsData));
|
||||
|
||||
bool sceneGraphsEqual =
|
||||
(AreSceneGraphsEqual(lhsGraph, rhsGraph) && AreSceneGraphsEqual(rhsGraph, lhsGraph));
|
||||
|
||||
EXPECT_FALSE(sceneGraphsEqual);
|
||||
}
|
||||
|
||||
TEST(SceneImporterUtilityTests, AreSceneGraphsEqual_SameNameOneEmptyOneSingleNode_ReturnsFalse)
|
||||
{
|
||||
Containers::SceneGraph lhsGraph;
|
||||
AZStd::shared_ptr<DataTypes::IGraphObject> lhsData = AZStd::make_shared<SceneData::GraphData::MeshData>();
|
||||
lhsGraph.AddChild(lhsGraph.GetRoot(), "testChild", AZStd::move(lhsData));
|
||||
Containers::SceneGraph rhsGraph;
|
||||
|
||||
bool sceneGraphsEqual =
|
||||
(AreSceneGraphsEqual(lhsGraph, rhsGraph) && AreSceneGraphsEqual(rhsGraph, lhsGraph));
|
||||
|
||||
EXPECT_FALSE(sceneGraphsEqual);
|
||||
}
|
||||
|
||||
TEST(SceneImpoterUtilityTests, AreSceneGraphsEqual_DifferentNamesSingleNodeBothNull_ReturnsFalse)
|
||||
{
|
||||
Containers::SceneGraph lhsGraph;
|
||||
lhsGraph.AddChild(lhsGraph.GetRoot(), "testChild");
|
||||
Containers::SceneGraph rhsGraph;
|
||||
rhsGraph.AddChild(rhsGraph.GetRoot(), "differentName");
|
||||
|
||||
bool sceneGraphsEqual =
|
||||
(AreSceneGraphsEqual(lhsGraph, rhsGraph) && AreSceneGraphsEqual(rhsGraph, lhsGraph));
|
||||
|
||||
EXPECT_FALSE(sceneGraphsEqual);
|
||||
}
|
||||
|
||||
TEST(SceneImporterUtilityTests, AreSceneGraphsEqual_SecondGraphExtraChild_ReturnsFalse)
|
||||
{
|
||||
Containers::SceneGraph lhsGraph;
|
||||
lhsGraph.AddChild(lhsGraph.GetRoot(), "testChild");
|
||||
lhsGraph.AddChild(lhsGraph.GetRoot(), "extraTestChild");
|
||||
Containers::SceneGraph rhsGraph;
|
||||
rhsGraph.AddChild(rhsGraph.GetRoot(), "testChild");
|
||||
|
||||
bool sceneGraphsEqual =
|
||||
(AreSceneGraphsEqual(lhsGraph, rhsGraph) && AreSceneGraphsEqual(rhsGraph, lhsGraph));
|
||||
|
||||
EXPECT_FALSE(sceneGraphsEqual);
|
||||
}
|
||||
} // namespace SceneBuilder
|
||||
} // namespace SceneAPI
|
||||
} // namespace AZ
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/std/smart_ptr/make_shared.h>
|
||||
#include <AzCore/std/smart_ptr/shared_ptr.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <SceneAPI/SceneBuilder/Importers/Utilities/RenamedNodesMap.h>
|
||||
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
|
||||
#include <SceneAPI/SceneCore/DataTypes/IGraphObject.h>
|
||||
#include <SceneAPI/SceneData/GraphData/MeshData.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace SceneAPI
|
||||
{
|
||||
namespace SceneBuilder
|
||||
{
|
||||
TEST(RenamedNodesMapTests, SanitizeNodeName_ValidNameProvided_ReturnsFalseAndNameUnchanged)
|
||||
{
|
||||
Containers::SceneGraph graph;
|
||||
AZStd::string name = "ValidName";
|
||||
|
||||
bool result = RenamedNodesMap::SanitizeNodeName(name, graph, graph.GetRoot());
|
||||
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_STREQ("ValidName", name.c_str());
|
||||
}
|
||||
|
||||
TEST(RenamedNodesMapTests, SanitizeNodeName_NameWithInvalidCharacter_ReturnsTrueAndNameChanged)
|
||||
{
|
||||
Containers::SceneGraph graph;
|
||||
AZStd::string check = "Valid";
|
||||
check += Containers::SceneGraph::GetNodeSeperationCharacter();
|
||||
check += "Name";
|
||||
AZStd::string name = check;
|
||||
|
||||
bool result = RenamedNodesMap::SanitizeNodeName(name, graph, graph.GetRoot());
|
||||
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_STRNE(check.c_str(), name.c_str());
|
||||
}
|
||||
|
||||
TEST(RenamedNodesMapTests, SanitizeNodeName_BlankName_ReturnsTrueAndNameSetToDefault)
|
||||
{
|
||||
Containers::SceneGraph graph;
|
||||
AZStd::string name;
|
||||
|
||||
bool result = RenamedNodesMap::SanitizeNodeName(name, graph, graph.GetRoot(), "Default");
|
||||
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_STREQ("Default", name.c_str());
|
||||
}
|
||||
|
||||
TEST(RenamedNodesMapTests, SanitizeNodeName_SingleCollision_ReturnsTrueAndNameHasAppendixOf1)
|
||||
{
|
||||
Containers::SceneGraph graph;
|
||||
graph.AddChild(graph.GetRoot(), "Child");
|
||||
AZStd::string name = "Child";
|
||||
|
||||
bool result = RenamedNodesMap::SanitizeNodeName(name, graph, graph.GetRoot());
|
||||
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_STREQ("Child_1", name.c_str());
|
||||
}
|
||||
|
||||
TEST(RenamedNodesMapTests, SanitizeNodeName_MultipleCollisions_ReturnsTrueAndNameHasAppendixOf2)
|
||||
{
|
||||
Containers::SceneGraph graph;
|
||||
auto child = graph.AddChild(graph.GetRoot(), "Child");
|
||||
graph.AddSibling(child, "Child_1");
|
||||
AZStd::string name = "Child";
|
||||
|
||||
bool result = RenamedNodesMap::SanitizeNodeName(name, graph, graph.GetRoot());
|
||||
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_STREQ("Child_2", name.c_str());
|
||||
}
|
||||
} // namespace SceneBuilder
|
||||
} // namespace SceneAPI
|
||||
} // namespace AZ
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <SceneAPI/FbxSceneBuilder/Tests/TestFbxMesh.h>
|
||||
#include <fbxsdk.h>
|
||||
#include <AzCore/Casting/lossy_cast.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace FbxSDKWrapper
|
||||
{
|
||||
TestFbxMesh::TestFbxMesh()
|
||||
: m_vertexControlPoints(nullptr)
|
||||
, m_vertexCount(0)
|
||||
, m_polygonVertexIndices(nullptr)
|
||||
, m_materialIndices(new FbxLayerElementArrayTemplate<int>(eFbxInt))
|
||||
, m_uvElements(FbxGeometryElementUV::Create(nullptr, "TestElements_UV"))
|
||||
, m_vertexColorElements(FbxGeometryElementVertexColor::Create(nullptr, "TestElements_VertexColors"))
|
||||
, m_expectedVertexCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
int TestFbxMesh::GetDeformerCount() const
|
||||
{
|
||||
// For current test need, only have one skin for the mesh
|
||||
return m_skin ? 1 : 0;
|
||||
}
|
||||
|
||||
AZStd::shared_ptr<const FbxSkinWrapper> TestFbxMesh::GetSkin(int index) const
|
||||
{
|
||||
// For current test need, only have one skin for the mesh
|
||||
return m_skin;
|
||||
}
|
||||
|
||||
bool TestFbxMesh::GetMaterialIndices(FbxLayerElementArrayTemplate<int>** lockableArray) const
|
||||
{
|
||||
*lockableArray = m_materialIndices;
|
||||
return true;
|
||||
}
|
||||
|
||||
int TestFbxMesh::GetControlPointsCount() const
|
||||
{
|
||||
return static_cast<int>(m_vertexCount);
|
||||
}
|
||||
|
||||
AZStd::vector<Vector3> TestFbxMesh::GetControlPoints() const
|
||||
{
|
||||
return m_vertexControlPoints;
|
||||
}
|
||||
|
||||
int TestFbxMesh::GetPolygonCount() const
|
||||
{
|
||||
return static_cast<int>(m_polygonInfo.size());
|
||||
}
|
||||
|
||||
int TestFbxMesh::GetPolygonSize(int polygonIndex) const
|
||||
{
|
||||
if (m_polygonInfo.find(polygonIndex) != m_polygonInfo.end())
|
||||
{
|
||||
return aznumeric_caster(m_polygonInfo.find(polygonIndex)->second.m_vertexCount);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int* TestFbxMesh::GetPolygonVertices() const
|
||||
{
|
||||
return m_polygonVertexIndices;
|
||||
}
|
||||
|
||||
int TestFbxMesh::GetPolygonVertexIndex(int polygonIndex) const
|
||||
{
|
||||
if (m_polygonInfo.find(polygonIndex) != m_polygonInfo.end())
|
||||
{
|
||||
return aznumeric_caster(m_polygonInfo.find(polygonIndex)->second.m_startVertexIndex);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
FbxUVWrapper TestFbxMesh::GetElementUV(int index)
|
||||
{
|
||||
(void)index;
|
||||
return m_uvElements;
|
||||
}
|
||||
|
||||
int TestFbxMesh::GetElementUVCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
FbxVertexColorWrapper TestFbxMesh::GetElementVertexColor(int index)
|
||||
{
|
||||
(void)index;
|
||||
return m_vertexColorElements;
|
||||
}
|
||||
|
||||
int TestFbxMesh::GetElementVertexColorCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool TestFbxMesh::GetPolygonVertexNormal(int polyIndex, int vertexIndex, Vector3& normal) const
|
||||
{
|
||||
normal = Vector3(1.0f, 0.0f, 0.0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TestFbxMesh::CreateMesh(std::vector<AZ::Vector3>& points, std::vector<std::vector<int> >& polygonVertexIndices)
|
||||
{
|
||||
m_vertexControlPoints.clear();
|
||||
m_materialIndices->Clear();
|
||||
m_polygonInfo.clear();
|
||||
|
||||
// Create fbx control point (position) data, and associated material index data
|
||||
m_vertexCount = aznumeric_caster(points.size());
|
||||
m_vertexControlPoints.reserve(points.size());
|
||||
for (unsigned int i = 0; i < points.size(); ++i)
|
||||
{
|
||||
m_vertexControlPoints.push_back(Vector3(points[i].GetX(), points[i].GetY(), points[i].GetZ()));
|
||||
m_materialIndices->Add(i);
|
||||
}
|
||||
|
||||
// Create fbx face data
|
||||
m_expectedVertexCount = 0;
|
||||
for (const std::vector<int>& onePolygonIndices : polygonVertexIndices)
|
||||
{
|
||||
for (const int& index : onePolygonIndices)
|
||||
{
|
||||
m_expectedVertexCount++;
|
||||
}
|
||||
}
|
||||
if (m_polygonVertexIndices)
|
||||
{
|
||||
delete m_polygonVertexIndices;
|
||||
}
|
||||
m_polygonVertexIndices = new int[m_expectedVertexCount];
|
||||
size_t i = 0;
|
||||
for (const std::vector<int>& onePolygonIndices : polygonVertexIndices)
|
||||
{
|
||||
m_polygonInfo.insert(std::make_pair<int, TestFbxPolygon>(aznumeric_caster(m_polygonInfo.size()),
|
||||
TestFbxPolygon(i, aznumeric_caster(onePolygonIndices.size()))));
|
||||
for (const int& index : onePolygonIndices)
|
||||
{
|
||||
m_polygonVertexIndices[i] = index;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TestFbxMesh::SetSkin(const AZStd::shared_ptr<FbxSkinWrapper>& skin)
|
||||
{
|
||||
m_skin = skin;
|
||||
}
|
||||
|
||||
void TestFbxMesh::CreateExpectMeshInfo(std::vector<std::vector<int> >& expectedFaceVertexIndices)
|
||||
{
|
||||
m_expectedFaceVertexIndices = expectedFaceVertexIndices;
|
||||
}
|
||||
|
||||
size_t TestFbxMesh::GetExpectedVetexCount() const
|
||||
{
|
||||
return m_expectedVertexCount;
|
||||
}
|
||||
|
||||
size_t TestFbxMesh::GetExpectedFaceCount() const
|
||||
{
|
||||
return m_expectedFaceVertexIndices.size();
|
||||
}
|
||||
|
||||
AZ::Vector3 TestFbxMesh::GetExpectedFaceVertexPosition(unsigned int faceIndex, unsigned int vertexIndex) const
|
||||
{
|
||||
return m_vertexControlPoints[m_expectedFaceVertexIndices[faceIndex][vertexIndex]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <SceneAPI/FbxSDKWrapper/FbxMeshWrapper.h>
|
||||
#include <SceneAPI/FbxSDKWrapper/FbxSkinWrapper.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace FbxSDKWrapper
|
||||
{
|
||||
struct TestFbxPolygon
|
||||
{
|
||||
size_t m_startVertexIndex;
|
||||
size_t m_vertexCount;
|
||||
|
||||
TestFbxPolygon(size_t startVertexIndex, size_t vertexCount)
|
||||
: m_startVertexIndex(startVertexIndex)
|
||||
, m_vertexCount(vertexCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// TestFbxMesh
|
||||
// FbxMesh Test Data creation
|
||||
class TestFbxMesh
|
||||
: public FbxMeshWrapper
|
||||
{
|
||||
public:
|
||||
TestFbxMesh();
|
||||
~TestFbxMesh() override = default;
|
||||
|
||||
int GetDeformerCount() const override;
|
||||
AZStd::shared_ptr<const FbxSkinWrapper> GetSkin(int index) const override;
|
||||
bool GetMaterialIndices(FbxLayerElementArrayTemplate<int>** lockableArray) const override;
|
||||
|
||||
int GetControlPointsCount() const;
|
||||
AZStd::vector<Vector3> GetControlPoints() const override;
|
||||
|
||||
int GetPolygonCount() const override;
|
||||
int GetPolygonSize(int polygonIndex) const override;
|
||||
int* GetPolygonVertices() const override;
|
||||
int GetPolygonVertexIndex(int polygonIndex) const;
|
||||
|
||||
FbxUVWrapper GetElementUV(int index = 0) override;
|
||||
int GetElementUVCount() const override;
|
||||
FbxVertexColorWrapper GetElementVertexColor(int index = 0) override;
|
||||
int GetElementVertexColorCount() const override;
|
||||
|
||||
bool GetPolygonVertexNormal(int polyIndex, int vertexIndex, Vector3& normal) const override;
|
||||
|
||||
// Create test data APIs
|
||||
void CreateMesh(std::vector<AZ::Vector3>& points, std::vector<std::vector<int> >& polygonVertexIndices);
|
||||
void CreateExpectMeshInfo(std::vector<std::vector<int> >& expectedFaceVertexIndices);
|
||||
void SetSkin(const AZStd::shared_ptr<FbxSkinWrapper>& skin);
|
||||
|
||||
size_t GetExpectedVetexCount() const;
|
||||
size_t GetExpectedFaceCount() const;
|
||||
AZ::Vector3 GetExpectedFaceVertexPosition(unsigned int faceIndex, unsigned int vertexIndex) const;
|
||||
|
||||
protected:
|
||||
AZStd::vector<Vector3> m_vertexControlPoints; // vertex positions
|
||||
size_t m_vertexCount;
|
||||
int* m_polygonVertexIndices; // store all polygons' vertex indices in sequence. Each index maps to a control point.
|
||||
FbxLayerElementArrayTemplate<int>* m_materialIndices;
|
||||
std::unordered_map<int, TestFbxPolygon> m_polygonInfo;
|
||||
|
||||
FbxUVWrapper m_uvElements;
|
||||
FbxVertexColorWrapper m_vertexColorElements;
|
||||
AZStd::shared_ptr<FbxSkinWrapper> m_skin;
|
||||
|
||||
// Expected converted data
|
||||
unsigned int m_expectedVertexCount;
|
||||
std::vector<std::vector<int> > m_expectedFaceVertexIndices;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include <SceneAPI/FbxSceneBuilder/Tests/TestFbxNode.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace FbxSDKWrapper
|
||||
{
|
||||
const std::shared_ptr<FbxMeshWrapper> TestFbxNode::GetMesh() const
|
||||
{
|
||||
return m_testFbxMesh;
|
||||
}
|
||||
|
||||
const char* TestFbxNode::GetName() const
|
||||
{
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
void TestFbxNode::SetMesh(std::shared_ptr<TestFbxMesh> testFbxMesh)
|
||||
{
|
||||
m_testFbxMesh = testFbxMesh;
|
||||
}
|
||||
|
||||
void TestFbxNode::SetName(const char* name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <SceneAPI/FbxSDKWrapper/FbxNodeWrapper.h>
|
||||
#include <SceneAPI/FbxSceneBuilder/Tests/TestFbxMesh.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace FbxSDKWrapper
|
||||
{
|
||||
// TestFbxNode
|
||||
// FbxNode Test Data creation
|
||||
class TestFbxNode
|
||||
: public FbxNodeWrapper
|
||||
{
|
||||
public:
|
||||
~TestFbxNode() override = default;
|
||||
|
||||
const std::shared_ptr<FbxMeshWrapper> GetMesh() const override;
|
||||
const char* GetName() const override;
|
||||
|
||||
void SetMesh(std::shared_ptr<TestFbxMesh> testFbxMesh);
|
||||
void SetName(const char* name);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<TestFbxMesh> m_testFbxMesh;
|
||||
AZStd::string m_name;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/std/smart_ptr/make_shared.h>
|
||||
#include <SceneAPI/FbxSceneBuilder/Tests/TestFbxSkin.h>
|
||||
#include <SceneAPI/FbxSceneBuilder/Tests/TestFbxNode.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace FbxSDKWrapper
|
||||
{
|
||||
const char* TestFbxSkin::GetName() const
|
||||
{
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
int TestFbxSkin::GetClusterCount() const
|
||||
{
|
||||
return aznumeric_caster(m_links.size());
|
||||
}
|
||||
|
||||
int TestFbxSkin::GetClusterControlPointIndicesCount(int index) const
|
||||
{
|
||||
return aznumeric_caster(m_controlPointIndices[index].size());
|
||||
}
|
||||
|
||||
int TestFbxSkin::GetClusterControlPointIndex(int clusterIndex, int pointIndex) const
|
||||
{
|
||||
return m_controlPointIndices[clusterIndex][pointIndex];
|
||||
}
|
||||
|
||||
double TestFbxSkin::GetClusterControlPointWeight(int clusterIndex, int pointIndex) const
|
||||
{
|
||||
return m_weights[clusterIndex][pointIndex];
|
||||
}
|
||||
|
||||
AZStd::shared_ptr<const FbxNodeWrapper> TestFbxSkin::GetClusterLink(int index) const
|
||||
{
|
||||
return m_links[index];
|
||||
}
|
||||
|
||||
void TestFbxSkin::SetName(const char* name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
void TestFbxSkin::CreateSkinWeightData(AZStd::vector<AZStd::string>& boneNames, AZStd::vector<AZStd::vector<double>>& weights, AZStd::vector<AZStd::vector<int>>& controlPointIndices)
|
||||
{
|
||||
m_links.resize(boneNames.size());
|
||||
for (size_t linkIndex = 0; linkIndex < boneNames.size(); ++linkIndex)
|
||||
{
|
||||
m_links[linkIndex] = AZStd::make_shared<FbxSDKWrapper::TestFbxNode>();
|
||||
m_links[linkIndex]->SetName(boneNames[linkIndex].c_str());
|
||||
}
|
||||
m_weights = weights;
|
||||
m_controlPointIndices = controlPointIndices;
|
||||
}
|
||||
|
||||
void TestFbxSkin::CreateExpectSkinWeightData(AZStd::vector<AZStd::vector<int>>& boneIds, AZStd::vector<AZStd::vector<float>>& weights)
|
||||
{
|
||||
m_expectedBoneIds = boneIds;
|
||||
m_expectedWeights = weights;
|
||||
}
|
||||
|
||||
size_t TestFbxSkin::GetExpectedVertexCount() const
|
||||
{
|
||||
return m_expectedBoneIds.size();
|
||||
}
|
||||
|
||||
size_t TestFbxSkin::GetExpectedLinkCount(size_t vertexIndex) const
|
||||
{
|
||||
return m_expectedBoneIds[vertexIndex].size();
|
||||
}
|
||||
|
||||
int TestFbxSkin::GetExpectedSkinLinkBoneId(size_t vertexIndex, size_t linkIndex) const
|
||||
{
|
||||
return m_expectedBoneIds[vertexIndex][linkIndex];
|
||||
}
|
||||
|
||||
float TestFbxSkin::GetExpectedSkinLinkWeight(size_t vertextIndex, size_t linkIndex) const
|
||||
{
|
||||
return m_expectedWeights[vertextIndex][linkIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <SceneAPI/FbxSDKWrapper/FbxSkinWrapper.h>
|
||||
#include <SceneAPI/FbxSceneBuilder/Tests/TestFbxNode.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace FbxSDKWrapper
|
||||
{
|
||||
class TestFbxSkin
|
||||
: public FbxSkinWrapper
|
||||
{
|
||||
public:
|
||||
~TestFbxSkin() override = default;
|
||||
|
||||
const char* GetName() const override;
|
||||
int GetClusterCount() const override;
|
||||
int GetClusterControlPointIndicesCount(int index) const override;
|
||||
int GetClusterControlPointIndex(int clusterIndex, int pointIndex) const override;
|
||||
double GetClusterControlPointWeight(int clusterIndex, int pointIndex) const override;
|
||||
AZStd::shared_ptr<const FbxNodeWrapper> GetClusterLink(int index) const override;
|
||||
|
||||
void SetName(const char* name);
|
||||
void CreateSkinWeightData(AZStd::vector<AZStd::string>& boneNames, AZStd::vector<AZStd::vector<double>>& weights, AZStd::vector<AZStd::vector<int>>& controlPointIndices);
|
||||
void CreateExpectSkinWeightData(AZStd::vector<AZStd::vector<int>>& boneIds, AZStd::vector<AZStd::vector<float>>& weights);
|
||||
|
||||
size_t GetExpectedVertexCount() const;
|
||||
size_t GetExpectedLinkCount(size_t vertexIndex) const;
|
||||
int GetExpectedSkinLinkBoneId(size_t vertexIndex, size_t linkIndex) const;
|
||||
float GetExpectedSkinLinkWeight(size_t vertexIndex, size_t linkIndex) const;
|
||||
|
||||
protected:
|
||||
AZStd::string m_name;
|
||||
AZStd::vector<AZStd::shared_ptr<FbxSDKWrapper::TestFbxNode>> m_links;
|
||||
AZStd::vector<AZStd::vector<double>> m_weights;
|
||||
AZStd::vector<AZStd::vector<int>> m_controlPointIndices;
|
||||
|
||||
AZStd::vector<AZStd::vector<int>> m_expectedBoneIds;
|
||||
AZStd::vector<AZStd::vector<float>> m_expectedWeights;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <AzCore/Module/DynamicModuleHandle.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
|
||||
class SceneBuilderTestEnvironment
|
||||
: public AZ::Test::ITestEnvironment
|
||||
{
|
||||
public:
|
||||
virtual ~SceneBuilderTestEnvironment()
|
||||
{}
|
||||
|
||||
protected:
|
||||
void SetupEnvironment() override
|
||||
{
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Create();
|
||||
|
||||
sceneCoreModule = AZ::DynamicModuleHandle::Create("SceneCore");
|
||||
AZ_Assert(sceneCoreModule, "SceneBuilder unit tests failed to create SceneCore module.");
|
||||
bool loaded = sceneCoreModule->Load(false);
|
||||
AZ_Assert(loaded, "SceneBuilder unit tests failed to load SceneCore module.");
|
||||
auto init = sceneCoreModule->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
|
||||
AZ_Assert(init, "SceneBuilder unit tests failed to find the initialization function the SceneCore module.");
|
||||
(*init)(AZ::Environment::GetInstance());
|
||||
|
||||
sceneDataModule = AZ::DynamicModuleHandle::Create("SceneData");
|
||||
AZ_Assert(sceneDataModule, "SceneData unit tests failed to create SceneData module.");
|
||||
loaded = sceneDataModule->Load(false);
|
||||
AZ_Assert(loaded, "SceneBuilder unit tests failed to load SceneData module.");
|
||||
init = sceneDataModule->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
|
||||
AZ_Assert(init, "SceneBuilder unit tests failed to find the initialization function the SceneData module.");
|
||||
(*init)(AZ::Environment::GetInstance());
|
||||
}
|
||||
|
||||
void TeardownEnvironment() override
|
||||
{
|
||||
auto uninit = sceneDataModule->GetFunction<AZ::UninitializeDynamicModuleFunction>(AZ::UninitializeDynamicModuleFunctionName);
|
||||
AZ_Assert(uninit, "SceneBuilder unit tests failed to find the uninitialization function the SceneData module.");
|
||||
(*uninit)();
|
||||
sceneDataModule.reset();
|
||||
|
||||
uninit = sceneCoreModule->GetFunction<AZ::UninitializeDynamicModuleFunction>(AZ::UninitializeDynamicModuleFunctionName);
|
||||
AZ_Assert(uninit, "SceneBuilder unit tests failed to find the uninitialization function the SceneCore module.");
|
||||
(*uninit)();
|
||||
sceneCoreModule.reset();
|
||||
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
|
||||
}
|
||||
|
||||
private:
|
||||
AZStd::unique_ptr<AZ::DynamicModuleHandle> sceneCoreModule;
|
||||
AZStd::unique_ptr<AZ::DynamicModuleHandle> sceneDataModule;
|
||||
};
|
||||
|
||||
AZ_UNIT_TEST_HOOK(new SceneBuilderTestEnvironment);
|
||||
|
||||
Reference in New Issue
Block a user