/* * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace EMotionFX { using ActorCanSaveSimulatedObjectSetupFixtureBase = InitSceneAPIFixture< AZ::MemoryComponent, AZ::AssetManagerComponent, AZ::JobManagerComponent, AzToolsFramework::Components::PropertyManagerComponent, EMotionFX::Integration::SystemComponent, EMotionFX::Pipeline::ActorBuilder >; class ActorCanSaveSimulatedObjectSetupFixture : public ActorCanSaveSimulatedObjectSetupFixtureBase { public: void SetUp() override { ActorCanSaveSimulatedObjectSetupFixtureBase::SetUp(); // Set up the scene graph m_scene = AZStd::make_unique("MockScene"); m_scene->SetOriginalSceneOrientation(AZ::SceneAPI::Containers::Scene::SceneOrientation::ZUp); AZ::SceneAPI::Containers::SceneGraph& graph = m_scene->GetGraph(); graph.AddChild(graph.GetRoot(), "testRootBone", AZStd::make_shared()); } AZStd::unique_ptr m_scene{}; }; TEST_F(ActorCanSaveSimulatedObjectSetupFixture, Test) { EMotionFX::Pipeline::Group::ActorGroup actorGroup; actorGroup.SetName("TestSimulatedObjectSaving"); actorGroup.SetSelectedRootBone("testRootBone"); auto simulatedObjectSetupRule = AZStd::make_shared(); auto simulatedObjectSetup = AZStd::make_shared(); simulatedObjectSetup->AddSimulatedObject("testSimulatedObject"); simulatedObjectSetupRule->SetData(simulatedObjectSetup); actorGroup.GetRuleContainer().AddRule(simulatedObjectSetupRule); AZ::SceneAPI::Events::ExportProductList products; // Only run the Filling phase, to avoid any file writes EMotionFX::Pipeline::ActorGroupExportContext actorGroupExportContext( products, *m_scene, /*outputDirectory =*/"tmp", actorGroup, AZ::RC::Phase::Filling ); EMotionFX::Pipeline::ActorGroupExporter exporter; AZ::SceneAPI::Events::ProcessingResult result = exporter.ProcessContext(actorGroupExportContext); ASSERT_EQ(result, AZ::SceneAPI::Events::ProcessingResult::Success) << "Failed to build actor"; Actor* actor = exporter.GetActor(); ASSERT_TRUE(actor); ASSERT_TRUE(actor->GetSimulatedObjectSetup()); ASSERT_EQ(actor->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 1); EXPECT_STREQ(actor->GetSimulatedObjectSetup()->GetSimulatedObject(0)->GetName().c_str(), "testSimulatedObject"); } } // namespace EMotionFX