Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,57 @@
/*
* 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/Components/BehaviorComponent.h>
#include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
class AnimationGroup
: public SceneCore::BehaviorComponent
, public Events::ManifestMetaInfoBus::Handler
, public Events::AssetImportRequestBus::Handler
{
public:
AZ_COMPONENT(AnimationGroup, "{CE7FEBE4-ACA3-41B8-9154-9B9E09A95A06}", SceneCore::BehaviorComponent);
~AnimationGroup() override = default;
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* context);
// ManifestMetaInfo
void GetCategoryAssignments(CategoryRegistrationList& categories, const Containers::Scene& scene) override;
void InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target) override;
// AssetImportRequest
Events::ProcessingResult UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication requester) override;
private:
Events::ProcessingResult BuildDefault(Containers::Scene& scene) const;
Events::ProcessingResult UpdateAnimationGroups(Containers::Scene& scene) const;
bool SceneHasAnimationGroup(const Containers::Scene& scene) const;
static const int s_animationsPreferredTabOrder;
};
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,174 @@
/*
* 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/SerializeContext.h>
#include <AzCore/std/algorithm.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphDownwardsIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/Containers/Utilities/SceneGraphUtilities.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IAnimationData.h>
#include <SceneAPI/SceneCore/DataTypes/DataTypeUtilities.h>
#include <SceneAPI/SceneData/Groups/AnimationGroup.h>
#include <SceneAPI/SceneData/Behaviors/AnimationGroup.h>
#include <SceneAPI/SceneData/GraphData/RootBoneData.h>
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
const int AnimationGroup::s_animationsPreferredTabOrder = 2;
void AnimationGroup::Activate()
{
}
void AnimationGroup::Deactivate()
{
}
void AnimationGroup::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<AnimationGroup, BehaviorComponent>()->Version(1);
}
}
void AnimationGroup::GetCategoryAssignments(CategoryRegistrationList& categories, const Containers::Scene& scene)
{
if (SceneHasAnimationGroup(scene) || Utilities::DoesSceneGraphContainDataLike<DataTypes::IAnimationData>(scene, false))
{
categories.emplace_back("Animations", SceneData::AnimationGroup::TYPEINFO_Uuid(), s_animationsPreferredTabOrder);
}
}
void AnimationGroup::InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target)
{
if (!target.RTTI_IsTypeOf(SceneData::AnimationGroup::TYPEINFO_Uuid()))
{
return;
}
SceneData::AnimationGroup* group = azrtti_cast<SceneData::AnimationGroup*>(&target);
group->SetName(DataTypes::Utilities::CreateUniqueName<DataTypes::IAnimationGroup>(scene.GetName(), scene.GetManifest()));
const Containers::SceneGraph &graph = scene.GetGraph();
auto nameStorage = graph.GetNameStorage();
auto contentStorage = graph.GetContentStorage();
auto nameContentView = Containers::Views::MakePairView(nameStorage, contentStorage);
AZStd::string shallowestRootBoneName;
auto graphDownwardsView = Containers::Views::MakeSceneGraphDownwardsView<Containers::Views::BreadthFirst>(graph, graph.GetRoot(), nameContentView.begin(), true);
for (auto it = graphDownwardsView.begin(); it != graphDownwardsView.end(); ++it)
{
if (!it->second)
{
continue;
}
if (it->second->RTTI_IsTypeOf(AZ::SceneData::GraphData::RootBoneData::TYPEINFO_Uuid()))
{
shallowestRootBoneName = it->first.GetPath();
break;
}
}
group->SetSelectedRootBone(shallowestRootBoneName);
Containers::SceneGraph::ContentStorageConstData graphContent = graph.GetContentStorage();
auto animationData = AZStd::find_if(graphContent.begin(), graphContent.end(), Containers::DerivedTypeFilter<DataTypes::IAnimationData>());
if (animationData == graphContent.end())
{
return;
}
const DataTypes::IAnimationData* animation = azrtti_cast<const DataTypes::IAnimationData*>(animationData->get());
uint32_t frameCount = aznumeric_caster(animation->GetKeyFrameCount());
group->SetStartFrame(0);
group->SetEndFrame(frameCount > 0 ? frameCount - 1 : 0);
}
Events::ProcessingResult AnimationGroup::UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication /*requester*/)
{
if (action == ManifestAction::ConstructDefault)
{
return BuildDefault(scene);
}
else if (action == ManifestAction::Update)
{
return UpdateAnimationGroups(scene);
}
else
{
return Events::ProcessingResult::Ignored;
}
}
Events::ProcessingResult AnimationGroup::BuildDefault(Containers::Scene& scene) const
{
if (SceneHasAnimationGroup(scene) || !Utilities::DoesSceneGraphContainDataLike<DataTypes::IAnimationData>(scene, true))
{
return Events::ProcessingResult::Ignored;
}
// There are animations but no animation group, so add a default animation group to the manifest.
AZStd::shared_ptr<SceneData::AnimationGroup> group = AZStd::make_shared<SceneData::AnimationGroup>();
// This is a group that's generated automatically so may not be saved to disk but would need to be recreated
// in the same way again. To guarantee the same uuid, generate a stable one instead.
group->OverrideId(DataTypes::Utilities::CreateStableUuid(scene, SceneData::AnimationGroup::TYPEINFO_Uuid()));
EBUS_EVENT(Events::ManifestMetaInfoBus, InitializeObject, scene, *group);
scene.GetManifest().AddEntry(AZStd::move(group));
return Events::ProcessingResult::Success;
}
Events::ProcessingResult AnimationGroup::UpdateAnimationGroups(Containers::Scene& scene) const
{
bool updated = false;
Containers::SceneManifest& manifest = scene.GetManifest();
auto valueStorage = manifest.GetValueStorage();
auto view = Containers::MakeDerivedFilterView<SceneData::AnimationGroup>(valueStorage);
for (SceneData::AnimationGroup& group : view)
{
if (group.GetName().empty())
{
group.SetName(DataTypes::Utilities::CreateUniqueName<DataTypes::IAnimationGroup>(scene.GetName(), scene.GetManifest()));
updated = true;
}
if (group.GetId().IsNull())
{
// When the uuid is null it's likely because the manifest has been updated from an older version. Include the
// name of the group as there could be multiple groups.
group.OverrideId(DataTypes::Utilities::CreateStableUuid(scene, SceneData::AnimationGroup::TYPEINFO_Uuid(), group.GetName()));
updated = true;
}
}
return updated ? Events::ProcessingResult::Success : Events::ProcessingResult::Ignored;
}
bool AnimationGroup::SceneHasAnimationGroup(const Containers::Scene& scene) const
{
const Containers::SceneManifest& manifest = scene.GetManifest();
Containers::SceneManifest::ValueStorageConstData manifestData = manifest.GetValueStorage();
auto animationGroup = AZStd::find_if(manifestData.begin(), manifestData.end(), Containers::DerivedTypeFilter<DataTypes::IAnimationGroup>());
return animationGroup != manifestData.end();
}
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,170 @@
/*
* 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/SerializeContext.h>
#include <AzCore/std/algorithm.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/Containers/Utilities/SceneGraphUtilities.h>
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/FilterIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphChildIterator.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IBoneData.h>
#include <SceneAPI/SceneCore/DataTypes/DataTypeUtilities.h>
#include <SceneAPI/SceneCore/Events/GraphMetaInfoBus.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneData/Groups/MeshGroup.h>
#include <SceneAPI/SceneData/Behaviors/MeshGroup.h>
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
const int MeshGroup::s_meshGroupPreferredTabOrder = 0;
void MeshGroup::Activate()
{
Events::ManifestMetaInfoBus::Handler::BusConnect();
Events::AssetImportRequestBus::Handler::BusConnect();
}
void MeshGroup::Deactivate()
{
Events::AssetImportRequestBus::Handler::BusDisconnect();
Events::ManifestMetaInfoBus::Handler::BusDisconnect();
}
void MeshGroup::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<MeshGroup, BehaviorComponent>()->Version(1);
}
}
void MeshGroup::GetCategoryAssignments(CategoryRegistrationList& categories, const Containers::Scene& scene)
{
if (SceneHasMeshGroup(scene) || Utilities::DoesSceneGraphContainDataLike<DataTypes::IMeshData>(scene, false))
{
categories.emplace_back("Meshes", SceneData::MeshGroup::TYPEINFO_Uuid(), s_meshGroupPreferredTabOrder);
}
}
void MeshGroup::InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target)
{
if (!target.RTTI_IsTypeOf(SceneData::MeshGroup::TYPEINFO_Uuid()))
{
return;
}
SceneData::MeshGroup* group = azrtti_cast<SceneData::MeshGroup*>(&target);
group->SetName(DataTypes::Utilities::CreateUniqueName<DataTypes::IMeshGroup>(scene.GetName(), scene.GetManifest()));
Utilities::SceneGraphSelector::SelectAll(scene.GetGraph(), group->GetSceneNodeSelectionList());
const Containers::SceneGraph& graph = scene.GetGraph();
auto nameStorage = graph.GetNameStorage();
auto contentStorage = graph.GetContentStorage();
auto keyValueView = Containers::Views::MakePairView(nameStorage, contentStorage);
auto filteredView = Containers::Views::MakeFilterView(keyValueView, Containers::DerivedTypeFilter<DataTypes::IMeshData>());
for (auto it = filteredView.begin(); it != filteredView.end(); ++it)
{
AZStd::set<Crc32> types;
auto keyValueIterator = it.GetBaseIterator();
Containers::SceneGraph::NodeIndex index = graph.ConvertToNodeIndex(keyValueIterator.GetFirstIterator());
EBUS_EVENT(Events::GraphMetaInfoBus, GetVirtualTypes, types, scene, index);
if (!types.empty())
{
// Mesh is not a standard static mesh, but a special type so remove it from the selected list.
group->GetSceneNodeSelectionList().RemoveSelectedNode(it->first.GetPath());
}
}
}
Events::ProcessingResult MeshGroup::UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication /*requester*/)
{
if (action == ManifestAction::ConstructDefault)
{
return BuildDefault(scene);
}
else if (action == ManifestAction::Update)
{
return UpdateMeshGroups(scene);
}
else
{
return Events::ProcessingResult::Ignored;
}
}
Events::ProcessingResult MeshGroup::BuildDefault(Containers::Scene& scene) const
{
if (SceneHasMeshGroup(scene) || !Utilities::DoesSceneGraphContainDataLike<DataTypes::IMeshData>(scene, true) || Utilities::DoesSceneGraphContainDataLike<DataTypes::IBoneData>(scene, true))
{
return Events::ProcessingResult::Ignored;
}
// There are meshes but no mesh group, so add a default mesh group to the manifest.
AZStd::shared_ptr<SceneData::MeshGroup> group = AZStd::make_shared<SceneData::MeshGroup>();
// This is a group that's generated automatically so may not be saved to disk but would need to be recreated
// in the same way again. To guarantee the same uuid, generate a stable one instead.
group->OverrideId(DataTypes::Utilities::CreateStableUuid(scene, MeshGroup::TYPEINFO_Uuid()));
EBUS_EVENT(Events::ManifestMetaInfoBus, InitializeObject, scene, *group);
scene.GetManifest().AddEntry(AZStd::move(group));
return Events::ProcessingResult::Success;
}
Events::ProcessingResult MeshGroup::UpdateMeshGroups(Containers::Scene& scene) const
{
bool updated = false;
Containers::SceneManifest& manifest = scene.GetManifest();
auto valueStorage = manifest.GetValueStorage();
auto view = Containers::MakeDerivedFilterView<SceneData::MeshGroup>(valueStorage);
for (SceneData::MeshGroup& group : view)
{
if (group.GetName().empty())
{
group.SetName(DataTypes::Utilities::CreateUniqueName<DataTypes::IMeshGroup>(scene.GetName(), scene.GetManifest()));
}
if (group.GetId().IsNull())
{
// When the uuid it's null is likely because the manifest has been updated from an older version. Include the
// name of the group as there could be multiple groups.
group.OverrideId(DataTypes::Utilities::CreateStableUuid(scene, MeshGroup::TYPEINFO_Uuid(), group.GetName()));
}
Utilities::SceneGraphSelector::UpdateNodeSelection(scene.GetGraph(), group.GetSceneNodeSelectionList());
updated = true;
}
return updated ? Events::ProcessingResult::Success : Events::ProcessingResult::Ignored;
}
bool MeshGroup::SceneHasMeshGroup(const Containers::Scene& scene) const
{
const Containers::SceneManifest& manifest = scene.GetManifest();
Containers::SceneManifest::ValueStorageConstData manifestData = manifest.GetValueStorage();
auto meshGroup = AZStd::find_if(manifestData.begin(), manifestData.end(), Containers::DerivedTypeFilter<DataTypes::IMeshGroup>());
return meshGroup != manifestData.end();
}
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,192 @@
/*
* 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/SerializeContext.h>
#include <AzCore/std/algorithm.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphDownwardsIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/Containers/Utilities/SceneGraphUtilities.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IBoneData.h>
#include <SceneAPI/SceneCore/DataTypes/DataTypeUtilities.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneData/Groups/SkeletonGroup.h>
#include <SceneAPI/SceneData/Behaviors/SkeletonGroup.h>
#include <SceneAPI/SceneData/GraphData/RootBoneData.h>
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
const int SkeletonGroup::s_rigsPreferredTabOrder = 1;
void SkeletonGroup::Activate()
{
}
void SkeletonGroup::Deactivate()
{
}
void SkeletonGroup::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<SkeletonGroup, BehaviorComponent>()->Version(1);
}
}
void SkeletonGroup::GetCategoryAssignments(CategoryRegistrationList& categories, const Containers::Scene& scene)
{
if (SceneHasSkeletonGroup(scene) || Utilities::DoesSceneGraphContainDataLike<DataTypes::IBoneData>(scene, false))
{
categories.emplace_back("Rigs", SceneData::SkeletonGroup::TYPEINFO_Uuid(), s_rigsPreferredTabOrder);
}
}
void SkeletonGroup::InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target)
{
if (!m_isDefaultConstructing && target.RTTI_IsTypeOf(SceneData::SkeletonGroup::TYPEINFO_Uuid()))
{
SceneData::SkeletonGroup* group = azrtti_cast<SceneData::SkeletonGroup*>(&target);
group->SetName(DataTypes::Utilities::CreateUniqueName<DataTypes::ISkeletonGroup>(scene.GetName(), scene.GetManifest()));
const Containers::SceneGraph &graph = scene.GetGraph();
auto contentStorage = graph.GetContentStorage();
auto nameStorage = graph.GetNameStorage();
auto nameContentView = Containers::Views::MakePairView(nameStorage, contentStorage);
AZStd::string shallowestRootBoneName;
auto graphDownwardsView = Containers::Views::MakeSceneGraphDownwardsView<Containers::Views::BreadthFirst>(graph, graph.GetRoot(), nameContentView.begin(), true);
for (auto it = graphDownwardsView.begin(); it != graphDownwardsView.end(); ++it)
{
if (!it->second)
{
continue;
}
if (it->second->RTTI_IsTypeOf(AZ::SceneData::GraphData::RootBoneData::TYPEINFO_Uuid()))
{
shallowestRootBoneName = it->first.GetPath();
break;
}
}
group->SetSelectedRootBone(shallowestRootBoneName);
}
}
Events::ProcessingResult SkeletonGroup::UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication /*requester*/)
{
if (action == ManifestAction::ConstructDefault)
{
return BuildDefault(scene);
}
else if (action == ManifestAction::Update)
{
return UpdateSkeletonGroups(scene);
}
else
{
return Events::ProcessingResult::Ignored;
}
}
Events::ProcessingResult SkeletonGroup::BuildDefault(Containers::Scene& scene)
{
if (SceneHasSkeletonGroup(scene))
{
return Events::ProcessingResult::Ignored;
}
const Containers::SceneGraph &graph = scene.GetGraph();
auto contentStorage = graph.GetContentStorage();
auto nameStorage = graph.GetNameStorage();
auto nameContentView = Containers::Views::MakePairView(nameStorage, contentStorage);
bool hasCreatedSkeletons = false;
m_isDefaultConstructing = true;
for (auto it = nameContentView.begin(); it != nameContentView.end(); ++it)
{
if (!it->second || !it->second->RTTI_IsTypeOf(AZ::SceneData::GraphData::RootBoneData::TYPEINFO_Uuid()))
{
continue;
}
// Check if this is a virtual type. There are no known virtual types supported by skeletons so this skeleton
// pretends to be something that's not understood by this behavior, so skip it.
AZStd::set<Crc32> virtualTypes;
Events::GraphMetaInfoBus::Broadcast(&Events::GraphMetaInfoBus::Events::GetVirtualTypes, virtualTypes,
scene, graph.ConvertToNodeIndex(it.GetFirstIterator()));
if (!virtualTypes.empty())
{
continue;
}
AZStd::shared_ptr<SceneData::SkeletonGroup> group = AZStd::make_shared<SceneData::SkeletonGroup>();
AZStd::string name = DataTypes::Utilities::CreateUniqueName<DataTypes::ISkeletonGroup>(scene.GetName(), it->first.GetName(), scene.GetManifest());
// This is a group that's generated automatically so may not be saved to disk but would need to be recreated
// in the same way again. To guarantee the same uuid, generate a stable one instead.
group->OverrideId(DataTypes::Utilities::CreateStableUuid(scene, SceneData::SkeletonGroup::TYPEINFO_Uuid(), name));
group->SetName(AZStd::move(name));
group->SetSelectedRootBone(it->first.GetPath());
Events::ManifestMetaInfoBus::Broadcast(&Events::ManifestMetaInfoBus::Events::InitializeObject, scene, *group);
scene.GetManifest().AddEntry(AZStd::move(group));
hasCreatedSkeletons = true;
}
m_isDefaultConstructing = false;
return hasCreatedSkeletons ? Events::ProcessingResult::Success : Events::ProcessingResult::Ignored;
}
Events::ProcessingResult SkeletonGroup::UpdateSkeletonGroups(Containers::Scene& scene) const
{
bool updated = false;
Containers::SceneManifest& manifest = scene.GetManifest();
auto valueStorage = manifest.GetValueStorage();
auto view = Containers::MakeDerivedFilterView<SceneData::SkeletonGroup>(valueStorage);
for (SceneData::SkeletonGroup& group : view)
{
if (group.GetName().empty())
{
group.SetName(DataTypes::Utilities::CreateUniqueName<DataTypes::ISkeletonGroup>(scene.GetName(), scene.GetManifest()));
updated = true;
}
if (group.GetId().IsNull())
{
// When the uuid is null it's likely because the manifest has been updated from an older version. Include the
// name of the group as there could be multiple groups.
group.OverrideId(DataTypes::Utilities::CreateStableUuid(scene, SceneData::SkeletonGroup::TYPEINFO_Uuid(), group.GetName()));
updated = true;
}
}
return updated ? Events::ProcessingResult::Success : Events::ProcessingResult::Ignored;
}
bool SkeletonGroup::SceneHasSkeletonGroup(const Containers::Scene& scene) const
{
const Containers::SceneManifest& manifest = scene.GetManifest();
Containers::SceneManifest::ValueStorageConstData manifestData = manifest.GetValueStorage();
auto skeletonGroup = AZStd::find_if(manifestData.begin(), manifestData.end(), Containers::DerivedTypeFilter<DataTypes::ISkeletonGroup>());
return skeletonGroup != manifestData.end();
}
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,197 @@
/*
* 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/SerializeContext.h>
#include <AzCore/std/algorithm.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/Containers/Views/FilterIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphChildIterator.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/ISkinWeightData.h>
#include <SceneAPI/SceneCore/DataTypes/DataTypeUtilities.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneCore/Containers/Utilities/SceneGraphUtilities.h>
#include <SceneAPI/SceneData/Groups/SkinGroup.h>
#include <SceneAPI/SceneData/Behaviors/SkinGroup.h>
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
const char* SkinGroup::s_skinVirtualTypeName = "Skin";
Crc32 SkinGroup::s_skinVirtualType = AZ_CRC(SkinGroup::s_skinVirtualTypeName, 0x0279681e);
const int SkinGroup::s_rigsPreferredTabOrder = 1;
void SkinGroup::Activate()
{
}
void SkinGroup::Deactivate()
{
}
void SkinGroup::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<SkinGroup, BehaviorComponent>()->Version(1);
}
}
void SkinGroup::GetCategoryAssignments(CategoryRegistrationList& categories, const Containers::Scene& scene)
{
if (SceneHasSkinGroup(scene) || Utilities::DoesSceneGraphContainDataLike<DataTypes::ISkinWeightData>(scene, false))
{
categories.emplace_back("Rigs", SceneData::SkinGroup::TYPEINFO_Uuid(), s_rigsPreferredTabOrder);
}
}
void SkinGroup::InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target)
{
SceneData::SkinGroup* group = azrtti_cast<SceneData::SkinGroup*>(&target);
if (!group)
{
return;
}
group->SetName(DataTypes::Utilities::CreateUniqueName<DataTypes::ISkinGroup>(scene.GetName(), scene.GetManifest()));
Utilities::SceneGraphSelector::UnselectAll(scene.GetGraph(), group->GetSceneNodeSelectionList());
const Containers::SceneGraph& graph = scene.GetGraph();
Containers::SceneGraph::ContentStorageConstData graphContent = graph.GetContentStorage();
auto view = Containers::Views::MakeFilterView(graphContent, Containers::DerivedTypeFilter<DataTypes::IMeshData>());
for (auto iter = view.begin(); iter != view.end(); ++iter)
{
Containers::SceneGraph::NodeIndex nodeIndex = graph.ConvertToNodeIndex(iter.GetBaseIterator());
auto children = Containers::Views::MakeSceneGraphChildView(graph, nodeIndex, iter.GetBaseIterator(), false);
if (AZStd::find_if(children.begin(), children.end(),
Containers::DerivedTypeFilter<DataTypes::ISkinWeightData>()) != children.end())
{
group->GetSceneNodeSelectionList().AddSelectedNode(graph.GetNodeName(nodeIndex).GetPath());
}
}
Utilities::SceneGraphSelector::UpdateNodeSelection(scene.GetGraph(), group->GetSceneNodeSelectionList());
}
Events::ProcessingResult SkinGroup::UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication /*requester*/)
{
if (action == ManifestAction::ConstructDefault)
{
return BuildDefault(scene);
}
else if (action == ManifestAction::Update)
{
return UpdateGroups(scene);
}
else
{
return Events::ProcessingResult::Ignored;
}
}
void SkinGroup::GetVirtualTypes(AZStd::set<Crc32>& types, const Containers::Scene& scene,
Containers::SceneGraph::NodeIndex node)
{
if (types.find(s_skinVirtualType) != types.end())
{
// Virtual type for skins has already been added.
return;
}
const Containers::SceneGraph& graph = scene.GetGraph();
auto children = Containers::Views::MakeSceneGraphChildView(graph, node, graph.GetContentStorage().begin(), true);
if (AZStd::find_if(children.begin(), children.end(),
Containers::DerivedTypeFilter<DataTypes::ISkinWeightData>()) != children.end())
{
types.insert(s_skinVirtualType);
}
}
void SkinGroup::GetVirtualTypeName(AZStd::string& name, Crc32 type)
{
if (type == s_skinVirtualType)
{
name = s_skinVirtualTypeName;
}
}
void SkinGroup::GetAllVirtualTypes(AZStd::set<Crc32>& types)
{
if (types.find(s_skinVirtualType) == types.end())
{
types.insert(s_skinVirtualType);
}
}
Events::ProcessingResult SkinGroup::BuildDefault(Containers::Scene& scene) const
{
if (SceneHasSkinGroup(scene) || !Utilities::DoesSceneGraphContainDataLike<DataTypes::ISkinWeightData>(scene, true))
{
return Events::ProcessingResult::Ignored;
}
// There are skins but no skin group, so add a default skin group to the manifest.
AZStd::shared_ptr<SceneData::SkinGroup> group = AZStd::make_shared<SceneData::SkinGroup>();
// This is a group that's generated automatically so may not be saved to disk but would need to be recreated
// in the same way again. To guarantee the same uuid, generate a stable one instead.
group->OverrideId(DataTypes::Utilities::CreateStableUuid(scene, SceneData::SkinGroup::TYPEINFO_Uuid()));
EBUS_EVENT(Events::ManifestMetaInfoBus, InitializeObject, scene, *group);
scene.GetManifest().AddEntry(AZStd::move(group));
return Events::ProcessingResult::Success;
}
Events::ProcessingResult SkinGroup::UpdateGroups(Containers::Scene& scene) const
{
bool updated = false;
Containers::SceneManifest& manifest = scene.GetManifest();
auto valueStorage = manifest.GetValueStorage();
auto view = Containers::MakeDerivedFilterView<SceneData::SkinGroup>(valueStorage);
for (SceneData::SkinGroup& group : view)
{
if (group.GetName().empty())
{
group.SetName(DataTypes::Utilities::CreateUniqueName<DataTypes::ISkinGroup>(scene.GetName(), scene.GetManifest()));
}
if (group.GetId().IsNull())
{
// When the uuid is null it's likely because the manifest has been updated from an older version. Include the
// name of the group as there could be multiple groups.
group.OverrideId(DataTypes::Utilities::CreateStableUuid(scene, SceneData::SkinGroup::TYPEINFO_Uuid(), group.GetName()));
}
Utilities::SceneGraphSelector::UpdateNodeSelection(scene.GetGraph(), group.GetSceneNodeSelectionList());
updated = true;
}
return updated ? Events::ProcessingResult::Success : Events::ProcessingResult::Ignored;
}
bool SkinGroup::SceneHasSkinGroup(const Containers::Scene& scene) const
{
const Containers::SceneManifest& manifest = scene.GetManifest();
Containers::SceneManifest::ValueStorageConstData manifestData = manifest.GetValueStorage();
auto skinGroup = AZStd::find_if(manifestData.begin(), manifestData.end(), Containers::DerivedTypeFilter<DataTypes::ISkinGroup>());
return skinGroup != manifestData.end();
}
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,145 @@
/*
* 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/SerializeContext.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/SceneManifest.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/FilterIterator.h>
#include <SceneAPI/SceneCore/Events/GraphMetaInfoBus.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkinGroup.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IMaterialRule.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IBlendShapeData.h>
#include <SceneAPI/SceneData/Rules/BlendShapeRule.h>
#include <SceneAPI/SceneData/Rules/MaterialRule.h>
#include <SceneAPI/SceneData/Behaviors/BlendShapeRuleBehavior.h>
#include <SceneAPI/SceneData/ManifestBase/SceneNodeSelectionList.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
void BlendShapeRuleBehavior::Activate()
{
Events::ManifestMetaInfoBus::Handler::BusConnect();
Events::AssetImportRequestBus::Handler::BusConnect();
}
void BlendShapeRuleBehavior::Deactivate()
{
Events::AssetImportRequestBus::Handler::BusDisconnect();
Events::ManifestMetaInfoBus::Handler::BusDisconnect();
}
void BlendShapeRuleBehavior::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<BlendShapeRuleBehavior, BehaviorComponent>()->Version(1);
}
}
void BlendShapeRuleBehavior::InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target)
{
if (target.RTTI_IsTypeOf(DataTypes::ISkinGroup::TYPEINFO_Uuid()))
{
SceneData::SceneNodeSelectionList selection;
size_t blendShapeCount = SelectBlendShapes(scene, selection);
if (blendShapeCount > 0)
{
AZStd::shared_ptr<SceneData::BlendShapeRule> blendShapeRule = AZStd::make_shared<SceneData::BlendShapeRule>();
selection.CopyTo(blendShapeRule->GetNodeSelectionList());
DataTypes::ISkinGroup* skinGroup = azrtti_cast<DataTypes::ISkinGroup*>(&target);
skinGroup->GetRuleContainer().AddRule(AZStd::move(blendShapeRule));
}
}
else if (target.RTTI_IsTypeOf(SceneData::BlendShapeRule::TYPEINFO_Uuid()))
{
SceneData::BlendShapeRule* rule = azrtti_cast<SceneData::BlendShapeRule*>(&target);
SelectBlendShapes(scene, rule->GetSceneNodeSelectionList());
}
}
size_t BlendShapeRuleBehavior::SelectBlendShapes(const Containers::Scene& scene, DataTypes::ISceneNodeSelectionList& selection) const
{
Utilities::SceneGraphSelector::UnselectAll(scene.GetGraph(), selection);
size_t blendShapeCount = 0;
const Containers::SceneGraph& graph = scene.GetGraph();
auto contentStorage = graph.GetContentStorage();
auto nameStorage = graph.GetNameStorage();
auto keyValueView = Containers::Views::MakePairView(nameStorage, contentStorage);
auto filteredView = Containers::Views::MakeFilterView(keyValueView, Containers::DerivedTypeFilter<DataTypes::IBlendShapeData>());
for (auto it = filteredView.begin(); it != filteredView.end(); ++it)
{
AZStd::set<Crc32> types;
auto keyValueIterator = it.GetBaseIterator();
Containers::SceneGraph::NodeIndex index = graph.ConvertToNodeIndex(keyValueIterator.GetFirstIterator());
EBUS_EVENT(Events::GraphMetaInfoBus, GetVirtualTypes, types, scene, index);
if (types.find(Events::GraphMetaInfo::GetIgnoreVirtualType()) == types.end())
{
selection.AddSelectedNode(it->first.GetPath());
blendShapeCount++;
}
}
return blendShapeCount;
}
Events::ProcessingResult BlendShapeRuleBehavior::UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication /*requester*/)
{
if (action == ManifestAction::Update)
{
UpdateBlendShapeRules(scene);
return Events::ProcessingResult::Success;
}
else
{
return Events::ProcessingResult::Ignored;
}
}
void BlendShapeRuleBehavior::UpdateBlendShapeRules(Containers::Scene& scene) const
{
Containers::SceneManifest& manifest = scene.GetManifest();
auto valueStorage = manifest.GetValueStorage();
auto view = Containers::MakeDerivedFilterView<DataTypes::ISkinGroup>(valueStorage);
for (DataTypes::ISkinGroup& group : view)
{
AZ_TraceContext("Skin group", group.GetName());
const Containers::RuleContainer& rules = group.GetRuleContainer();
const size_t ruleCount = rules.GetRuleCount();
for (size_t index = 0; index < ruleCount; ++index)
{
SceneData::BlendShapeRule* rule = azrtti_cast<SceneData::BlendShapeRule*>(rules.GetRule(index).get());
if (rule)
{
Utilities::SceneGraphSelector::UpdateNodeSelection(scene.GetGraph(), rule->GetSceneNodeSelectionList());
}
}
}
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,55 @@
/*
* 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/Components/BehaviorComponent.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace SceneAPI
{
namespace DataTypes
{
class IGroup;
class ISceneNodeSelectionList;
}
namespace SceneData
{
class BlendShapeRuleBehavior
: public SceneCore::BehaviorComponent
, public Events::ManifestMetaInfoBus::Handler
, public Events::AssetImportRequestBus::Handler
{
public:
AZ_COMPONENT(BlendShapeRuleBehavior, "{D07DABE6-D731-4F4F-B55E-019EDE5B435E}", SceneCore::BehaviorComponent);
~BlendShapeRuleBehavior() override = default;
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* context);
void InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target) override;
Events::ProcessingResult UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication requester) override;
private:
size_t SelectBlendShapes(const Containers::Scene& scene, DataTypes::ISceneNodeSelectionList& selection) const;
void UpdateBlendShapeRules(Containers::Scene& scene) const;
};
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,220 @@
/*
* 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/SerializeContext.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/std/containers/fixed_vector.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/SceneManifest.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/FilterIterator.h>
#include <SceneAPI/SceneCore/Events/GraphMetaInfoBus.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISceneNodeGroup.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IMaterialRule.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/IMeshGroup.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkinGroup.h>
#include <SceneAPI/SceneData/Rules/LodRule.h>
#include <SceneAPI/SceneData/Behaviors/LodRuleBehavior.h>
#include <SceneAPI/SceneData/ManifestBase/SceneNodeSelectionList.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
static AZStd::fixed_vector < AZ::Crc32, LodRule::m_maxLods > s_lodVirtualTypeKeys =
{
AZ_CRC("LODMesh1", 0xcbea988c),
AZ_CRC("LODMesh2", 0x52e3c936),
AZ_CRC("LODMesh3", 0x25e4f9a0),
AZ_CRC("LODMesh4", 0xbb806c03),
AZ_CRC("LODMesh5", 0xcc875c95)
};
void LodRuleBehavior::Activate()
{
Events::ManifestMetaInfoBus::Handler::BusConnect();
Events::AssetImportRequestBus::Handler::BusConnect();
Events::GraphMetaInfoBus::Handler::BusConnect();
}
void LodRuleBehavior::Deactivate()
{
Events::GraphMetaInfoBus::Handler::BusDisconnect();
Events::AssetImportRequestBus::Handler::BusDisconnect();
Events::ManifestMetaInfoBus::Handler::BusDisconnect();
}
void LodRuleBehavior::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<LodRuleBehavior, BehaviorComponent>()->Version(1);
}
}
void LodRuleBehavior::InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target)
{
//Initialize Mesh Groups.
if (target.RTTI_IsTypeOf(DataTypes::IMeshGroup::TYPEINFO_Uuid()) || target.RTTI_IsTypeOf(DataTypes::ISkinGroup::TYPEINFO_Uuid()))
{
AZStd::shared_ptr<LodRule> lodRule = nullptr;
for (size_t lodLevel = 0; lodLevel < LodRule::m_maxLods; ++lodLevel)
{
SceneNodeSelectionList selection;
size_t lodCount = SelectLodMeshes(scene, selection, lodLevel);
if (lodCount > 0)
{
//Only create a lodRule if we have the first lod level.
if (lodLevel == 0 && !lodRule)
{
lodRule = AZStd::make_shared<LodRule>();
}
lodRule->AddLod();
selection.CopyTo(lodRule->GetNodeSelectionList(lodLevel));
}
else
{
//Stop processing if we hit an empty lod.
break;
}
}
if(lodRule)
{
DataTypes::IGroup* group = azrtti_cast<DataTypes::IGroup*>(&target);
group->GetRuleContainer().AddRule(AZStd::move(lodRule));
}
}
else if (target.RTTI_IsTypeOf(LodRule::TYPEINFO_Uuid()))
{
LodRule* rule = azrtti_cast<LodRule*>(&target);
for (size_t lodLevel = 0; lodLevel < rule->GetLodCount(); ++lodLevel)
{
SelectLodMeshes(scene, rule->GetSceneNodeSelectionList(lodLevel), lodLevel);
}
}
}
size_t LodRuleBehavior::SelectLodMeshes(const Containers::Scene& scene, DataTypes::ISceneNodeSelectionList& selection, size_t lodLevel) const
{
Utilities::SceneGraphSelector::SelectAll(scene.GetGraph(), selection);
size_t lodMeshCount = 0;
const Containers::SceneGraph& graph = scene.GetGraph();
auto contentStorage = graph.GetContentStorage();
auto nameStorage = graph.GetNameStorage();
auto keyValueView = Containers::Views::MakePairView(nameStorage, contentStorage);
auto filteredView = Containers::Views::MakeFilterView(keyValueView, Containers::DerivedTypeFilter<DataTypes::IMeshData>());
for (auto it = filteredView.begin(); it != filteredView.end(); ++it)
{
AZStd::set<Crc32> types;
auto keyValueIterator = it.GetBaseIterator();
Containers::SceneGraph::NodeIndex index = graph.ConvertToNodeIndex(keyValueIterator.GetFirstIterator());
EBUS_EVENT(Events::GraphMetaInfoBus, GetVirtualTypes, types, scene, index);
if (types.find(Events::GraphMetaInfo::GetIgnoreVirtualType()) != types.end() ||
types.find(s_lodVirtualTypeKeys[lodLevel]) == types.end())
{
selection.RemoveSelectedNode(it->first.GetPath());
}
else
{
lodMeshCount++;
}
}
return lodMeshCount;
}
Events::ProcessingResult LodRuleBehavior::UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication /*requester*/)
{
if (action == ManifestAction::Update)
{
UpdateLodRules(scene);
return Events::ProcessingResult::Success;
}
else
{
return Events::ProcessingResult::Ignored;
}
}
void LodRuleBehavior::UpdateLodRules(Containers::Scene& scene) const
{
Containers::SceneManifest& manifest = scene.GetManifest();
//Process Mesh or Skin Groups.
auto valueStorage = manifest.GetValueStorage();
auto view = Containers::MakeDerivedFilterView<DataTypes::ISceneNodeGroup>(valueStorage);
for (DataTypes::ISceneNodeGroup& group : view)
{
AZ_TraceContext("Mesh/Skin Group", group.GetName());
const Containers::RuleContainer& rules = group.GetRuleContainer();
const size_t ruleCount = rules.GetRuleCount();
for (size_t index = 0; index < ruleCount; ++index)
{
LodRule* rule = azrtti_cast<LodRule*>(rules.GetRule(index).get());
if (rule)
{
//update existing lods.
for (size_t lodLevel = 0; lodLevel < rule->GetLodCount(); ++lodLevel)
{
Utilities::SceneGraphSelector::UpdateNodeSelection(scene.GetGraph(), rule->GetSceneNodeSelectionList(lodLevel));
}
//Check for new lods.
for (size_t lodLevel = rule->GetLodCount(); lodLevel < LodRule::m_maxLods; ++lodLevel)
{
SceneNodeSelectionList selection;
size_t lodCount = SelectLodMeshes(scene, selection, lodLevel);
if (lodCount > 0)
{
rule->AddLod();
selection.CopyTo(rule->GetNodeSelectionList(index));
}
else
{
//Stop processing if we hit an empty lod.
break;
}
}
}
}
}
}
void LodRuleBehavior::GetVirtualTypeName(AZStd::string& name, Crc32 type)
{
if (type == AZ_CRC("LODMesh1", 0xcbea988c)) { name = "LODMesh1"; }
else if (type == AZ_CRC("LODMesh2", 0x52e3c936)) { name = "LODMesh2"; }
else if (type == AZ_CRC("LODMesh3", 0x25e4f9a0)) { name = "LODMesh3"; }
else if (type == AZ_CRC("LODMesh4", 0xbb806c03)) { name = "LODMesh4"; }
else if (type == AZ_CRC("LODMesh5", 0xcc875c95)) { name = "LODMesh5"; }
}
void LodRuleBehavior::GetAllVirtualTypes(AZStd::set<Crc32>& types)
{
AZStd::copy(s_lodVirtualTypeKeys.begin(), s_lodVirtualTypeKeys.end(), AZStd::inserter(types, types.begin()));
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,62 @@
/*
* 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 <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Components/BehaviorComponent.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
#include <SceneAPI/SceneCore/Events/GraphMetaInfoBus.h>
#include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
namespace AZ
{
namespace SceneAPI
{
namespace DataTypes
{
class IGroup;
class ISceneNodeSelectionList;
}
namespace SceneData
{
class LodRule;
class LodRuleBehavior
: public SceneCore::BehaviorComponent
, public Events::ManifestMetaInfoBus::Handler
, public Events::AssetImportRequestBus::Handler
, public Events::GraphMetaInfoBus::Handler
{
public:
AZ_COMPONENT(LodRuleBehavior, "{D2E19864-9A4B-41FD-8ACC-DA6756728CB3}", SceneCore::BehaviorComponent);
~LodRuleBehavior() override = default;
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* context);
void InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target) override;
Events::ProcessingResult UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication requester) override;
void GetVirtualTypeName(AZStd::string& name, Crc32 type) override;
void GetAllVirtualTypes(AZStd::set<Crc32>& types) override;
private:
size_t SelectLodMeshes(const Containers::Scene& scene, DataTypes::ISceneNodeSelectionList& selection, size_t lodLevel) const;
void UpdateLodRules(Containers::Scene& scene) const;
};
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,71 @@
/*
* 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/SerializeContext.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/Containers/Utilities/SceneGraphUtilities.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISceneNodeGroup.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMaterialData.h>
#include <SceneAPI/SceneData/Rules/MaterialRule.h>
#include <SceneAPI/SceneData/Behaviors/MaterialRuleBehavior.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
void MaterialRuleBehavior::Activate()
{
BusConnect();
}
void MaterialRuleBehavior::Deactivate()
{
BusDisconnect();
}
void MaterialRuleBehavior::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<MaterialRuleBehavior, BehaviorComponent>()->Version(1);
}
}
void MaterialRuleBehavior::InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target)
{
if (target.RTTI_IsTypeOf(DataTypes::ISceneNodeGroup::TYPEINFO_Uuid()))
{
DataTypes::ISceneNodeGroup* sceneNodeGroup = azrtti_cast<DataTypes::ISceneNodeGroup*>(&target);
// Note that other behaviors such as the physics can also add a material rule.
Containers::RuleContainer& rules = sceneNodeGroup->GetRuleContainer();
if (Utilities::DoesSceneGraphContainDataLike<DataTypes::IMaterialData>(scene, true) && !rules.ContainsRuleOfType<DataTypes::IMaterialRule>())
{
Events::ManifestMetaInfo::ModifiersList modifiers;
Events::ManifestMetaInfoBus::Broadcast(&Events::ManifestMetaInfo::GetAvailableModifiers, modifiers, scene, target);
if (AZStd::find(modifiers.begin(), modifiers.end(), azrtti_typeid<SceneData::MaterialRule>()) != modifiers.end())
{
rules.AddRule(AZStd::make_shared<SceneData::MaterialRule>());
}
}
}
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,46 @@
/*
* 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/Components/BehaviorComponent.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
namespace AZ
{
namespace SceneAPI
{
namespace DataTypes
{
class IGroup;
}
namespace SceneData
{
class MaterialRuleBehavior
: public SceneCore::BehaviorComponent
, public Events::ManifestMetaInfoBus::Handler
{
public:
AZ_COMPONENT(MaterialRuleBehavior, "{14FD7ECE-195D-46A7-85AB-135F77D757DC}", SceneCore::BehaviorComponent);
~MaterialRuleBehavior() override = default;
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* context);
void InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target) override;
};
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,217 @@
/*
* 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/SerializeContext.h>
#include <AzCore/std/algorithm.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/SceneManifest.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/IMeshGroup.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISceneNodeGroup.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkinGroup.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexUVData.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h>
#include <SceneAPI/SceneData/Rules/StaticMeshAdvancedRule.h>
#include <SceneAPI/SceneData/Rules/SkinMeshAdvancedRule.h>
#include <SceneAPI/SceneData/Behaviors/MeshAdvancedRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
void MeshAdvancedRule::Activate()
{
Events::ManifestMetaInfoBus::Handler::BusConnect();
Events::AssetImportRequestBus::Handler::BusConnect();
}
void MeshAdvancedRule::Deactivate()
{
Events::AssetImportRequestBus::Handler::BusDisconnect();
Events::ManifestMetaInfoBus::Handler::BusDisconnect();
}
void MeshAdvancedRule::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<MeshAdvancedRule, BehaviorComponent>()->Version(1);
}
}
void MeshAdvancedRule::InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target)
{
AZStd::string firstVertexColorStream = GetFirstVertexColorStream(scene);
if (target.RTTI_IsTypeOf(DataTypes::ISceneNodeGroup::TYPEINFO_Uuid()))
{
if (!firstVertexColorStream.empty())
{
if (target.RTTI_IsTypeOf(DataTypes::ISkinGroup::TYPEINFO_Uuid()))
{
AZStd::shared_ptr<SceneData::SkinMeshAdvancedRule> rule = AZStd::make_shared<SceneData::SkinMeshAdvancedRule>();
rule->SetVertexColorStreamName(firstVertexColorStream.empty() ?
DataTypes::s_advancedDisabledString : AZStd::move(firstVertexColorStream));
DataTypes::ISceneNodeGroup* sceneNodeGroup = azrtti_cast<DataTypes::ISceneNodeGroup*>(&target);
sceneNodeGroup->GetRuleContainer().AddRule(AZStd::move(rule));
}
else if (target.RTTI_IsTypeOf(DataTypes::IMeshGroup::TYPEINFO_Uuid()))
{
AZStd::shared_ptr<SceneData::StaticMeshAdvancedRule> rule = AZStd::make_shared<SceneData::StaticMeshAdvancedRule>();
rule->SetVertexColorStreamName(firstVertexColorStream.empty() ?
DataTypes::s_advancedDisabledString : AZStd::move(firstVertexColorStream));
DataTypes::ISceneNodeGroup* sceneNodeGroup = azrtti_cast<DataTypes::ISceneNodeGroup*>(&target);
sceneNodeGroup->GetRuleContainer().AddRule(AZStd::move(rule));
}
}
}
else if (target.RTTI_IsTypeOf(SceneData::StaticMeshAdvancedRule::TYPEINFO_Uuid()))
{
SceneData::StaticMeshAdvancedRule* rule = azrtti_cast<SceneData::StaticMeshAdvancedRule*>(&target);
rule->SetVertexColorStreamName(firstVertexColorStream.empty() ?
DataTypes::s_advancedDisabledString : AZStd::move(firstVertexColorStream));
}
else if (target.RTTI_IsTypeOf(SceneData::SkinMeshAdvancedRule::TYPEINFO_Uuid()))
{
SceneData::SkinMeshAdvancedRule* rule = azrtti_cast<SceneData::SkinMeshAdvancedRule*>(&target);
rule->SetVertexColorStreamName(firstVertexColorStream.empty() ?
DataTypes::s_advancedDisabledString : AZStd::move(firstVertexColorStream));
}
}
Events::ProcessingResult MeshAdvancedRule::UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication requester)
{
AZ_UNUSED(requester);
if (action == ManifestAction::Update)
{
UpdateMeshAdvancedRules(scene);
return Events::ProcessingResult::Success;
}
else
{
return Events::ProcessingResult::Ignored;
}
}
void MeshAdvancedRule::UpdateMeshAdvancedRules(Containers::Scene& scene) const
{
Containers::SceneManifest& manifest = scene.GetManifest();
auto valueStorage = manifest.GetValueStorage();
auto view = Containers::MakeDerivedFilterView<DataTypes::ISceneNodeGroup>(valueStorage);
for (DataTypes::ISceneNodeGroup& group : view)
{
AZ_TraceContext("Scene node group", group.GetName());
Containers::RuleContainer& rules = group.GetRuleContainer();
const size_t ruleCount = rules.GetRuleCount();
// The Mesh Advanced Rules were previously invalidly applied to any group containing a vertex color stream, and should be cleaned up if unnecessarily added to existing data.
// We use a list to track indices of rules to remove in a separate pass since the RuleContainer does not have direct iterator access.
bool isValidGroupType = group.RTTI_IsTypeOf(DataTypes::IMeshGroup::TYPEINFO_Uuid()) || group.RTTI_IsTypeOf(DataTypes::ISkinGroup::TYPEINFO_Uuid());
AZStd::vector<size_t> rulesToRemove;
for (size_t index = 0; index < ruleCount; ++index)
{
DataTypes::IMeshAdvancedRule* rule = azrtti_cast<DataTypes::IMeshAdvancedRule*>(rules.GetRule(index).get());
if (rule)
{
if (isValidGroupType)
{
UpdateMeshAdvancedRule(scene, rule);
}
else
{
rulesToRemove.push_back(index);
}
}
}
// Remove in reversed order, as otherwise the indices will be wrong. For example if we remove index 3, then index 6 would really be 5 afterwards.
// By doing this in reversed order we remove items at the end of the list first so it won't impact the indices of previous ones.
for (AZStd::vector<size_t>::reverse_iterator it = rulesToRemove.rbegin(); it != rulesToRemove.rend(); ++it)
{
rules.RemoveRule(*it);
}
}
}
void MeshAdvancedRule::UpdateMeshAdvancedRule(Containers::Scene& scene, DataTypes::IMeshAdvancedRule* rule) const
{
if (!rule)
{
return;
}
SceneData::SkinMeshAdvancedRule* skinRule = azrtti_cast<SceneData::SkinMeshAdvancedRule*>(rule);
SceneData::StaticMeshAdvancedRule* meshRule = azrtti_cast<SceneData::StaticMeshAdvancedRule*>(rule);
if (!(skinRule || meshRule))
{
return;
}
const AZStd::string& vertexColorStreamName = rule->GetVertexColorStreamName();
bool foundColorStream = vertexColorStreamName == DataTypes::s_advancedDisabledString;
const Containers::SceneGraph& graph = scene.GetGraph();
Containers::SceneGraph::NameStorageConstData graphNames = graph.GetNameStorage();
for (auto it = graphNames.begin(); it != graphNames.end(); ++it)
{
if (foundColorStream)
{
break;
}
const char* nodeName = it->GetName();
if (!foundColorStream && vertexColorStreamName == nodeName)
{
foundColorStream = true;
}
}
if (!foundColorStream)
{
AZStd::string newColorStreamName = GetFirstVertexColorStream(scene);
AZ_TracePrintf(Utilities::WarningWindow, "Old vertex color stream name not found so renamed from '%s' to '%s'.",
vertexColorStreamName.c_str(), newColorStreamName.c_str());
if (skinRule)
{
skinRule->SetVertexColorStreamName(newColorStreamName.empty() ? DataTypes::s_advancedDisabledString : AZStd::move(newColorStreamName));
}
else if (meshRule)
{
meshRule->SetVertexColorStreamName(newColorStreamName.empty() ? DataTypes::s_advancedDisabledString : AZStd::move(newColorStreamName));
}
}
}
AZStd::string MeshAdvancedRule::GetFirstVertexColorStream(const Containers::Scene& scene) const
{
const Containers::SceneGraph& graph = scene.GetGraph();
Containers::SceneGraph::ContentStorageConstData graphContent = graph.GetContentStorage();
auto vertexColorData = AZStd::find_if(graphContent.begin(), graphContent.end(),
Containers::DerivedTypeFilter<DataTypes::IMeshVertexColorData>());
if (vertexColorData != graphContent.end())
{
return graph.GetNodeName(graph.ConvertToNodeIndex(vertexColorData)).GetName();
}
else
{
return AZStd::string();
}
}
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,59 @@
/*
* 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/Components/BehaviorComponent.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace SceneAPI
{
namespace DataTypes
{
class IMeshAdvancedRule;
}
namespace Behaviors
{
class MeshAdvancedRule
: public SceneCore::BehaviorComponent
, public Events::ManifestMetaInfoBus::Handler
, public Events::AssetImportRequestBus::Handler
{
public:
AZ_COMPONENT(MeshAdvancedRule, "{4217B46E-87A6-438E-8ACE-0397828AE889}", SceneCore::BehaviorComponent);
~MeshAdvancedRule() override = default;
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* context);
void InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target) override;
Events::ProcessingResult UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication requester) override;
private:
void UpdateMeshAdvancedRules(Containers::Scene& scene) const;
void UpdateMeshAdvancedRule(Containers::Scene& scene, DataTypes::IMeshAdvancedRule* rule) const;
AZStd::string GetFirstVertexColorStream(const Containers::Scene& scene) const;
};
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,54 @@
#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 <SceneAPI/SceneCore/Components/BehaviorComponent.h>
#include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
class MeshGroup
: public SceneCore::BehaviorComponent
, public Events::ManifestMetaInfoBus::Handler
, public Events::AssetImportRequestBus::Handler
{
public:
AZ_COMPONENT(MeshGroup, "{52DD90C2-81F5-4763-AC64-6DB2294BE50A}", SceneCore::BehaviorComponent);
~MeshGroup() override = default;
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* context);
void GetCategoryAssignments(CategoryRegistrationList& categories, const Containers::Scene& scene) override;
void InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target) override;
Events::ProcessingResult UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication requester) override;
private:
Events::ProcessingResult BuildDefault(Containers::Scene& scene) const;
Events::ProcessingResult UpdateMeshGroups(Containers::Scene& scene) const;
bool SceneHasMeshGroup(const Containers::Scene& scene) const;
static const int s_meshGroupPreferredTabOrder;
};
} // Behaviors
} // SceneAPI
} // AZ
@@ -0,0 +1,48 @@
/*
* 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/Component/ComponentApplicationBus.h>
#include <SceneAPI/SceneData/Behaviors/Registry.h>
#include <SceneAPI/SceneData/Behaviors/AnimationGroup.h>
#include <SceneAPI/SceneData/Behaviors/BlendShapeRuleBehavior.h>
#include <SceneAPI/SceneData/Behaviors/LodRuleBehavior.h>
#include <SceneAPI/SceneData/Behaviors/MaterialRuleBehavior.h>
#include <SceneAPI/SceneData/Behaviors/MeshAdvancedRule.h>
#include <SceneAPI/SceneData/Behaviors/MeshGroup.h>
#include <SceneAPI/SceneData/Behaviors/ScriptProcessorRuleBehavior.h>
#include <SceneAPI/SceneData/Behaviors/SkeletonGroup.h>
#include <SceneAPI/SceneData/Behaviors/SkinGroup.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
void Registry::RegisterComponents(ComponentDescriptorList& components)
{
components.insert(components.end(),
{
Behaviors::AnimationGroup::CreateDescriptor(),
BlendShapeRuleBehavior::CreateDescriptor(),
LodRuleBehavior::CreateDescriptor(),
MaterialRuleBehavior::CreateDescriptor(),
Behaviors::MeshAdvancedRule::CreateDescriptor(),
Behaviors::MeshGroup::CreateDescriptor(),
Behaviors::ScriptProcessorRuleBehavior::CreateDescriptor(),
Behaviors::SkeletonGroup::CreateDescriptor(),
Behaviors::SkinGroup::CreateDescriptor()
});
}
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,37 @@
/*
* 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 <AzCore/Memory/Memory.h>
#include <AzCore/Memory/SystemAllocator.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace SceneData
{
class Registry
{
public:
using ComponentDescriptorList = AZStd::vector<AZ::ComponentDescriptor*>;
AZ_CLASS_ALLOCATOR(Registry, SystemAllocator, 0)
static void RegisterComponents(ComponentDescriptorList& components);
};
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,205 @@
/*
* 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 <SceneAPI/SceneData/Behaviors/ScriptProcessorRuleBehavior.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <AzFramework/Asset/AssetSystemComponent.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/API/EditorPythonConsoleBus.h>
#include <AzToolsFramework/API/EditorPythonRunnerRequestsBus.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/SceneManifest.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/Containers/Views/FilterIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
#include <SceneAPI/SceneData/Rules/ScriptProcessorRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
// a event bus to signal during scene building
struct ScriptBuildingNotifications
: public AZ::EBusTraits
{
virtual AZStd::string OnUpdateManifest(Containers::Scene& scene) = 0;
};
using ScriptBuildingNotificationBus = AZ::EBus<ScriptBuildingNotifications>;
// a back end to handle scene builder events for a script
struct ScriptBuildingNotificationBusHandler final
: public ScriptBuildingNotificationBus::Handler
, public AZ::BehaviorEBusHandler
{
AZ_EBUS_BEHAVIOR_BINDER(
ScriptBuildingNotificationBusHandler,
"{DF2B51DE-A4D0-4139-B5D0-DF185832380D}",
AZ::SystemAllocator,
OnUpdateManifest);
virtual ~ScriptBuildingNotificationBusHandler() = default;
AZStd::string OnUpdateManifest(Containers::Scene& scene) override
{
AZStd::string result;
CallResult(result, FN_OnUpdateManifest, scene);
return result;
}
static void Reflect(AZ::ReflectContext* context)
{
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<ScriptBuildingNotificationBus>("ScriptBuildingNotificationBus")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "scene")
->Handler<ScriptBuildingNotificationBusHandler>()
->Event("OnUpdateManifest", &ScriptBuildingNotificationBus::Events::OnUpdateManifest);
}
}
};
void ScriptProcessorRuleBehavior::Activate()
{
Events::AssetImportRequestBus::Handler::BusConnect();
}
void ScriptProcessorRuleBehavior::Deactivate()
{
Events::AssetImportRequestBus::Handler::BusDisconnect();
if (m_editorPythonEventsInterface)
{
const bool silenceWarnings = true;
m_editorPythonEventsInterface->StopPython(silenceWarnings);
m_editorPythonEventsInterface = nullptr;
}
}
void ScriptProcessorRuleBehavior::Reflect(ReflectContext* context)
{
ScriptBuildingNotificationBusHandler::Reflect(context);
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<ScriptProcessorRuleBehavior, BehaviorComponent>()->Version(1);
}
}
Events::ProcessingResult ScriptProcessorRuleBehavior::UpdateManifest(
Containers::Scene& scene,
Events::AssetImportRequest::ManifestAction action,
[[maybe_unused]] Events::AssetImportRequest::RequestingApplication requester)
{
using namespace AzToolsFramework;
if (action != ManifestAction::Update)
{
return Events::ProcessingResult::Ignored;
}
// get project folder
auto settingsRegistry = AZ::SettingsRegistry::Get();
AZ::IO::FixedMaxPath projectPath;
if (!settingsRegistry->Get(projectPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_SourceGameFolder))
{
return Events::ProcessingResult::Ignored;
}
auto& sceneManifest = scene.GetManifest();
auto view = Containers::MakeDerivedFilterView<DataTypes::IScriptProcessorRule>(sceneManifest.GetValueStorage());
for (const auto& scriptItem : view)
{
AZ::IO::FixedMaxPath scriptFilename(scriptItem.GetScriptFilename());
if (scriptFilename.empty())
{
AZ_Warning("scene", false, "Skipping an empty script filename in (%s)", scene.GetManifestFilename().c_str());
continue;
}
// check for file exist via absolute path
if (!IO::FileIOBase::GetInstance()->Exists(scriptFilename.c_str()))
{
// check for script in the project folder
AZ::IO::FixedMaxPath projectScriptPath = projectPath / scriptFilename;
if (!IO::FileIOBase::GetInstance()->Exists(projectScriptPath.c_str()))
{
AZ_Warning("scene", false, "Skipping a missing script (%s) in manifest file (%s)",
scriptFilename.c_str(),
scene.GetManifestFilename().c_str());
continue;
}
scriptFilename = AZStd::move(projectScriptPath);
}
// lazy load the Python interface
if (!m_editorPythonEventsInterface)
{
m_editorPythonEventsInterface = AZ::Interface<AzToolsFramework::EditorPythonEventsInterface>::Get();
const bool silenceWarnings = true;
m_editorPythonEventsInterface->StartPython(silenceWarnings);
}
if (!m_editorPythonEventsInterface && !scriptFilename.empty())
{
AZ_Warning("scene", false,
"The scene manifest (%s) attempted to use script(%s) but Python is not enabled;"
"please add the EditorPythonBinding gem & PythonAssetBuilder gem to your project.",
scene.GetManifestFilename().c_str(), scriptFilename.c_str());
return Events::ProcessingResult::Ignored;
}
AZStd::string manifestUpdate;
auto executeCallback = [&scene, &scriptFilename, &manifestUpdate]()
{
EditorPythonRunnerRequestBus::Broadcast(
&EditorPythonRunnerRequestBus::Events::ExecuteByFilename,
scriptFilename.c_str());
ScriptBuildingNotificationBus::BroadcastResult(
manifestUpdate,
&ScriptBuildingNotificationBus::Events::OnUpdateManifest,
scene);
};
m_editorPythonEventsInterface->ExecuteWithLock(executeCallback);
// attempt to load the manifest string back to a JSON-scene-manifest
auto sceneManifestLoader = AZStd::make_unique<AZ::SceneAPI::Containers::SceneManifest>();
auto loadOutcome = sceneManifestLoader->LoadFromString(manifestUpdate);
if (loadOutcome.IsSuccess())
{
sceneManifest.Clear();
for (size_t entryIndex = 0; entryIndex < sceneManifestLoader->GetEntryCount(); ++entryIndex)
{
sceneManifest.AddEntry(sceneManifestLoader->GetValue(entryIndex));
}
return Events::ProcessingResult::Success;
}
}
return Events::ProcessingResult::Ignored;
}
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,54 @@
/*
* 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 <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Components/BehaviorComponent.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AzToolsFramework
{
class EditorPythonEventsInterface;
}
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
class ScriptProcessorRuleBehavior
: public SceneCore::BehaviorComponent
, public Events::AssetImportRequestBus::Handler
{
public:
AZ_COMPONENT(ScriptProcessorRuleBehavior, "{24054E73-1B92-43B0-AC13-174B2F0E3F66}", SceneCore::BehaviorComponent);
~ScriptProcessorRuleBehavior() override = default;
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* context);
// AssetImportRequestBus::Handler
Events::ProcessingResult UpdateManifest(
Containers::Scene& scene,
ManifestAction action,
RequestingApplication requester) override;
private:
AzToolsFramework::EditorPythonEventsInterface* m_editorPythonEventsInterface = nullptr;
};
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,55 @@
/*
* 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/Components/BehaviorComponent.h>
#include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
class SkeletonGroup
: public SceneCore::BehaviorComponent
, public Events::ManifestMetaInfoBus::Handler
, public Events::AssetImportRequestBus::Handler
{
public:
AZ_COMPONENT(SkeletonGroup, "{9243A4BA-46BD-4961-950F-DEFAE9A919E5}", SceneCore::BehaviorComponent);
~SkeletonGroup() override = default;
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* context);
void GetCategoryAssignments(CategoryRegistrationList& categories, const Containers::Scene& scene) override;
void InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target) override;
Events::ProcessingResult UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication requester) override;
private:
Events::ProcessingResult BuildDefault(Containers::Scene& scene);
Events::ProcessingResult UpdateSkeletonGroups(Containers::Scene& scene) const;
bool SceneHasSkeletonGroup(const Containers::Scene& scene) const;
static const int s_rigsPreferredTabOrder;
bool m_isDefaultConstructing{ false };
};
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,64 @@
/*
* 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/Components/BehaviorComponent.h>
#include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
#include <SceneAPI/SceneCore/Events/GraphMetaInfoBus.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace SceneAPI
{
namespace Behaviors
{
class SkinGroup
: public SceneCore::BehaviorComponent
, public Events::ManifestMetaInfoBus::Handler
, public Events::GraphMetaInfoBus::Handler
, public Events::AssetImportRequestBus::Handler
{
public:
AZ_COMPONENT(SkinGroup, "{348566F7-7113-4CEB-ADF8-C1CC686CD3BD}", SceneCore::BehaviorComponent);
static Crc32 s_skinVirtualType;
static const char* s_skinVirtualTypeName;
~SkinGroup() override = default;
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* context);
void GetCategoryAssignments(CategoryRegistrationList& categories, const Containers::Scene& scene) override;
void InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target) override;
Events::ProcessingResult UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication requester) override;
void GetVirtualTypes(AZStd::set<Crc32>& types, const Containers::Scene& scene,
Containers::SceneGraph::NodeIndex node) override;
void GetAllVirtualTypes(AZStd::set<Crc32>& types) override;
void GetVirtualTypeName(AZStd::string& name, Crc32 type) override;
private:
Events::ProcessingResult BuildDefault(Containers::Scene& scene) const;
Events::ProcessingResult UpdateGroups(Containers::Scene& scene) const;
bool SceneHasSkinGroup(const Containers::Scene& scene) const;
static const int s_rigsPreferredTabOrder;
};
} // namespace Behaviors
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,55 @@
#
# 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.
#
if (NOT PAL_TRAIT_BUILD_HOST_TOOLS)
return()
endif()
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
ly_add_target(
NAME SceneData SHARED
NAMESPACE AZ
FILES_CMAKE
SceneData_files.cmake
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
COMPILE_DEFINITIONS
PRIVATE
SCENE_DATA_EXPORTS
INCLUDE_DIRECTORIES
PUBLIC
../..
BUILD_DEPENDENCIES
PRIVATE
AZ::AzCore
AZ::AzFramework
AZ::AzToolsFramework
AZ::SceneCore
)
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
ly_add_target(
NAME SceneData.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE AZ
FILES_CMAKE
SceneData_testing_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Tests
BUILD_DEPENDENCIES
PRIVATE
AZ::AzTest
AZ::SceneData
)
ly_add_googletest(
NAME AZ::SceneData.Tests
)
endif()
+158
View File
@@ -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.
*
*/
#if !defined(AZ_MONOLITHIC_BUILD)
#include <AzCore/Component/Component.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Module/Environment.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <SceneAPI/SceneData/ManifestMetaInfoHandler.h>
#include <SceneAPI/SceneData/ReflectionRegistrar.h>
#include <SceneAPI/SceneData/Behaviors/Registry.h>
namespace AZ {
namespace SceneAPI {
namespace SceneData {
static AZ::SceneAPI::SceneData::ManifestMetaInfoHandler* g_manifestMetaInfoHandler = nullptr;
static AZ::SceneAPI::SceneData::Registry::ComponentDescriptorList g_componentDescriptors;
static AZ::BehaviorContext* g_behaviorContext = nullptr;
void Initialize()
{
if (!g_manifestMetaInfoHandler)
{
g_manifestMetaInfoHandler = aznew AZ::SceneAPI::SceneData::ManifestMetaInfoHandler();
}
}
void Reflect(AZ::SerializeContext* context)
{
if (!context)
{
EBUS_EVENT_RESULT(context, AZ::ComponentApplicationBus, GetSerializeContext);
}
if (context)
{
AZ::SceneAPI::RegisterDataTypeReflection(context);
}
// Descriptor registration is done in Reflect instead of Initialize because the ResourceCompilerScene initializes the libraries before
// there's an application.
if (g_componentDescriptors.empty())
{
AZ::SceneAPI::SceneData::Registry::RegisterComponents(g_componentDescriptors);
for (AZ::ComponentDescriptor* descriptor : g_componentDescriptors)
{
AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Handler::RegisterComponentDescriptor, descriptor);
}
}
}
void ReflectBehavior(AZ::BehaviorContext* context)
{
if (!g_behaviorContext)
{
// Reflect instead of Initialize because ResourceCompilerScene initializes the libraries before there's an application
if (context)
{
g_behaviorContext = context;
AZ::SceneAPI::RegisterDataTypeBehaviorReflection(g_behaviorContext);
}
}
}
void Activate()
{
}
void Deactivate()
{
}
void Uninitialize()
{
AZ::SerializeContext* context = nullptr;
EBUS_EVENT_RESULT(context, AZ::ComponentApplicationBus, GetSerializeContext);
if (context)
{
context->EnableRemoveReflection();
Reflect(context);
context->DisableRemoveReflection();
context->CleanupModuleGenericClassInfo();
}
if (!g_componentDescriptors.empty())
{
for (AZ::ComponentDescriptor* descriptor : g_componentDescriptors)
{
descriptor->ReleaseDescriptor();
}
g_componentDescriptors.clear();
g_componentDescriptors.shrink_to_fit();
}
delete g_manifestMetaInfoHandler;
g_manifestMetaInfoHandler = nullptr;
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
extern "C" AZ_DLL_EXPORT void InitializeDynamicModule(void* env)
{
if (AZ::Environment::IsReady())
{
return;
}
AZ::Environment::Attach(static_cast<AZ::EnvironmentInstance>(env));
AZ::SceneAPI::SceneData::Initialize();
}
extern "C" AZ_DLL_EXPORT void Reflect(AZ::SerializeContext* context)
{
AZ::SceneAPI::SceneData::Reflect(context);
}
extern "C" AZ_DLL_EXPORT void ReflectBehavior(AZ::BehaviorContext * context)
{
AZ::SceneAPI::SceneData::ReflectBehavior(context);
}
extern "C" AZ_DLL_EXPORT void UninitializeDynamicModule()
{
if (!AZ::Environment::IsReady())
{
return;
}
AZ::SceneAPI::SceneData::Uninitialize();
// This module does not own these allocators, but must clear its cached EnvironmentVariables
// because it is linked into other modules, and thus does not get unloaded from memory always
if (AZ::AllocatorInstance<AZ::SystemAllocator>::IsReady())
{
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
}
if (AZ::AllocatorInstance<AZ::OSAllocator>::IsReady())
{
AZ::AllocatorInstance<AZ::OSAllocator>::Destroy();
}
AZ::Environment::Detach();
}
#endif // !defined(AZ_MONOLITHIC_BUILD)
@@ -0,0 +1,118 @@
/*
* 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 <SceneAPI/SceneData/GraphData/AnimationData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
AnimationData::AnimationData()
: m_timeStepBetweenFrames(1.0/30.0) // default value
{
}
void AnimationData::AddKeyFrame(const SceneAPI::DataTypes::MatrixType& keyFrameTransform)
{
m_keyFrames.push_back(keyFrameTransform);
}
void AnimationData::ReserveKeyFrames(size_t count)
{
m_keyFrames.reserve(count);
}
void AnimationData::SetTimeStepBetweenFrames(double timeStep)
{
m_timeStepBetweenFrames = timeStep;
}
size_t AnimationData::GetKeyFrameCount() const
{
return m_keyFrames.size();
}
const SceneAPI::DataTypes::MatrixType& AnimationData::GetKeyFrame(size_t index) const
{
AZ_Assert(index < m_keyFrames.size(), "GetTranslationKeyFrame index %i is out of range for frame size %i", index, m_keyFrames.size());
return m_keyFrames[index];
}
double AnimationData::GetTimeStepBetweenFrames() const
{
return m_timeStepBetweenFrames;
}
void AnimationData::GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("KeyFrames", m_keyFrames);
output.Write("TimeStepBetweenFrames", m_timeStepBetweenFrames);
}
BlendShapeAnimationData::BlendShapeAnimationData()
: m_timeStepBetweenFrames(1 / 30.0) // default value
{
}
void BlendShapeAnimationData::SetBlendShapeName(const char* blendShapeName)
{
m_blendShapeName = blendShapeName;
}
void BlendShapeAnimationData::AddKeyFrame(double keyFrameValue)
{
m_keyFrames.push_back(keyFrameValue);
}
void BlendShapeAnimationData::ReserveKeyFrames(size_t count)
{
m_keyFrames.reserve(count);
}
void BlendShapeAnimationData::SetTimeStepBetweenFrames(double timeStep)
{
m_timeStepBetweenFrames = timeStep;
}
const char* BlendShapeAnimationData::GetBlendShapeName() const
{
return m_blendShapeName.c_str();
}
size_t BlendShapeAnimationData::GetKeyFrameCount() const
{
return m_keyFrames.size();
}
double BlendShapeAnimationData::GetKeyFrame(size_t index) const
{
AZ_Assert(index < m_keyFrames.size(), "BlendShapeAnimationData::GetKeyFrame index %i is out of range for frame count %i", index, m_keyFrames.size());
return m_keyFrames[index];
}
double BlendShapeAnimationData::GetTimeStepBetweenFrames() const
{
return m_timeStepBetweenFrames;
}
void BlendShapeAnimationData::GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("BlendShapeName", m_blendShapeName);
output.Write("KeyFrames", m_keyFrames);
output.Write("TimeStepBetweenFrames", m_timeStepBetweenFrames);
}
}
}
}
@@ -0,0 +1,77 @@
#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/std/string/string.h>
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IAnimationData.h>
#include <SceneAPI/SceneCore/DataTypes/MatrixType.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS AnimationData
: public SceneAPI::DataTypes::IAnimationData
{
public:
AZ_RTTI(AnimationData, "{D350732E-4727-41C8-95E0-FBAF5F2AC074}", SceneAPI::DataTypes::IAnimationData);
SCENE_DATA_API AnimationData();
SCENE_DATA_API ~AnimationData() override = default;
SCENE_DATA_API virtual void AddKeyFrame(const SceneAPI::DataTypes::MatrixType& keyFrameTransform);
SCENE_DATA_API virtual void ReserveKeyFrames(size_t count);
SCENE_DATA_API virtual void SetTimeStepBetweenFrames(double timeStep);
SCENE_DATA_API size_t GetKeyFrameCount() const override;
SCENE_DATA_API const SceneAPI::DataTypes::MatrixType& GetKeyFrame(size_t index) const override;
SCENE_DATA_API double GetTimeStepBetweenFrames() const override;
SCENE_DATA_API void GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<SceneAPI::DataTypes::MatrixType> m_keyFrames;
double m_timeStepBetweenFrames;
};
class BlendShapeAnimationData
: public SceneAPI::DataTypes::IBlendShapeAnimationData
{
public:
AZ_RTTI(BlendShapeAnimationData, "{02766CCF-BDA7-46B6-9BB1-58A90C1AD6AA}", SceneAPI::DataTypes::IBlendShapeAnimationData);
SCENE_DATA_API BlendShapeAnimationData();
SCENE_DATA_API ~BlendShapeAnimationData() override = default;
SCENE_DATA_API virtual void SetBlendShapeName(const char* name);
SCENE_DATA_API virtual void AddKeyFrame(double keyFrameValue);
SCENE_DATA_API virtual void ReserveKeyFrames(size_t count);
SCENE_DATA_API virtual void SetTimeStepBetweenFrames(double timeStep);
SCENE_DATA_API const char* GetBlendShapeName() const override;
SCENE_DATA_API size_t GetKeyFrameCount() const override;
SCENE_DATA_API double GetKeyFrame(size_t index) const override;
SCENE_DATA_API double GetTimeStepBetweenFrames() const override;
SCENE_DATA_API void GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::string m_blendShapeName;
AZStd::vector<double> m_keyFrames;
double m_timeStepBetweenFrames;
};
}
}
}
@@ -0,0 +1,110 @@
/*
* 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/Casting/numeric_cast.h>
#include <SceneAPI/SceneData/GraphData/BlendShapeData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
namespace DataTypes = SceneAPI::DataTypes;
BlendShapeData::~BlendShapeData() = default;
unsigned int BlendShapeData::AddVertex(const Vector3& position, const Vector3& normal)
{
m_positions.push_back(position);
m_normals.push_back(normal);
return static_cast<unsigned int>(m_positions.size()-1);
}
void BlendShapeData::AddFace(const Face& face)
{
m_faces.push_back(face);
}
void BlendShapeData::SetVertexIndexToControlPointIndexMap(int vertexIndex, int controlPointIndex)
{
m_vertexIndexToControlPointIndexMap[vertexIndex] = controlPointIndex;
// The above hashmap stores the control point index (value) per vertex (key).
// We construct an unordered set and fill in the control point indices in order to get access to the number of unique control points indices.
m_controlPointToUsedVertexIndexMap.emplace(controlPointIndex, aznumeric_cast<unsigned int>(m_controlPointToUsedVertexIndexMap.size()));
}
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);
// Note: AZStd::unordered_map's operator [] doesn't have const version...
return iter->second;
}
size_t BlendShapeData::GetUsedControlPointCount() const
{
return m_controlPointToUsedVertexIndexMap.size();
}
int BlendShapeData::GetUsedPointIndexForControlPoint(int controlPointIndex) const
{
auto iter = m_controlPointToUsedVertexIndexMap.find(controlPointIndex);
if (iter != m_controlPointToUsedVertexIndexMap.end())
{
return iter->second;
}
else
{
return -1; // That control point is not used in this mesh
}
}
unsigned int BlendShapeData::GetVertexCount() const
{
return static_cast<unsigned int>(m_positions.size());
}
unsigned int BlendShapeData::GetFaceCount() const
{
return static_cast<unsigned int>(m_faces.size());
}
const Vector3& BlendShapeData::GetPosition(unsigned int index) const
{
AZ_Assert(index < m_positions.size(), "GetPosition index not in range");
return m_positions[index];
}
const Vector3& BlendShapeData::GetNormal(unsigned int index) const
{
AZ_Assert(index < m_normals.size(), "GetNormal index not in range");
return m_normals[index];
}
unsigned int BlendShapeData::GetFaceVertexIndex(unsigned int face, unsigned int vertexIndex) const
{
AZ_Assert(face < m_faces.size(), "GetFaceVertexPositionIndex face index not in range");
AZ_Assert(vertexIndex < 3, "GetFaceVertexPositionIndex vertexIndex index not in range");
return m_faces[face].vertexIndex[vertexIndex];
}
void BlendShapeData::GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("Positions", m_positions);
output.Write("Normals", m_normals);
output.Write("Faces", m_faces);
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,66 @@
#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/std/containers/vector.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IBlendShapeData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS BlendShapeData
: public SceneAPI::DataTypes::IBlendShapeData
{
public:
AZ_RTTI(BlendShapeData, "{FF875C22-2E4F-4CE3-BA49-09BF78C70A09}", SceneAPI::DataTypes::IBlendShapeData)
SCENE_DATA_API ~BlendShapeData() override;
SCENE_DATA_API virtual unsigned int AddVertex(const Vector3& position, const Vector3& normal);
//assume consistent winding - no stripping or fanning expected (3 index per face)
SCENE_DATA_API virtual void AddFace(const Face& face);
SCENE_DATA_API void SetVertexIndexToControlPointIndexMap(int vertexIndex, int controlPointIndex);
SCENE_DATA_API size_t GetUsedControlPointCount() const override;
SCENE_DATA_API int GetControlPointIndex(int vertexIndex) const override;
SCENE_DATA_API int GetUsedPointIndexForControlPoint(int controlPointIndex) const override;
//assume consistent winding - no stripping or fanning expected (3 index per face)
SCENE_DATA_API unsigned int GetVertexCount() const override;
SCENE_DATA_API unsigned int GetFaceCount() const override;
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 unsigned int GetFaceVertexIndex(unsigned int face, unsigned int vertexIndex) const override;
SCENE_DATA_API void GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<Vector3> m_positions;
AZStd::vector<Vector3> m_normals;
AZStd::vector<Face> m_faces;
AZStd::unordered_map<int, int> m_vertexIndexToControlPointIndexMap;
AZStd::unordered_map<int, int> m_controlPointToUsedVertexIndexMap;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,51 @@
/*
* 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 <SceneAPI/SceneData/GraphData/BoneData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
void BoneData::SetWorldTransform(const SceneAPI::DataTypes::MatrixType& transform)
{
m_worldTransform = transform;
}
const SceneAPI::DataTypes::MatrixType& BoneData::GetWorldTransform() const
{
return m_worldTransform;
}
void BoneData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<BoneData>()->Version(1)
->Field("worldTransform", &BoneData::m_worldTransform);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<BoneData>("Bone data", "Data this individual bone contributes to the overall skeleton.")
->DataElement(AZ::Edit::UIHandlers::Default, &BoneData::m_worldTransform, "World", "World transform this bone contributes to the overall skeleton.");
}
}
}
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,42 @@
/*
* 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/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IBoneData.h>
namespace AZ
{
class ReflectContext;
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS BoneData
: public AZ::SceneAPI::DataTypes::IBoneData
{
public:
AZ_RTTI(BoneData, "{EDFB7CDB-DA39-41F1-800D-1E10421849E5}", AZ::SceneAPI::DataTypes::IBoneData);
SCENE_DATA_API void SetWorldTransform(const SceneAPI::DataTypes::MatrixType& transform);
SCENE_DATA_API const SceneAPI::DataTypes::MatrixType& GetWorldTransform() const override;
static void Reflect(ReflectContext* context);
protected:
SceneAPI::DataTypes::MatrixType m_worldTransform;
};
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,192 @@
/*
* 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 <SceneAPI/SceneData/GraphData/MaterialData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
namespace DataTypes = AZ::SceneAPI::DataTypes;
const AZStd::string MaterialData::s_DiffuseMapName = "Diffuse";
const AZStd::string MaterialData::s_SpecularMapName = "Specular";
const AZStd::string MaterialData::s_BumpMapName = "Bump";
const AZStd::string MaterialData::s_emptyString = "";
MaterialData::MaterialData()
: m_isNoDraw(false)
, m_diffuseColor(AZ::Vector3::CreateOne())
, m_specularColor(AZ::Vector3::CreateZero())
, m_emissiveColor(AZ::Vector3::CreateZero())
, m_opacity(1.f)
, m_shininess(10.f)
{
}
void MaterialData::SetMaterialName(AZStd::string materialName)
{
m_materialName = AZStd::move(materialName);
}
const AZStd::string& MaterialData::GetMaterialName() const
{
return m_materialName;
}
void MaterialData::SetTexture(TextureMapType mapType, const char* textureFileName)
{
if (textureFileName)
{
SetTexture(mapType, AZStd::string(textureFileName));
}
}
void MaterialData::SetTexture(TextureMapType mapType, const AZStd::string& textureFileName)
{
SetTexture(mapType, AZStd::string(textureFileName));
}
void MaterialData::SetTexture(TextureMapType mapType, AZStd::string&& textureFileName)
{
if (!textureFileName.empty())
{
m_textureMap[mapType] = AZStd::move(textureFileName);
}
}
const AZStd::string& MaterialData::GetTexture(TextureMapType mapType) const
{
auto result = m_textureMap.find(mapType);
if (result != m_textureMap.end())
{
return result->second;
}
return s_emptyString;
}
void MaterialData::SetNoDraw(bool isNoDraw)
{
m_isNoDraw = isNoDraw;
}
bool MaterialData::IsNoDraw() const
{
return m_isNoDraw;
}
void MaterialData::SetDiffuseColor(const AZ::Vector3& color)
{
m_diffuseColor = color;
}
void MaterialData::SetUniqueId(uint64_t uid)
{
m_uniqueId = uid;
}
const AZ::Vector3& MaterialData:: GetDiffuseColor() const
{
return m_diffuseColor;
}
void MaterialData::SetSpecularColor(const AZ::Vector3& color)
{
m_specularColor = color;
}
const AZ::Vector3& MaterialData::GetSpecularColor() const
{
return m_specularColor;
}
void MaterialData::SetEmissiveColor(const AZ::Vector3& color)
{
m_emissiveColor = color;
}
const AZ::Vector3& MaterialData::GetEmissiveColor() const
{
return m_emissiveColor;
}
void MaterialData::SetOpacity(float opacity)
{
m_opacity = opacity;
}
float MaterialData::GetOpacity() const
{
return m_opacity;
}
void MaterialData::SetShininess(float shininess)
{
m_shininess = shininess;
}
float MaterialData::GetShininess() const
{
return m_shininess;
}
uint64_t MaterialData::GetUniqueId() const
{
return m_uniqueId;
}
void MaterialData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<MaterialData>()->Version(2)
->Field("textureMap", &MaterialData::m_textureMap)
->Field("diffuseColor", &MaterialData::m_diffuseColor)
->Field("specularColor", &MaterialData::m_specularColor)
->Field("emissiveColor", &MaterialData::m_emissiveColor)
->Field("opacity", &MaterialData::m_opacity)
->Field("shininess", &MaterialData::m_shininess)
->Field("noDraw", &MaterialData::m_isNoDraw)
->Field("uniqueId", &MaterialData::m_uniqueId);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<MaterialData>("Materials", "Material configuration for the parent.")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_diffuseColor, "Diffuse", "Diffuse color component of the material.")
->Attribute(Edit::Attributes::LabelForX, "R")
->Attribute(Edit::Attributes::LabelForY, "G")
->Attribute(Edit::Attributes::LabelForZ, "B")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_specularColor, "Specular", "Specular color component of the material.")
->Attribute(Edit::Attributes::LabelForX, "R")
->Attribute(Edit::Attributes::LabelForY, "G")
->Attribute(Edit::Attributes::LabelForZ, "B")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_emissiveColor, "Emissive", "Emissive color component of the material.")
->Attribute(Edit::Attributes::LabelForX, "R")
->Attribute(Edit::Attributes::LabelForY, "G")
->Attribute(Edit::Attributes::LabelForZ, "B")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_opacity, "Opacity", "Opacity strength of the material, with 0 fully transparent and 1 fully opaque.")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_shininess, "Shininess", "The shininess strength of the material.")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_isNoDraw, "No draw", "If enabled the mesh with material will not be drawn.")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_textureMap, "Texture map", "List of assigned texture slots.");
}
}
}
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,88 @@
/*
* 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/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMaterialData.h>
#include <AzCore/std/containers/unordered_map.h>
namespace AZ
{
class ReflectContext;
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS MaterialData
: public AZ::SceneAPI::DataTypes::IMaterialData
{
public:
AZ_RTTI(MaterialData, "{F2EE1768-183B-483E-9778-CB3D3D0DA68A}", AZ::SceneAPI::DataTypes::IMaterialData)
SCENE_DATA_API MaterialData();
SCENE_DATA_API virtual ~MaterialData() = default;
SCENE_DATA_API void SetMaterialName(AZStd::string materialName);
SCENE_DATA_API const AZStd::string& GetMaterialName() const override;
SCENE_DATA_API virtual void SetTexture(TextureMapType mapType, const char* textureFileName);
SCENE_DATA_API virtual void SetTexture(TextureMapType mapType, const AZStd::string& textureFileName);
SCENE_DATA_API virtual void SetTexture(TextureMapType mapType, AZStd::string&& textureFileName);
SCENE_DATA_API virtual void SetNoDraw(bool isNoDraw);
SCENE_DATA_API virtual void SetDiffuseColor(const AZ::Vector3& color);
SCENE_DATA_API virtual void SetSpecularColor(const AZ::Vector3& color);
SCENE_DATA_API virtual void SetEmissiveColor(const AZ::Vector3& color);
SCENE_DATA_API virtual void SetOpacity(float opacity);
SCENE_DATA_API virtual void SetShininess(float shininess);
SCENE_DATA_API virtual void SetUniqueId(uint64_t uid);
SCENE_DATA_API const AZStd::string& GetTexture(TextureMapType mapType) const override;
SCENE_DATA_API bool IsNoDraw() const override;
SCENE_DATA_API const AZ::Vector3& GetDiffuseColor() const override;
SCENE_DATA_API const AZ::Vector3& GetSpecularColor() const override;
SCENE_DATA_API const AZ::Vector3& GetEmissiveColor() const override;
SCENE_DATA_API float GetOpacity() const override;
SCENE_DATA_API float GetShininess() const override;
SCENE_DATA_API uint64_t GetUniqueId() const override;
static void Reflect(ReflectContext* context);
protected:
AZStd::unordered_map<TextureMapType, AZStd::string> m_textureMap;
AZ::Vector3 m_diffuseColor;
AZ::Vector3 m_specularColor;
AZ::Vector3 m_emissiveColor;
float m_opacity;
float m_shininess;
bool m_isNoDraw;
const static AZStd::string s_DiffuseMapName;
const static AZStd::string s_SpecularMapName;
const static AZStd::string s_BumpMapName;
const static AZStd::string s_emptyString;
// A unique id which is used to identify a material in a fbx.
// This is the same as the ID in the fbx file's FbxNode
uint64_t m_uniqueId;
//! Material name from FbxNode's Object name
AZStd::string m_materialName;
};
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,156 @@
/*
* 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 <SceneAPI/SceneData/GraphData/MeshData.h>
#include <AzCore/Casting/numeric_cast.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
namespace DataTypes = AZ::SceneAPI::DataTypes;
MeshData::~MeshData() = default;
void MeshData::AddPosition(const AZ::Vector3& position)
{
m_positions.push_back(position);
}
void MeshData::AddNormal(const AZ::Vector3& normal)
{
m_normals.push_back(normal);
}
//assume consistent winding - no stripping or fanning expected (3 index per face)
//indices can be used for position and normal
void MeshData::AddFace(unsigned int index1, unsigned int index2, unsigned int index3, unsigned int faceMaterialId)
{
IMeshData::Face face;
face.vertexIndex[0] = index1;
face.vertexIndex[1] = index2;
face.vertexIndex[2] = index3;
m_faceList.push_back(face);
m_faceMaterialIds.push_back(faceMaterialId);
}
void MeshData::AddFace(const DataTypes::IMeshData::Face& face, unsigned int faceMaterialId)
{
m_faceList.push_back(face);
m_faceMaterialIds.push_back(faceMaterialId);
}
void MeshData::SetSdkMeshIndex(int sdkMeshIndex)
{
m_sdkMeshIndex = sdkMeshIndex;
}
int MeshData::GetSdkMeshIndex() const
{
return m_sdkMeshIndex;
}
void MeshData::SetVertexIndexToControlPointIndexMap(int vertexIndex, int controlPointIndex)
{
m_vertexIndexToControlPointIndexMap[vertexIndex] = controlPointIndex;
// The above hashmap stores the control point index (value) per vertex (key).
// We construct an unordered set and fill in the control point indices in order to get access to the number of unique control points indices.
if (m_controlPointToUsedVertexIndexMap.find(controlPointIndex) == m_controlPointToUsedVertexIndexMap.end())
{
m_controlPointToUsedVertexIndexMap[controlPointIndex] = aznumeric_cast<unsigned int>(m_controlPointToUsedVertexIndexMap.size());
}
}
int MeshData::GetControlPointIndex(int vertexIndex) const
{
AZ_Assert(m_vertexIndexToControlPointIndexMap.find(vertexIndex) != m_vertexIndexToControlPointIndexMap.end(), "Vertex index %i doesn't exist", vertexIndex);
// Note: AZStd::unordered_map's operator [] doesn't have const version...
return m_vertexIndexToControlPointIndexMap.find(vertexIndex)->second;
}
size_t MeshData::GetUsedControlPointCount() const
{
return m_controlPointToUsedVertexIndexMap.size();
}
int MeshData::GetUsedPointIndexForControlPoint(int controlPointIndex) const
{
auto iter = m_controlPointToUsedVertexIndexMap.find(controlPointIndex);
if (iter != m_controlPointToUsedVertexIndexMap.end())
{
return iter->second;
}
else
{
return -1; // That control point is not used in this mesh
}
}
unsigned int MeshData::GetVertexCount() const
{
return static_cast<unsigned int>(m_positions.size());
}
bool MeshData::HasNormalData() const
{
return m_normals.size() > 0;
}
const AZ::Vector3& MeshData::GetPosition(unsigned int index) const
{
AZ_Assert(index < m_positions.size(), "GetPosition index not in range");
return m_positions[index];
}
const AZ::Vector3& MeshData::GetNormal(unsigned int index) const
{
AZ_Assert(index < m_normals.size(), "GetNormal index not in range");
return m_normals[index];
}
unsigned int MeshData::GetFaceCount() const
{
return static_cast<unsigned int>(m_faceList.size());
}
const DataTypes::IMeshData::Face& MeshData::GetFaceInfo(unsigned int index) const
{
AZ_Assert(index < m_faceList.size(), "GetFaceInfo index not in range");
return m_faceList[index];
}
unsigned int MeshData::GetFaceMaterialId(unsigned int index) const
{
AZ_Assert(index < m_faceMaterialIds.size(), "GetFaceMaterialIds index not in range");
return m_faceMaterialIds[index];
}
unsigned int MeshData::GetVertexIndex(int faceIndex, int vertexIndexInFace) const
{
AZ_Assert(faceIndex < m_faceList.size(), "GetFaceInfo index not in range");
AZ_Assert(vertexIndexInFace < 3, "vertexIndexInFace index not in range");
return m_faceList[faceIndex].vertexIndex[vertexIndexInFace];
}
void MeshData::GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("Positions", m_positions);
output.Write("Normals", m_normals);
output.Write("FaceList", m_faceList);
output.Write("FaceMaterialIds", m_faceMaterialIds);
}
}
}
}
@@ -0,0 +1,83 @@
/*
* 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/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/containers/unordered_set.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS MeshData
: public AZ::SceneAPI::DataTypes::IMeshData
{
public:
AZ_RTTI(MeshData, "{a2589bd4-42fb-40ba-a38d-cfcd6e9ea169}", AZ::SceneAPI::DataTypes::IMeshData)
SCENE_DATA_API ~MeshData() override;
//assumes 1 to 1 mapping for these position, normal, color, uv
//positions with more than one normal or uv (seam) will duplicate shared values in multiple verts
SCENE_DATA_API virtual void AddPosition(const AZ::Vector3& position);
SCENE_DATA_API virtual void AddNormal(const AZ::Vector3& normal);
//assume consistent winding - no stripping or fanning expected (3 index per face)
SCENE_DATA_API void AddFace(unsigned int index1, unsigned int index2, unsigned int index3,
unsigned int faceMaterialId = AZ::SceneAPI::DataTypes::IMeshData::s_invalidMaterialId);
SCENE_DATA_API void AddFace(const AZ::SceneAPI::DataTypes::IMeshData::Face& face,
unsigned int faceMaterialId = AZ::SceneAPI::DataTypes::IMeshData::s_invalidMaterialId);
SCENE_DATA_API void SetSdkMeshIndex(int sdkMeshIndex);
SCENE_DATA_API int GetSdkMeshIndex() const;
SCENE_DATA_API void SetVertexIndexToControlPointIndexMap(int vertexIndex, int controlPointIndex);
SCENE_DATA_API size_t GetUsedControlPointCount() const override;
SCENE_DATA_API int GetControlPointIndex(int vertexIndex) const override;
SCENE_DATA_API int GetUsedPointIndexForControlPoint(int controlPointIndex) const override;
SCENE_DATA_API unsigned int GetVertexCount() const override;
SCENE_DATA_API bool HasNormalData() const override;
SCENE_DATA_API const AZ::Vector3& GetPosition(unsigned int index) const override;
SCENE_DATA_API const AZ::Vector3& GetNormal(unsigned int index) const override;
SCENE_DATA_API unsigned int GetFaceCount() const override;
SCENE_DATA_API const AZ::SceneAPI::DataTypes::IMeshData::Face& GetFaceInfo(unsigned int index) const override;
SCENE_DATA_API unsigned int GetFaceMaterialId(unsigned int index) const override;
SCENE_DATA_API unsigned int GetVertexIndex(int faceIndex, int vertexIndexInFace) const override;
SCENE_DATA_API void GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZ::Vector3> m_positions;
AZStd::vector<AZ::Vector3> m_normals;
AZStd::vector<AZ::SceneAPI::DataTypes::IMeshData::Face> m_faceList;
AZStd::vector<unsigned int> m_faceMaterialIds;
AZStd::unordered_map<int, int> m_vertexIndexToControlPointIndexMap;
AZStd::unordered_map<int, int> m_controlPointToUsedVertexIndexMap;
int m_sdkMeshIndex = -1;
};
}
}
}
@@ -0,0 +1,83 @@
/*
* 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 <SceneAPI/SceneData/GraphData/MeshData.h>
#include <SceneAPI/SceneData/GraphData/MeshDataPrimitiveUtils.h>
#include <algorithm>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
namespace DataTypes = AZ::SceneAPI::DataTypes;
std::unique_ptr<DataTypes::IMeshData > MeshDataPrimitiveUtils::CreateBox(const AZ::Vector3& dimensions, unsigned int materialId)
{
return CreateBox(dimensions.GetX(), dimensions.GetY(), dimensions.GetZ(), materialId);
}
std::unique_ptr<DataTypes::IMeshData> MeshDataPrimitiveUtils::CreateBox(float xDimension, float yDimension, float zDimension, unsigned int materialId)
{
const float c_minDimension = 0.00001f;
xDimension = std::max(xDimension, c_minDimension);
yDimension = std::max(yDimension, c_minDimension);
zDimension = std::max(zDimension, c_minDimension);
xDimension /= 2.0f;
yDimension /= 2.0f;
zDimension /= 2.0f;
//assume box is centered
//assume clockwise rotation for faces
MeshData* meshData = new MeshData();
//clockwise looking from neg x
meshData->AddPosition(Vector3(-xDimension, -yDimension, -zDimension));
meshData->AddPosition(Vector3(-xDimension, -yDimension, zDimension));
meshData->AddPosition(Vector3(-xDimension, yDimension, zDimension));
meshData->AddPosition(Vector3(-xDimension, yDimension, -zDimension));
//clockwise looking from pos x
meshData->AddPosition(Vector3(xDimension, -yDimension, -zDimension));
meshData->AddPosition(Vector3(xDimension, yDimension, -zDimension));
meshData->AddPosition(Vector3(xDimension, yDimension, zDimension));
meshData->AddPosition(Vector3(xDimension, -yDimension, zDimension));
//negx
meshData->AddFace(0, 1, 2, materialId);
meshData->AddFace(0, 2, 3, materialId);
//x
meshData->AddFace(4, 5, 6, materialId);
meshData->AddFace(4, 6, 7, materialId);
//negy
meshData->AddFace(0, 4, 7, materialId);
meshData->AddFace(0, 7, 1, materialId);
//y
meshData->AddFace(3, 2, 6, materialId);
meshData->AddFace(3, 6, 5, materialId);
//negz
meshData->AddFace(0, 3, 4, materialId);
meshData->AddFace(4, 3, 5, materialId);
//z
meshData->AddFace(7, 6, 2, materialId);
meshData->AddFace(7, 2, 1, materialId);
return std::unique_ptr<DataTypes::IMeshData>(meshData);
}
}
}
}
@@ -0,0 +1,42 @@
#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 <memory>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class MeshDataPrimitiveUtils
{
public:
SCENE_DATA_API static std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData> CreateBox(
const AZ::Vector3& dimensions,
unsigned int materialId = AZ::SceneAPI::DataTypes::IMeshData::s_invalidMaterialId
);
SCENE_DATA_API static std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData> CreateBox(
float xDimension,
float yDimension,
float zDimension,
unsigned int materialId = AZ::SceneAPI::DataTypes::IMeshData::s_invalidMaterialId
);
};
}
}
}
@@ -0,0 +1,89 @@
/*
* 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 <SceneAPI/SceneData/GraphData/MeshVertexBitangentData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
size_t MeshVertexBitangentData::GetCount() const
{
return m_bitangents.size();
}
const AZ::Vector3& MeshVertexBitangentData::GetBitangent(size_t index) const
{
AZ_Assert(index < m_bitangents.size(), "Invalid index %i for mesh bitangents.", index);
return m_bitangents[index];
}
void MeshVertexBitangentData::ReserveContainerSpace(size_t numVerts)
{
m_bitangents.reserve(numVerts);
}
void MeshVertexBitangentData::Resize(size_t numVerts)
{
m_bitangents.resize(numVerts);
}
void MeshVertexBitangentData::AppendBitangent(const AZ::Vector3& bitangent)
{
m_bitangents.push_back(bitangent);
}
void MeshVertexBitangentData::SetBitangent(size_t vertexIndex, const AZ::Vector3& bitangent)
{
m_bitangents[vertexIndex] = bitangent;
}
void MeshVertexBitangentData::SetBitangentSetIndex(size_t setIndex)
{
m_setIndex = setIndex;
}
size_t MeshVertexBitangentData::GetBitangentSetIndex() const
{
return m_setIndex;
}
AZ::SceneAPI::DataTypes::TangentSpace MeshVertexBitangentData::GetTangentSpace() const
{
return m_tangentSpace;
}
void MeshVertexBitangentData::SetTangentSpace(AZ::SceneAPI::DataTypes::TangentSpace space)
{
m_tangentSpace = space;
}
void MeshVertexBitangentData::GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("Bitangents", m_bitangents);
output.Write("TangentSpace", aznumeric_cast<int64_t>(m_tangentSpace));
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,60 @@
/*
* 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 <AzCore/Math/Vector3.h>
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexBitangentData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS MeshVertexBitangentData
: public AZ::SceneAPI::DataTypes::IMeshVertexBitangentData
{
public:
AZ_RTTI(MeshVertexBitangentData, "{F56FB088-4C92-4453-AFE9-4E820F03FA90}", AZ::SceneAPI::DataTypes::IMeshVertexBitangentData);
SCENE_DATA_API ~MeshVertexBitangentData() override = default;
SCENE_DATA_API size_t GetCount() const override;
SCENE_DATA_API const AZ::Vector3& GetBitangent(size_t index) const override;
SCENE_DATA_API void SetBitangent(size_t vertexIndex, const AZ::Vector3& bitangent) override;
SCENE_DATA_API void SetBitangentSetIndex(size_t setIndex) override;
SCENE_DATA_API size_t GetBitangentSetIndex() const override;
SCENE_DATA_API void Resize(size_t numVerts);
SCENE_DATA_API void ReserveContainerSpace(size_t numVerts);
SCENE_DATA_API void AppendBitangent(const AZ::Vector3& bitangent);
SCENE_DATA_API AZ::SceneAPI::DataTypes::TangentSpace GetTangentSpace() const override;
SCENE_DATA_API void SetTangentSpace(AZ::SceneAPI::DataTypes::TangentSpace space) override;
SCENE_DATA_API void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZ::Vector3> m_bitangents;
AZ::SceneAPI::DataTypes::TangentSpace m_tangentSpace = AZ::SceneAPI::DataTypes::TangentSpace::FromFbx;
size_t m_setIndex = 0;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,60 @@
/*
* 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 <SceneAPI/SceneData/GraphData/MeshVertexColorData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
const AZ::Name& MeshVertexColorData::GetCustomName() const
{
return m_customName;
}
void MeshVertexColorData::SetCustomName(const char* name)
{
m_customName = name;
}
size_t MeshVertexColorData::GetCount() const
{
return m_colors.size();
}
const AZ::SceneAPI::DataTypes::Color& MeshVertexColorData::GetColor(size_t index) const
{
AZ_Assert(index < m_colors.size(), "Invalid index %i for mesh vertex color.", index);
return m_colors[index];
}
void MeshVertexColorData::ReserveContainerSpace(size_t size)
{
m_colors.reserve(size);
}
void MeshVertexColorData::AppendColor(const AZ::SceneAPI::DataTypes::Color& color)
{
m_colors.push_back(color);
}
void MeshVertexColorData::GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("Colors", m_colors);
output.Write("ColorsCustomName", m_customName.GetCStr());
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,51 @@
#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/std/containers/vector.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class MeshVertexColorData
: public AZ::SceneAPI::DataTypes::IMeshVertexColorData
{
public:
AZ_RTTI(MeshVertexColorData, "{17477B86-B163-4574-8FB2-4916BC218B3D}", AZ::SceneAPI::DataTypes::IMeshVertexColorData);
SCENE_DATA_API ~MeshVertexColorData() override = default;
SCENE_DATA_API const AZ::Name& GetCustomName() const override;
SCENE_DATA_API void SetCustomName(const char* name);
SCENE_DATA_API size_t GetCount() const override;
SCENE_DATA_API const AZ::SceneAPI::DataTypes::Color& GetColor(size_t index) const override;
// Pre-allocates memory for the color storage container. This can speed up loading as
// the container doesn't need to resize between adding colors.
SCENE_DATA_API void ReserveContainerSpace(size_t size);
SCENE_DATA_API void AppendColor(const AZ::SceneAPI::DataTypes::Color& color);
SCENE_DATA_API void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZ::SceneAPI::DataTypes::Color> m_colors;
AZ::Name m_customName;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,91 @@
/*
* 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 <SceneAPI/SceneData/GraphData/MeshVertexTangentData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
size_t MeshVertexTangentData::GetCount() const
{
return m_tangents.size();
}
const AZ::Vector4& MeshVertexTangentData::GetTangent(size_t index) const
{
AZ_Assert(index < m_tangents.size(), "Invalid index %i for mesh tangents.", index);
return m_tangents[index];
}
void MeshVertexTangentData::ReserveContainerSpace(size_t numVerts)
{
m_tangents.reserve(numVerts);
}
void MeshVertexTangentData::Resize(size_t numVerts)
{
m_tangents.resize(numVerts);
}
void MeshVertexTangentData::AppendTangent(const AZ::Vector4& tangent)
{
m_tangents.push_back(tangent);
}
void MeshVertexTangentData::GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("Tangents", m_tangents);
output.Write("TangentSpace", aznumeric_cast<int64_t>(m_tangentSpace));
output.Write("SetIndex", aznumeric_cast<uint64_t>(m_setIndex));
}
void MeshVertexTangentData::SetTangent(size_t vertexIndex, const AZ::Vector4& tangent)
{
m_tangents[vertexIndex] = tangent;
}
void MeshVertexTangentData::SetTangentSetIndex(size_t setIndex)
{
m_setIndex = setIndex;
}
size_t MeshVertexTangentData::GetTangentSetIndex() const
{
return m_setIndex;
}
AZ::SceneAPI::DataTypes::TangentSpace MeshVertexTangentData::GetTangentSpace() const
{
return m_tangentSpace;
}
void MeshVertexTangentData::SetTangentSpace(AZ::SceneAPI::DataTypes::TangentSpace space)
{
m_tangentSpace = space;
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,59 @@
/*
* 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 <AzCore/Math/Vector4.h>
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexTangentData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS MeshVertexTangentData
: public AZ::SceneAPI::DataTypes::IMeshVertexTangentData
{
public:
AZ_RTTI(MeshVertexTangentData, "{C16F0F38-8F8F-45A2-A33B-F2758922A7C4}", AZ::SceneAPI::DataTypes::IMeshVertexTangentData);
SCENE_DATA_API ~MeshVertexTangentData() override = default;
SCENE_DATA_API size_t GetCount() const override;
SCENE_DATA_API const AZ::Vector4& GetTangent(size_t index) const override;
SCENE_DATA_API void SetTangent(size_t vertexIndex, const AZ::Vector4& tangent) override;
SCENE_DATA_API void SetTangentSetIndex(size_t setIndex) override;
SCENE_DATA_API size_t GetTangentSetIndex() const override;
SCENE_DATA_API AZ::SceneAPI::DataTypes::TangentSpace GetTangentSpace() const override;
SCENE_DATA_API void SetTangentSpace(AZ::SceneAPI::DataTypes::TangentSpace space) override;
SCENE_DATA_API void Resize(size_t numVerts);
SCENE_DATA_API void ReserveContainerSpace(size_t numVerts);
SCENE_DATA_API void AppendTangent(const AZ::Vector4& tangent);
SCENE_DATA_API void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZ::Vector4> m_tangents;
AZ::SceneAPI::DataTypes::TangentSpace m_tangentSpace = AZ::SceneAPI::DataTypes::TangentSpace::FromFbx;
size_t m_setIndex = 0;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,60 @@
/*
* 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 <SceneAPI/SceneData/GraphData/MeshVertexUVData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
const AZ::Name& MeshVertexUVData::GetCustomName() const
{
return m_customName;
}
void MeshVertexUVData::SetCustomName(const char* name)
{
m_customName = name;
}
size_t MeshVertexUVData::GetCount() const
{
return m_uvs.size();
}
const AZ::Vector2& MeshVertexUVData::GetUV(size_t index) const
{
AZ_Assert(index < m_uvs.size(), "Invalid index %i for mesh vertex UVs.", index);
return m_uvs[index];
}
void MeshVertexUVData::ReserveContainerSpace(size_t size)
{
m_uvs.reserve(size);
}
void MeshVertexUVData::AppendUV(const AZ::Vector2& uv)
{
m_uvs.push_back(uv);
}
void MeshVertexUVData::GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("UVs", m_uvs);
output.Write("UVCustomName", m_customName.GetCStr());
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,52 @@
#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/Math/Vector2.h>
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexUVData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class MeshVertexUVData
: public AZ::SceneAPI::DataTypes::IMeshVertexUVData
{
public:
AZ_RTTI(MeshVertexUVData, "{B435C091-482C-4EB9-B1F4-FA5B480796DA}", AZ::SceneAPI::DataTypes::IMeshVertexUVData);
SCENE_DATA_API ~MeshVertexUVData() override = default;
SCENE_DATA_API const AZ::Name& GetCustomName() const override;
SCENE_DATA_API void SetCustomName(const char* name);
SCENE_DATA_API size_t GetCount() const override;
SCENE_DATA_API const AZ::Vector2& GetUV(size_t index) const override;
// Pre-allocate memory
SCENE_DATA_API void ReserveContainerSpace(size_t size);
SCENE_DATA_API void AppendUV(const AZ::Vector2& uv);
SCENE_DATA_API void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZ::Vector2> m_uvs;
AZ::Name m_customName;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,40 @@
/*
* 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 <SceneAPI/SceneData/GraphData/RootBoneData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
void RootBoneData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<RootBoneData, BoneData>()->Version(1);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<RootBoneData>("Root Bone data", "First bone in the skeletal hierarchy.");
}
}
}
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,37 @@
/*
* 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/SceneData/GraphData/BoneData.h>
namespace AZ
{
class ReflectContext;
namespace SceneData
{
namespace GraphData
{
class RootBoneData
: public AZ::SceneData::GraphData::BoneData
{
public:
AZ_RTTI(RootBoneData, "{EB1FCB42-77A2-4EBA-B70B-8BB1B6948355}", AZ::SceneData::GraphData::BoneData);
virtual ~RootBoneData() override = default;
static void Reflect(ReflectContext* context);
};
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,34 @@
#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 <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneData/GraphData/MeshData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SkinMeshData
: public MeshData
{
public:
AZ_RTTI(SkinMeshData, "{F765B68B-101E-4CED-879A-663AEDE6AE89}", MeshData);
virtual ~SkinMeshData() override = default;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,85 @@
/*
* 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/Casting/numeric_cast.h>
#include <SceneAPI/SceneData/GraphData/SkinWeightData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
size_t SkinWeightData::GetVertexCount() const
{
return m_vertexLinks.size();
}
size_t SkinWeightData::GetLinkCount(size_t vertexIndex) const
{
AZ_Assert(vertexIndex < m_vertexLinks.size(), "Invalid vertex index %i for skin weight data links.", vertexIndex);
return m_vertexLinks[vertexIndex].size();
}
const SceneAPI::DataTypes::ISkinWeightData::Link& SkinWeightData::GetLink(size_t vertexIndex, size_t linkIndex) const
{
AZ_Assert(vertexIndex < m_vertexLinks.size(), "Invalid vertex index %i for skin weight data links.", vertexIndex);
AZ_Assert(linkIndex < m_vertexLinks[vertexIndex].size(), "Invalid link index %i for skin weight data %i.", linkIndex, vertexIndex);
return m_vertexLinks[vertexIndex][linkIndex];
}
SceneAPI::DataTypes::ISkinWeightData::Link& SkinWeightData::GetLink(size_t vertexIndex, size_t linkIndex)
{
AZ_Assert(vertexIndex < m_vertexLinks.size(), "Invalid vertex index %i for skin weight data links.", vertexIndex);
AZ_Assert(linkIndex < m_vertexLinks[vertexIndex].size(), "Invalid link index %i for skin weight data %i.", linkIndex, vertexIndex);
return m_vertexLinks[vertexIndex][linkIndex];
}
size_t SkinWeightData::GetBoneCount() const
{
return m_boneIdNameMap.size();
}
const AZStd::string& SkinWeightData::GetBoneName(int boneId) const
{
AZ_Assert(m_boneIdNameMap.find(boneId) != m_boneIdNameMap.end(), "Invalid bone id %i to look up bone name.", boneId);
return m_boneIdNameMap.at(boneId);
}
void SkinWeightData::ResizeContainerSpace(size_t size)
{
m_vertexLinks.resize(size);
}
void SkinWeightData::AppendLink(size_t vertexIndex, const SceneAPI::DataTypes::ISkinWeightData::Link& link)
{
AZ_Assert(vertexIndex < m_vertexLinks.size(), "Invalid vertex index %i for skin weight data links.", vertexIndex);
m_vertexLinks[vertexIndex].push_back(link);
}
int SkinWeightData::GetBoneId(const AZStd::string& boneName)
{
if (m_boneNameIdMap.find(boneName) == m_boneNameIdMap.end())
{
m_boneNameIdMap[boneName] = aznumeric_caster(m_boneNameIdMap.size());
m_boneIdNameMap[m_boneNameIdMap[boneName]] = boneName;
}
return m_boneNameIdMap[boneName];
}
void SkinWeightData::GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("VertexLinks", m_vertexLinks);
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,55 @@
#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/std/containers/vector.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/ISkinWeightData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SkinWeightData
: public SceneAPI::DataTypes::ISkinWeightData
{
public:
AZ_RTTI(SkinWeightData, "{2175A399-8EAA-4BFF-9720-C5FED739717E}", SceneAPI::DataTypes::ISkinWeightData);
SCENE_DATA_API ~SkinWeightData() override = default;
SCENE_DATA_API size_t GetVertexCount() const override;
SCENE_DATA_API size_t GetLinkCount(size_t vertexIndex) const override;
SCENE_DATA_API const Link& GetLink(size_t vertexIndex, size_t linkIndex) const override;
SCENE_DATA_API Link& GetLink(size_t vertexIndex, size_t linkIndex);
SCENE_DATA_API size_t GetBoneCount() const override;
SCENE_DATA_API const AZStd::string& GetBoneName(int boneId) const override;
SCENE_DATA_API void ResizeContainerSpace(size_t size);
SCENE_DATA_API void AppendLink(size_t vertexIndex, const SceneAPI::DataTypes::ISkinWeightData::Link& link);
SCENE_DATA_API int GetBoneId(const AZStd::string& boneName);
SCENE_DATA_API void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZStd::vector<SceneAPI::DataTypes::ISkinWeightData::Link>> m_vertexLinks;
AZStd::unordered_map<AZStd::string, int> m_boneNameIdMap;
AZStd::unordered_map<int, AZStd::string> m_boneIdNameMap;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,61 @@
/*
* 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 <SceneAPI/SceneData/GraphData/TransformData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
TransformData::TransformData(const SceneAPI::DataTypes::MatrixType& transform)
: m_transform(transform)
{
}
void TransformData::SetMatrix(const SceneAPI::DataTypes::MatrixType& transform)
{
m_transform = transform;
}
SceneAPI::DataTypes::MatrixType& TransformData::GetMatrix()
{
return m_transform;
}
const SceneAPI::DataTypes::MatrixType& TransformData::GetMatrix() const
{
return m_transform;
}
void TransformData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<TransformData>()->Version(1)
->Field("transform", &TransformData::m_transform);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<TransformData>("Transform", "Transform matrix applied as a node or as a child.")
->DataElement(AZ::Edit::UIHandlers::Default, &TransformData::m_transform, "", "Transform matrix applied as a node or as a child.");
}
}
}
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,47 @@
/*
* 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/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/ITransform.h>
namespace AZ
{
class ReflectContext;
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS TransformData
: public AZ::SceneAPI::DataTypes::ITransform
{
public:
AZ_RTTI(TransformData, "{EA86343D-8DB4-4907-8CA8-E6BAB8961914}", AZ::SceneAPI::DataTypes::ITransform);
SCENE_DATA_API TransformData() = default;
SCENE_DATA_API explicit TransformData(const SceneAPI::DataTypes::MatrixType& transform);
SCENE_DATA_API virtual void SetMatrix(const SceneAPI::DataTypes::MatrixType& transform);
SCENE_DATA_API SceneAPI::DataTypes::MatrixType& GetMatrix() override;
SCENE_DATA_API const SceneAPI::DataTypes::MatrixType& GetMatrix() const override;
static void Reflect(ReflectContext* context);
protected:
SceneAPI::DataTypes::MatrixType m_transform;
};
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,208 @@
/*
* 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/SceneCore/DataTypes/Rules/IRule.h>
#include <SceneAPI/SceneData/Groups/AnimationGroup.h>
#include <SceneAPI/SceneData/GraphData/RootBoneData.h>
namespace AZ
{
namespace SceneAPI
{
void DataTypes::IAnimationGroup::PerBoneCompression::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
serializeContext->Class<IAnimationGroup::PerBoneCompression>()->Version(1)
->Field("boneNamePattern", &IAnimationGroup::PerBoneCompression::m_boneNamePattern)
->Field("compressionStrength", &IAnimationGroup::PerBoneCompression::m_compressionStrength)
;
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<IAnimationGroup::PerBoneCompression>("Compression Override", "Compression settings for an individual bone.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->DataElement("NodeListSelection", &IAnimationGroup::PerBoneCompression::m_boneNamePattern, "Bone name/pattern", "Bone name or pattern with wildcards, e.g. \"*arm*\".")
->Attribute("ClassTypeIdFilter", AZ::SceneAPI::DataTypes::IBoneData::TYPEINFO_Uuid())
->Attribute(AZ::Edit::Attributes::ComboBoxEditable, true)
->DataElement(Edit::UIHandlers::Slider, &IAnimationGroup::PerBoneCompression::m_compressionStrength, "Strength", "Compression strength to use for the specified bone.")
->Attribute(AZ::Edit::Attributes::Min, 0.f)
->Attribute(AZ::Edit::Attributes::Max, 1.f)
;
}
}
namespace SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(AnimationGroup, SystemAllocator, 0)
AnimationGroup::AnimationGroup()
: m_id(Uuid::CreateRandom())
, m_startFrame(0)
, m_endFrame(0)
, m_defaultCompressionStrength(0.1f)
{
}
const AZStd::string& AnimationGroup::GetName() const
{
return m_name;
}
void AnimationGroup::SetName(const AZStd::string& name)
{
m_name = name;
}
void AnimationGroup::SetName(AZStd::string&& name)
{
m_name = AZStd::move(name);
}
const Uuid& AnimationGroup::GetId() const
{
return m_id;
}
void AnimationGroup::OverrideId(const Uuid& id)
{
m_id = id;
}
Containers::RuleContainer& AnimationGroup::GetRuleContainer()
{
return m_rules;
}
const Containers::RuleContainer& AnimationGroup::GetRuleContainerConst() const
{
return m_rules;
}
const AZStd::string& AnimationGroup::GetSelectedRootBone() const
{
return m_selectedRootBone;
}
uint32_t AnimationGroup::GetStartFrame() const
{
return m_startFrame;
}
uint32_t AnimationGroup::GetEndFrame() const
{
return m_endFrame;
}
const float AnimationGroup::GetDefaultCompressionStrength() const
{
return m_defaultCompressionStrength;
}
const DataTypes::IAnimationGroup::PerBoneCompressionList& AnimationGroup::GetPerBoneCompression() const
{
return m_perBoneCompression;
}
void AnimationGroup::SetSelectedRootBone(const AZStd::string& selectedRootBone)
{
m_selectedRootBone = selectedRootBone;
}
void AnimationGroup::SetStartFrame(uint32_t frame)
{
m_startFrame = frame;
}
void AnimationGroup::SetEndFrame(uint32_t frame)
{
m_endFrame = frame;
}
void AnimationGroup::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
DataTypes::IAnimationGroup::PerBoneCompression::Reflect(context);
serializeContext->Class<AnimationGroup, DataTypes::IAnimationGroup>()->Version(3, VersionConverter)
->Field("name", &AnimationGroup::m_name)
->Field("id", &AnimationGroup::m_id)
->Field("selectedRootBone", &AnimationGroup::m_selectedRootBone)
->Field("startFrame", &AnimationGroup::m_startFrame)
->Field("endFrame", &AnimationGroup::m_endFrame)
->Field("defaultCompressionStrength", &AnimationGroup::m_defaultCompressionStrength)
->Field("perBoneCompression", &AnimationGroup::m_perBoneCompression)
->Field("rules", &AnimationGroup::m_rules)
;
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<AnimationGroup>("Animation group", "Configure animation data exporting.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(Edit::Attributes::NameLabelOverride, "")
->DataElement(AZ_CRC("ManifestName", 0x5215b349), &AnimationGroup::m_name, "Group name",
"Name for the group. This name will also be used as the name for the generated file.")
->Attribute("FilterType", DataTypes::IAnimationGroup::TYPEINFO_Uuid())
->DataElement("NodeListSelection", &AnimationGroup::m_selectedRootBone, "Select root bone", "The root bone of the animation that will be exported.")
->Attribute("ClassTypeIdFilter", AZ::SceneAPI::DataTypes::IBoneData::TYPEINFO_Uuid())
->DataElement(Edit::UIHandlers::Default, &AnimationGroup::m_startFrame, "Start frame", "The start frame of the animation that will be exported.")
->DataElement(Edit::UIHandlers::Default, &AnimationGroup::m_endFrame, "End frame", "The end frame of the animation that will be exported.")
->DataElement(Edit::UIHandlers::Default, &AnimationGroup::m_rules, "", "Add or remove rules to fine-tune the export process.")
->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20))
->ClassElement(Edit::ClassElements::Group, "Compression")
->DataElement(Edit::UIHandlers::Slider, &AnimationGroup::m_defaultCompressionStrength, "Default strength", "Default compression strength to use by default for all bones.")
->Attribute(AZ::Edit::Attributes::Min, 0.f)
->Attribute(AZ::Edit::Attributes::Max, 1.f)
->DataElement(Edit::UIHandlers::Default, &AnimationGroup::m_perBoneCompression, "Bone/group overrides", "Compression strength overrides for specific bones, or bone groups (using wildcards).")
;
}
}
bool AnimationGroup::VersionConverter(SerializeContext& context, SerializeContext::DataElementNode& classElement)
{
const unsigned int version = classElement.GetVersion();
bool result = true;
// Replaced vector<IRule> with RuleContainer.
if (version == 1)
{
result = result && Containers::RuleContainer::VectorToRuleContainerConverter(context, classElement);
}
// Added a uuid "id" as the unique identifier to replace the file name.
// Setting it to null by default and expecting a behavior to patch this when additional information is available.
if (version <= 2)
{
result = result && classElement.AddElementWithData<AZ::Uuid>(context, "id", AZ::Uuid::CreateNull()) != -1;
}
return result;
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,71 @@
/*
* 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 <AzCore/Memory/Memory.h>
#include <SceneAPI/SceneCore/Containers/RuleContainer.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/IAnimationGroup.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace SceneData
{
class AnimationGroup
: public DataTypes::IAnimationGroup
{
public:
AZ_RTTI(AnimationGroup, "{982E0030-8131-43E9-BA8C-23775A3B7219}", DataTypes::IAnimationGroup);
AZ_CLASS_ALLOCATOR_DECL
AnimationGroup();
~AnimationGroup() override = default;
const AZStd::string& GetName() const override;
void SetName(const AZStd::string& name);
void SetName(AZStd::string&& name);
const Uuid& GetId() const override;
void OverrideId(const Uuid& id);
Containers::RuleContainer& GetRuleContainer() override;
const Containers::RuleContainer& GetRuleContainerConst() const;
const AZStd::string& GetSelectedRootBone() const override;
uint32_t GetStartFrame() const override;
uint32_t GetEndFrame() const override;
const float GetDefaultCompressionStrength() const override;
const DataTypes::IAnimationGroup::PerBoneCompressionList& GetPerBoneCompression() const override;
void SetSelectedRootBone(const AZStd::string& selectedRootBone) override;
void SetStartFrame(uint32_t frame) override;
void SetEndFrame(uint32_t frame) override;
static void Reflect(ReflectContext* context);
static bool VersionConverter(SerializeContext& context, SerializeContext::DataElementNode& classElement);
protected:
DataTypes::IAnimationGroup::PerBoneCompressionList m_perBoneCompression;
Containers::RuleContainer m_rules;
AZStd::string m_selectedRootBone;
AZStd::string m_name;
Uuid m_id;
uint32_t m_startFrame;
uint32_t m_endFrame;
float m_defaultCompressionStrength;
};
}
}
}
@@ -0,0 +1,135 @@
/*
* 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 <algorithm>
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <SceneAPI/SceneData/Groups/MeshGroup.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IRule.h>
#include <SceneAPI/SceneUI/RowWidgets/ManifestVectorHandler.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
MeshGroup::MeshGroup()
: m_id(Uuid::CreateRandom())
{
}
const AZStd::string& MeshGroup::GetName() const
{
return m_name;
}
void MeshGroup::SetName(const AZStd::string& name)
{
m_name = name;
}
void MeshGroup::SetName(AZStd::string&& name)
{
m_name = AZStd::move(name);
}
const Uuid& MeshGroup::GetId() const
{
return m_id;
}
void MeshGroup::OverrideId(const Uuid& id)
{
m_id = id;
}
Containers::RuleContainer& MeshGroup::GetRuleContainer()
{
return m_rules;
}
const Containers::RuleContainer& MeshGroup::GetRuleContainerConst() const
{
return m_rules;
}
DataTypes::ISceneNodeSelectionList& MeshGroup::GetSceneNodeSelectionList()
{
return m_nodeSelectionList;
}
const DataTypes::ISceneNodeSelectionList& MeshGroup::GetSceneNodeSelectionList() const
{
return m_nodeSelectionList;
}
void MeshGroup::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<MeshGroup, DataTypes::IMeshGroup>()
->Version(3, VersionConverter)
->Field("name", &MeshGroup::m_name)
->Field("nodeSelectionList", &MeshGroup::m_nodeSelectionList)
->Field("rules", &MeshGroup::m_rules)
->Field("id", &MeshGroup::m_id);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<MeshGroup>("Mesh group", "Name and configure 1 or more meshes from your source file.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(Edit::Attributes::NameLabelOverride, "")
->DataElement(AZ_CRC("ManifestName", 0x5215b349), &MeshGroup::m_name, "Name mesh",
"Name the mesh as you want it to appear in the Lumberyard Asset Browser.")
->Attribute("FilterType", DataTypes::IMeshGroup::TYPEINFO_Uuid())
->DataElement(Edit::UIHandlers::Default, &MeshGroup::m_nodeSelectionList, "Select meshes", "Select 1 or more meshes to add to this asset in the Lumberyard Asset Browser.")
->Attribute("FilterName", "meshes")
->Attribute("FilterType", DataTypes::IMeshData::TYPEINFO_Uuid())
->DataElement(Edit::UIHandlers::Default, &MeshGroup::m_rules, "", "Add or remove rules to fine-tune the export process.")
->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20));
}
}
bool MeshGroup::VersionConverter(SerializeContext& context, SerializeContext::DataElementNode& classElement)
{
const unsigned int version = classElement.GetVersion();
// Replaced vector<IRule> with RuleContainer.
bool result = true;
if (version == 1)
{
result = result && Containers::RuleContainer::VectorToRuleContainerConverter(context, classElement);
}
// Added a uuid "id" as the unique identifier to replace the file name.
// Setting it to null by default and expecting a behavior to patch this when additional information is available.
if (version <= 2)
{
result = result && classElement.AddElementWithData<AZ::Uuid>(context, "id", AZ::Uuid::CreateNull()) != -1;
}
return result;
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,69 @@
/*
* 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 <AzCore/Memory/Memory.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <SceneAPI/SceneCore/Containers/RuleContainer.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/IMeshGroup.h>
#include <SceneAPI/SceneData/ManifestBase/SceneNodeSelectionList.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace SceneData
{
class MeshGroup
: public DataTypes::IMeshGroup
{
public:
AZ_RTTI(MeshGroup, "{07B356B7-3635-40B5-878A-FAC4EFD5AD86}", DataTypes::IMeshGroup);
AZ_CLASS_ALLOCATOR(MeshGroup, SystemAllocator, 0)
MeshGroup();
~MeshGroup() override = default;
const AZStd::string& GetName() const override;
void SetName(const AZStd::string& name);
void SetName(AZStd::string&& name) override;
const Uuid& GetId() const override;
void OverrideId(const Uuid& id) override;
Containers::RuleContainer& GetRuleContainer() override;
const Containers::RuleContainer& GetRuleContainerConst() const override;
DataTypes::ISceneNodeSelectionList& GetSceneNodeSelectionList() override;
const DataTypes::ISceneNodeSelectionList& GetSceneNodeSelectionList() const override;
static void Reflect(AZ::ReflectContext* context);
static bool VersionConverter(SerializeContext& context, SerializeContext::DataElementNode& classElement);
protected:
SceneNodeSelectionList m_nodeSelectionList;
Containers::RuleContainer m_rules;
AZStd::string m_name;
Uuid m_id;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,135 @@
/*
* 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/SceneCore/DataTypes/Rules/IRule.h>
#include <SceneAPI/SceneData/Groups/SkeletonGroup.h>
#include <SceneAPI/SceneData/GraphData/RootBoneData.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(SkeletonGroup, SystemAllocator, 0)
SkeletonGroup::SkeletonGroup()
: m_id(Uuid::CreateRandom())
{
}
const AZStd::string& SkeletonGroup::GetName() const
{
return m_name;
}
void SkeletonGroup::SetName(const AZStd::string& name)
{
m_name = name;
}
void SkeletonGroup::SetName(AZStd::string&& name)
{
m_name = AZStd::move(name);
}
const Uuid& SkeletonGroup::GetId() const
{
return m_id;
}
void SkeletonGroup::OverrideId(const Uuid& id)
{
m_id = id;
}
Containers::RuleContainer& SkeletonGroup::GetRuleContainer()
{
return m_rules;
}
const Containers::RuleContainer& SkeletonGroup::GetRuleContainerConst() const
{
return m_rules;
}
const AZStd::string& SkeletonGroup::GetSelectedRootBone() const
{
return m_selectedRootBone;
}
void SkeletonGroup::SetSelectedRootBone(const AZStd::string& selectedRootBone)
{
m_selectedRootBone = selectedRootBone;
}
void SkeletonGroup::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<SkeletonGroup, DataTypes::ISkeletonGroup>()->Version(3, VersionConverter)
->Field("name", &SkeletonGroup::m_name)
->Field("selectedRootBone", &SkeletonGroup::m_selectedRootBone)
->Field("rules", &SkeletonGroup::m_rules)
->Field("id", &SkeletonGroup::m_id);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<SkeletonGroup>("Skeleton group", "Name and configure a skeleton from your source file.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(Edit::Attributes::NameLabelOverride, "")
->DataElement(AZ_CRC("ManifestName", 0x5215b349), &SkeletonGroup::m_name, "Name skeleton",
"Name the skeleton as you want it to appear in the Lumberyard Asset Browser.")
->Attribute("FilterType", DataTypes::ISkeletonGroup::TYPEINFO_Uuid())
->DataElement("NodeListSelection", &SkeletonGroup::m_selectedRootBone, "Select root bone", "Select the root bone of the skeleton.")
->Attribute("ClassTypeIdFilter", AZ::SceneData::GraphData::RootBoneData::TYPEINFO_Uuid())
->DataElement(Edit::UIHandlers::Default, &SkeletonGroup::m_rules, "", "Add or remove rules to fine-tune the export process.")
->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20));
}
}
bool SkeletonGroup::VersionConverter(SerializeContext& context, SerializeContext::DataElementNode& classElement)
{
const unsigned int version = classElement.GetVersion();
bool result = true;
// Replaced vector<IRule> with RuleContainer.
if (version == 1)
{
result = result && Containers::RuleContainer::VectorToRuleContainerConverter(context, classElement);
}
// Added a uuid "id" as the unique identifier to replace the file name.
// Setting it to null by default and expecting a behavior to patch this when additional information is available.
if (version <= 2)
{
result = result && classElement.AddElementWithData<AZ::Uuid>(context, "id", AZ::Uuid::CreateNull()) != -1;
}
return result;
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,63 @@
/*
* 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 <AzCore/Memory/Memory.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneCore/Containers/RuleContainer.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkeletonGroup.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace SceneData
{
class SkeletonGroup
: public DataTypes::ISkeletonGroup
{
public:
AZ_RTTI(SkeletonGroup, "{F5F8D1BF-3A24-45E8-8C3F-6A682CA02520}", DataTypes::ISkeletonGroup);
AZ_CLASS_ALLOCATOR_DECL
SkeletonGroup();
~SkeletonGroup() override = default;
const AZStd::string& GetName() const override;
void SetName(const AZStd::string& name);
void SetName(AZStd::string&& name);
const Uuid& GetId() const override;
void OverrideId(const Uuid& id);
Containers::RuleContainer& GetRuleContainer();
const Containers::RuleContainer& GetRuleContainerConst() const;
const AZStd::string& GetSelectedRootBone() const override;
void SetSelectedRootBone(const AZStd::string& selectedRootBone) override;
static void Reflect(ReflectContext* context);
static bool VersionConverter(SerializeContext& context, SerializeContext::DataElementNode& classElement);
protected:
Containers::RuleContainer m_rules;
AZStd::string m_name;
AZStd::string m_selectedRootBone;
Uuid m_id;
};
}
}
}
@@ -0,0 +1,141 @@
/*
* 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 <SceneAPI/SceneData/Groups/SkinGroup.h>
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphChildIterator.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IRule.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/ISkinWeightData.h>
#include <SceneAPI/SceneData/Behaviors/SkinGroup.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(SkinGroup, AZ::SystemAllocator, 0)
SkinGroup::SkinGroup()
: m_id(Uuid::CreateRandom())
{
}
const AZStd::string& SkinGroup::GetName() const
{
return m_name;
}
void SkinGroup::SetName(const AZStd::string& name)
{
m_name = name;
}
void SkinGroup::SetName(AZStd::string&& name)
{
m_name = AZStd::move(name);
}
const Uuid& SkinGroup::GetId() const
{
return m_id;
}
void SkinGroup::OverrideId(const Uuid& id)
{
m_id = id;
}
Containers::RuleContainer& SkinGroup::GetRuleContainer()
{
return m_rules;
}
const Containers::RuleContainer& SkinGroup::GetRuleContainerConst() const
{
return m_rules;
}
DataTypes::ISceneNodeSelectionList& SkinGroup::GetSceneNodeSelectionList()
{
return m_nodeSelectionList;
}
const DataTypes::ISceneNodeSelectionList& SkinGroup::GetSceneNodeSelectionList() const
{
return m_nodeSelectionList;
}
void SkinGroup::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<SkinGroup, DataTypes::ISkinGroup>()->Version(3, VersionConverter)
->Field("name", &SkinGroup::m_name)
->Field("nodeSelectionList", &SkinGroup::m_nodeSelectionList)
->Field("rules", &SkinGroup::m_rules)
->Field("id", &SkinGroup::m_id);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<SkinGroup>("Skin group", "Name and configure 1 or more skins from your source file.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(AZ_CRC("ManifestName", 0x5215b349), &SkinGroup::m_name, "Name skin",
"Name the skin as you want it to appear in the Lumberyard Asset Browser.")
->Attribute("FilterType", DataTypes::ISkinGroup::TYPEINFO_Uuid())
->DataElement(AZ_CRC("ManifestName", 0x5215b349), &SkinGroup::m_nodeSelectionList, "Select skins", "Select 1 or more skins to add to this asset in the Lumberyard Asset Browser.")
->Attribute("FilterName", "skins")
->Attribute("FilterVirtualType", Behaviors::SkinGroup::s_skinVirtualType)
->DataElement(Edit::UIHandlers::Default, &SkinGroup::m_rules, "", "Add or remove rules to fine-tune the export process.")
->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20));
}
}
bool SkinGroup::VersionConverter(SerializeContext& context, SerializeContext::DataElementNode& classElement)
{
const unsigned int version = classElement.GetVersion();
bool result = true;
// Replaced vector<IRule> with RuleContainer.
if (version == 1)
{
result = result && Containers::RuleContainer::VectorToRuleContainerConverter(context, classElement);
}
// Added a uuid "id" as the unique identifier to replace the file name.
// Setting it to null by default and expecting a behavior to patch this when additional information is available.
if (version <= 2)
{
result = result && classElement.AddElementWithData<AZ::Uuid>(context, "id", AZ::Uuid::CreateNull()) != -1;
}
return result;
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,71 @@
/*
* 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 <AzCore/Memory/Memory.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <SceneAPI/SceneCore/Containers/RuleContainer.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkinGroup.h>
#include <SceneAPI/SceneData/ManifestBase/SceneNodeSelectionList.h>
namespace AZ
{
class ReflectContex;
namespace SceneAPI
{
namespace DataTypes
{
class IRule;
}
namespace SceneData
{
class SkinGroup : public DataTypes::ISkinGroup
{
public:
AZ_RTTI(SkinGroup, "{A3217B13-79EA-4487-9A13-5D382EA9077A}", DataTypes::ISkinGroup);
AZ_CLASS_ALLOCATOR_DECL
SkinGroup();
~SkinGroup() override = default;
const AZStd::string& GetName() const override;
void SetName(const AZStd::string& name);
void SetName(AZStd::string&& name);
const Uuid& GetId() const override;
void OverrideId(const Uuid& id);
Containers::RuleContainer& GetRuleContainer();
const Containers::RuleContainer& GetRuleContainerConst() const;
DataTypes::ISceneNodeSelectionList& GetSceneNodeSelectionList() override;
const DataTypes::ISceneNodeSelectionList& GetSceneNodeSelectionList() const override;
static void Reflect(AZ::ReflectContext* context);
static bool VersionConverter(SerializeContext& context, SerializeContext::DataElementNode& classElement);
protected:
SceneNodeSelectionList m_nodeSelectionList;
Containers::RuleContainer m_rules;
AZStd::string m_name;
Uuid m_id;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,163 @@
/*
* 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 <algorithm>
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <SceneAPI/SceneData/ManifestBase/SceneNodeSelectionList.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
size_t SceneNodeSelectionList::GetSelectedNodeCount() const
{
return m_selectedNodes.size();
}
const AZStd::string& SceneNodeSelectionList::GetSelectedNode(size_t index) const
{
AZ_Assert(index < m_selectedNodes.size(), "Invalid index %i for selected node in mesh group.", index);
return m_selectedNodes[index];
}
size_t SceneNodeSelectionList::AddSelectedNode(const AZStd::string& name)
{
auto unselectEntry = AZStd::find(m_unselectedNodes.begin(), m_unselectedNodes.end(), name);
if (unselectEntry != m_unselectedNodes.end())
{
m_unselectedNodes.erase(unselectEntry);
}
auto entry = AZStd::find(m_selectedNodes.begin(), m_selectedNodes.end(), name);
if (entry == m_selectedNodes.end())
{
size_t index = m_selectedNodes.size();
m_selectedNodes.push_back(name);
return index;
}
else
{
return entry - m_selectedNodes.begin();
}
}
size_t SceneNodeSelectionList::AddSelectedNode(AZStd::string&& name)
{
auto unselectedEntry = AZStd::find(m_unselectedNodes.begin(), m_unselectedNodes.end(), name);
if (unselectedEntry != m_unselectedNodes.end())
{
m_unselectedNodes.erase(unselectedEntry);
}
auto entry = AZStd::find(m_selectedNodes.begin(), m_selectedNodes.end(), name);
if (entry == m_selectedNodes.end())
{
size_t index = m_selectedNodes.size();
m_selectedNodes.push_back(AZStd::move(name));
return index;
}
else
{
return entry - m_selectedNodes.begin();
}
}
void SceneNodeSelectionList::RemoveSelectedNode(size_t index)
{
if (index < m_selectedNodes.size())
{
auto unselectedEntry = AZStd::find(m_unselectedNodes.begin(), m_unselectedNodes.end(), m_selectedNodes[index]);
if (unselectedEntry == m_unselectedNodes.end())
{
m_unselectedNodes.push_back(m_selectedNodes[index]);
}
m_selectedNodes.erase(m_selectedNodes.begin() + index);
}
}
void SceneNodeSelectionList::RemoveSelectedNode(const AZStd::string& name)
{
auto selectEntry = AZStd::find(m_selectedNodes.begin(), m_selectedNodes.end(), name);
if (selectEntry != m_selectedNodes.end())
{
m_selectedNodes.erase(selectEntry);
}
auto entry = AZStd::find(m_unselectedNodes.begin(), m_unselectedNodes.end(), name);
if (entry == m_unselectedNodes.end())
{
m_unselectedNodes.push_back(name);
}
}
void SceneNodeSelectionList::ClearSelectedNodes()
{
m_selectedNodes.clear();
}
size_t SceneNodeSelectionList::GetUnselectedNodeCount() const
{
return m_unselectedNodes.size();
}
const AZStd::string& SceneNodeSelectionList::GetUnselectedNode(size_t index) const
{
AZ_Assert(index < m_unselectedNodes.size(), "Invalid index %i for unselected node in mesh group.", index);
return m_unselectedNodes[index];
}
void SceneNodeSelectionList::ClearUnselectedNodes()
{
m_unselectedNodes.clear();
}
AZStd::unique_ptr<DataTypes::ISceneNodeSelectionList> SceneNodeSelectionList::Copy() const
{
return AZStd::unique_ptr<DataTypes::ISceneNodeSelectionList>(new SceneNodeSelectionList(*this));
}
void SceneNodeSelectionList::CopyTo(DataTypes::ISceneNodeSelectionList& other) const
{
other.ClearSelectedNodes();
other.ClearUnselectedNodes();
for (const AZStd::string& selected : m_selectedNodes)
{
other.AddSelectedNode(selected);
}
for (const AZStd::string& unselected : m_unselectedNodes)
{
other.RemoveSelectedNode(unselected);
}
}
void SceneNodeSelectionList::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<SceneNodeSelectionList, DataTypes::ISceneNodeSelectionList>()->Version(1)
->Field("selectedNodes", &SceneNodeSelectionList::m_selectedNodes)
->Field("unselectedNodes", &SceneNodeSelectionList::m_unselectedNodes);
}
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,73 @@
#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/JSON/document.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <SceneAPI/SceneCore/DataTypes/ManifestBase/ISceneNodeSelectionList.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace DataTypes
{
class IManifestObject;
}
namespace SceneData
{
class SceneNodeSelectionList
: public DataTypes::ISceneNodeSelectionList
{
public:
AZ_RTTI(SceneNodeSelectionList, "{D0CE66CE-1BAD-42F5-86ED-3923573B3A02}", DataTypes::ISceneNodeSelectionList);
~SceneNodeSelectionList() override;
SCENE_DATA_API size_t GetSelectedNodeCount() const override;
SCENE_DATA_API const AZStd::string& GetSelectedNode(size_t index) const override;
SCENE_DATA_API size_t AddSelectedNode(const AZStd::string& name) override;
SCENE_DATA_API size_t AddSelectedNode(AZStd::string&& name) override;
SCENE_DATA_API void RemoveSelectedNode(size_t index) override;
SCENE_DATA_API void RemoveSelectedNode(const AZStd::string& name) override;
SCENE_DATA_API void ClearSelectedNodes() override;
SCENE_DATA_API size_t GetUnselectedNodeCount() const override;
SCENE_DATA_API const AZStd::string& GetUnselectedNode(size_t index) const override;
SCENE_DATA_API void ClearUnselectedNodes() override;
SCENE_DATA_API AZStd::unique_ptr<DataTypes::ISceneNodeSelectionList> Copy() const override;
SCENE_DATA_API void CopyTo(DataTypes::ISceneNodeSelectionList& other) const override;
static void Reflect(AZ::ReflectContext* context);
protected:
AZStd::vector<AZStd::string> m_selectedNodes;
AZStd::vector<AZStd::string> m_unselectedNodes;
};
inline SceneNodeSelectionList::~SceneNodeSelectionList() = default;
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,131 @@
/*
* 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/SystemAllocator.h>
#include <AzCore/std/containers/unordered_set.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneData/ManifestMetaInfoHandler.h>
#include <SceneAPI/SceneData/Groups/MeshGroup.h>
#include <SceneAPI/SceneData/Groups/SkeletonGroup.h>
#include <SceneAPI/SceneData/Groups/SkinGroup.h>
#include <SceneAPI/SceneData/Groups/AnimationGroup.h>
#include <SceneAPI/SceneData/Rules/BlendShapeRule.h>
#include <SceneAPI/SceneData/Rules/CommentRule.h>
#include <SceneAPI/SceneData/Rules/LodRule.h>
#include <SceneAPI/SceneData/Rules/MaterialRule.h>
#include <SceneAPI/SceneData/Rules/StaticMeshAdvancedRule.h>
#include <SceneAPI/SceneData/Rules/OriginRule.h>
#include <SceneAPI/SceneData/Rules/ScriptProcessorRule.h>
#include <SceneAPI/SceneData/Rules/SkeletonProxyRule.h>
#include <SceneAPI/SceneData/Rules/SkinMeshAdvancedRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(ManifestMetaInfoHandler, SystemAllocator, 0)
ManifestMetaInfoHandler::ManifestMetaInfoHandler()
{
BusConnect();
}
ManifestMetaInfoHandler::~ManifestMetaInfoHandler()
{
BusDisconnect();
}
void ManifestMetaInfoHandler::GetAvailableModifiers(ModifiersList& modifiers, const Containers::Scene& /*scene*/,
const DataTypes::IManifestObject& target)
{
AZ_TraceContext("Object Type", target.RTTI_GetTypeName());
modifiers.push_back(SceneData::CommentRule::TYPEINFO_Uuid());
modifiers.push_back(SceneData::ScriptProcessorRule::TYPEINFO_Uuid());
if (target.RTTI_IsTypeOf(DataTypes::IMeshGroup::TYPEINFO_Uuid()))
{
const DataTypes::IMeshGroup* group = azrtti_cast<const DataTypes::IMeshGroup*>(&target);
const Containers::RuleContainer& rules = group->GetRuleContainerConst();
AZStd::unordered_set<Uuid> existingRules;
const size_t ruleCount = rules.GetRuleCount();
for (size_t i = 0; i < ruleCount; ++i)
{
existingRules.insert(rules.GetRule(i)->RTTI_GetType());
}
if (existingRules.find(SceneData::LodRule::TYPEINFO_Uuid()) == existingRules.end())
{
modifiers.push_back(SceneData::LodRule::TYPEINFO_Uuid());
}
if (existingRules.find(SceneData::MaterialRule::TYPEINFO_Uuid()) == existingRules.end())
{
modifiers.push_back(SceneData::MaterialRule::TYPEINFO_Uuid());
}
if (existingRules.find(SceneData::StaticMeshAdvancedRule::TYPEINFO_Uuid()) == existingRules.end())
{
modifiers.push_back(SceneData::StaticMeshAdvancedRule::TYPEINFO_Uuid());
}
if (existingRules.find(SceneData::OriginRule::TYPEINFO_Uuid()) == existingRules.end())
{
modifiers.push_back(SceneData::OriginRule::TYPEINFO_Uuid());
}
}
else if (target.RTTI_IsTypeOf(DataTypes::ISkinGroup::TYPEINFO_Uuid()))
{
const DataTypes::ISkinGroup* group = azrtti_cast<const DataTypes::ISkinGroup*>(&target);
const Containers::RuleContainer& rules = group->GetRuleContainerConst();
AZStd::unordered_set<AZ::Uuid> existingRules;
const size_t ruleCount = rules.GetRuleCount();
for (size_t i = 0; i < ruleCount; ++i)
{
existingRules.insert(rules.GetRule(i)->RTTI_GetType());
}
if (existingRules.find(SceneData::BlendShapeRule::TYPEINFO_Uuid()) == existingRules.end())
{
modifiers.push_back(SceneData::BlendShapeRule::TYPEINFO_Uuid());
}
if (existingRules.find(SceneData::LodRule::TYPEINFO_Uuid()) == existingRules.end())
{
modifiers.push_back(SceneData::LodRule::TYPEINFO_Uuid());
}
if (existingRules.find(SceneData::MaterialRule::TYPEINFO_Uuid()) == existingRules.end())
{
modifiers.push_back(SceneData::MaterialRule::TYPEINFO_Uuid());
}
if (existingRules.find(SceneData::SkinMeshAdvancedRule::TYPEINFO_Uuid()) == existingRules.end())
{
modifiers.push_back(SceneData::SkinMeshAdvancedRule::TYPEINFO_Uuid());
}
}
else if (target.RTTI_IsTypeOf(DataTypes::ISkeletonGroup::TYPEINFO_Uuid()))
{
const DataTypes::ISkeletonGroup* group = azrtti_cast<const DataTypes::ISkeletonGroup*>(&target);
const Containers::RuleContainer& rules = group->GetRuleContainerConst();
AZStd::unordered_set<AZ::Uuid> existingRules;
const size_t ruleCount = rules.GetRuleCount();
for (size_t i = 0; i < ruleCount; ++i)
{
existingRules.insert(rules.GetRule(i)->RTTI_GetType());
}
}
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,36 @@
#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/Events/ManifestMetaInfoBus.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
class ManifestMetaInfoHandler : public Events::ManifestMetaInfoBus::Handler
{
public:
AZ_CLASS_ALLOCATOR_DECL
ManifestMetaInfoHandler();
~ManifestMetaInfoHandler() override;
void GetAvailableModifiers(ModifiersList& modifiers, const Containers::Scene& scene, const DataTypes::IManifestObject& target) override;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,13 @@
#
# 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.
#
set(FILES
)
@@ -0,0 +1,21 @@
#
# 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.
#
set(FILES
../../../SceneCore/Containers/SceneManifest.h
../../../SceneCore/Containers/SceneManifest.inl
../../../SceneCore/Containers/SceneManifest.cpp
../../../SceneCore/Events/AssetImportRequest.cpp
../../../SceneCore/Events/AssetImportRequest.h
../../../SceneCore/Events/ManifestMetaInfoBus.cpp
../../../SceneCore/Events/ManifestMetaInfoBus.h
../../../SceneCore/Events/GraphMetaInfoBus.h
)
@@ -0,0 +1,13 @@
#
# 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.
#
set(FILES
)
@@ -0,0 +1,107 @@
/*
* 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 <SceneAPI/SceneData/ReflectionRegistrar.h>
#include <SceneAPI/SceneData/Groups/MeshGroup.h>
#include <SceneAPI/SceneData/Groups/SkeletonGroup.h>
#include <SceneAPI/SceneData/Groups/SkinGroup.h>
#include <SceneAPI/SceneData/Groups/AnimationGroup.h>
#include <SceneAPI/SceneData/Rules/BlendShapeRule.h>
#include <SceneAPI/SceneData/Rules/CommentRule.h>
#include <SceneAPI/SceneData/Rules/LodRule.h>
#include <SceneAPI/SceneData/Rules/StaticMeshAdvancedRule.h>
#include <SceneAPI/SceneData/Rules/SkinMeshAdvancedRule.h>
#include <SceneAPI/SceneData/Rules/OriginRule.h>
#include <SceneAPI/SceneData/Rules/MaterialRule.h>
#include <SceneAPI/SceneData/Rules/ScriptProcessorRule.h>
#include <SceneAPI/SceneData/Rules/SkeletonProxyRule.h>
#include <SceneAPI/SceneData/Rules/TangentsRule.h>
#include <SceneAPI/SceneData/ManifestBase/SceneNodeSelectionList.h>
#include <SceneAPI/SceneData/GraphData/AnimationData.h>
#include <SceneAPI/SceneData/GraphData/BlendShapeData.h>
#include <SceneAPI/SceneData/GraphData/BoneData.h>
#include <SceneAPI/SceneData/GraphData/MaterialData.h>
#include <SceneAPI/SceneData/GraphData/MeshData.h>
#include <SceneAPI/SceneData/GraphData/MeshVertexColorData.h>
#include <SceneAPI/SceneData/GraphData/MeshVertexUVData.h>
#include <SceneAPI/SceneData/GraphData/MeshVertexTangentData.h>
#include <SceneAPI/SceneData/GraphData/MeshVertexBitangentData.h>
#include <SceneAPI/SceneData/GraphData/RootBoneData.h>
#include <SceneAPI/SceneData/GraphData/SkinMeshData.h>
#include <SceneAPI/SceneData/GraphData/SkinWeightData.h>
#include <SceneAPI/SceneData/GraphData/TransformData.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/RTTI/BehaviorContext.h>
namespace AZ
{
namespace SceneAPI
{
void RegisterDataTypeReflection(AZ::SerializeContext* context)
{
// Check if this library hasn't already been reflected. This can happen as the ResourceCompilerScene needs
// to explicitly load and reflect the SceneAPI libraries to discover the available extension, while
// Gems with system components need to do the same in the Project Configurator.
if (!context->IsRemovingReflection() && context->FindClassData(SceneData::MeshGroup::TYPEINFO_Uuid()))
{
return;
}
// Groups
SceneData::MeshGroup::Reflect(context);
SceneData::SkeletonGroup::Reflect(context);
SceneData::SkinGroup::Reflect(context);
SceneData::AnimationGroup::Reflect(context);
// Rules
SceneData::BlendShapeRule::Reflect(context);
SceneData::CommentRule::Reflect(context);
SceneData::LodRule::Reflect(context);
SceneData::StaticMeshAdvancedRule::Reflect(context);
SceneData::OriginRule::Reflect(context);
SceneData::MaterialRule::Reflect(context);
SceneData::ScriptProcessorRule::Reflect(context);
SceneData::SkeletonProxyRule::Reflect(context);
SceneData::SkinMeshAdvancedRule::Reflect(context);
SceneData::TangentsRule::Reflect(context);
// Utility
SceneData::SceneNodeSelectionList::Reflect(context);
// Graph objects
context->Class<AZ::SceneData::GraphData::AnimationData>()->Version(1);
context->Class<AZ::SceneData::GraphData::BlendShapeData>()->Version(1);
AZ::SceneData::GraphData::BoneData::Reflect(context);
AZ::SceneData::GraphData::MaterialData::Reflect(context);
context->Class<AZ::SceneData::GraphData::MeshData>()->Version(1);
context->Class<AZ::SceneData::GraphData::MeshVertexColorData>()->Version(1);
context->Class<AZ::SceneData::GraphData::MeshVertexUVData>()->Version(1);
context->Class<AZ::SceneData::GraphData::MeshVertexTangentData>()->Version(1);
context->Class<AZ::SceneData::GraphData::MeshVertexBitangentData>()->Version(1);
AZ::SceneData::GraphData::RootBoneData::Reflect(context);
context->Class<AZ::SceneData::GraphData::SkinMeshData>()->Version(1);
context->Class<AZ::SceneData::GraphData::SkinWeightData>()->Version(1);
AZ::SceneData::GraphData::TransformData::Reflect(context);
}
void RegisterDataTypeBehaviorReflection(AZ::BehaviorContext* context)
{
AZ::SceneData::GraphData::BoneData::Reflect(context);
AZ::SceneData::GraphData::MaterialData::Reflect(context);
AZ::SceneData::GraphData::RootBoneData::Reflect(context);
AZ::SceneData::GraphData::TransformData::Reflect(context);
}
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,24 @@
/*
* 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 <SceneAPI/SceneData/SceneDataConfiguration.h>
namespace AZ
{
class SerializeContext;
class BehaviorContext;
namespace SceneAPI
{
SCENE_DATA_API void RegisterDataTypeReflection(AZ::SerializeContext* context);
SCENE_DATA_API void RegisterDataTypeBehaviorReflection(AZ::BehaviorContext* context);
}
}
@@ -0,0 +1,72 @@
/*
* 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/SceneCore/DataTypes/GraphData/IBlendShapeData.h>
#include <SceneAPI/SceneData/GraphData/SkinMeshData.h>
#include <SceneAPI/SceneData/Rules/BlendShapeRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(BlendShapeRule, AZ::SystemAllocator, 0)
SceneNodeSelectionList& BlendShapeRule::GetNodeSelectionList()
{
return m_blendShapes;
}
DataTypes::ISceneNodeSelectionList& BlendShapeRule::GetSceneNodeSelectionList()
{
return m_blendShapes;
}
const DataTypes::ISceneNodeSelectionList& BlendShapeRule::GetSceneNodeSelectionList() const
{
return m_blendShapes;
}
void BlendShapeRule::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<BlendShapeRule, DataTypes::IBlendShapeRule>()->Version(1)
->Field("blendShapes", &BlendShapeRule::m_blendShapes);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<BlendShapeRule>("Blend shapes", "Select mesh targets to configure blend shapes at a later time using Lumberyard.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(AZ_CRC("ManifestName", 0x5215b349), &BlendShapeRule::m_blendShapes, "Select blend shapes",
"Select 1 or more meshes to include in the skin group for later use with the blend shape system.")
->Attribute("FilterName", "blend shapes")
->Attribute("FilterType", DataTypes::IBlendShapeData::TYPEINFO_Uuid())
->Attribute("NarrowSelection", true);
}
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,52 @@
#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/std/containers/vector.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IBlendShapeRule.h>
#include <SceneAPI/SceneData/ManifestBase/SceneNodeSelectionList.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace SceneData
{
class SCENE_DATA_CLASS BlendShapeRule
: public DataTypes::IBlendShapeRule
{
public:
AZ_RTTI(BlendShapeRule, "{E9D04F75-735B-484B-A6F1-5B91F92B36B4}", DataTypes::IBlendShapeRule);
AZ_CLASS_ALLOCATOR_DECL
SCENE_DATA_API ~BlendShapeRule() override = default;
SCENE_DATA_API SceneNodeSelectionList& GetNodeSelectionList();
SCENE_DATA_API DataTypes::ISceneNodeSelectionList& GetSceneNodeSelectionList() override;
SCENE_DATA_API const DataTypes::ISceneNodeSelectionList& GetSceneNodeSelectionList() const override;
static void Reflect(ReflectContext* context);
protected:
SceneNodeSelectionList m_blendShapes;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,56 @@
/*
* 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/CommentRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(CommentRule, AZ::SystemAllocator, 0)
const AZStd::string& CommentRule::GetComment() const
{
return m_comment;
}
void CommentRule::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<CommentRule, DataTypes::ICommentRule>()->Version(1)
->Field("comment", &CommentRule::m_comment);
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<CommentRule>("Comment", "Add an optional comment to the asset's properties.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement("MultiLineEdit", &CommentRule::m_comment, "", "Text for the comment.")
->Attribute("PlaceholderText", "Add comment text here");
}
}
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,49 @@
#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/std/string/string.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/ICommentRule.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace SceneData
{
class CommentRule
: public DataTypes::ICommentRule
{
public:
AZ_RTTI(CommentRule, "{9A20AC53-04B3-4A2F-A43F-338456974874}", DataTypes::ICommentRule);
AZ_CLASS_ALLOCATOR_DECL
~CommentRule() override = default;
const AZStd::string& GetComment() const override;
static void Reflect(ReflectContext* context);
protected:
AZStd::string m_comment;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,97 @@
/*
* 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/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <SceneAPI/SceneData/Rules/LodRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
const size_t LodRule::m_maxLods;
AZ_CLASS_ALLOCATOR_IMPL(LodRule, SystemAllocator, 0)
SceneNodeSelectionList& LodRule::GetNodeSelectionList(size_t index)
{
if (index < m_maxLods)
{
return m_nodeSelectionLists[index];
}
return *m_nodeSelectionLists.end();
}
DataTypes::ISceneNodeSelectionList& LodRule::GetSceneNodeSelectionList(size_t index)
{
if (index < m_maxLods)
{
return m_nodeSelectionLists[index];
}
return *m_nodeSelectionLists.end();
}
const DataTypes::ISceneNodeSelectionList& LodRule::GetSceneNodeSelectionList(size_t index) const
{
if (index < m_maxLods)
{
return m_nodeSelectionLists[index];
}
return *m_nodeSelectionLists.end();
}
size_t LodRule::GetLodCount() const
{
return m_nodeSelectionLists.size();
}
void LodRule::AddLod()
{
if (m_nodeSelectionLists.size() < m_nodeSelectionLists.capacity())
{
m_nodeSelectionLists.push_back(SceneNodeSelectionList());
}
}
void LodRule::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<LodRule, DataTypes::ILodRule>()->Version(1)
->Field("nodeSelectionList", &LodRule::m_nodeSelectionLists);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<LodRule>("Level of Detail", "Set up the level of detail for the meshes in this group.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute(AZ_CRC("AutoExpand", 0x306ff5c0), true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(Edit::UIHandlers::Default, &LodRule::m_nodeSelectionLists, "Lod Meshes", "Select the meshes to assign to each level of detail.")
->ElementAttribute(AZ_CRC("FilterName", 0xf49ce62e), "Lod meshes")
->ElementAttribute(AZ_CRC("FilterType", 0x2661cf01), DataTypes::IMeshData::TYPEINFO_Uuid());
}
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,59 @@
#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/std/containers/fixed_vector.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/ILodRule.h>
#include <SceneAPI/SceneData/ManifestBase/SceneNodeSelectionList.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace SceneData
{
class LodRule
: public DataTypes::ILodRule
{
public:
AZ_RTTI(LodRule, "{6E796AC8-1484-4909-860A-6D3F22A7346F}", DataTypes::ILodRule);
AZ_CLASS_ALLOCATOR_DECL
~LodRule() override = default;
SceneNodeSelectionList& GetNodeSelectionList(size_t index);
DataTypes::ISceneNodeSelectionList& GetSceneNodeSelectionList(size_t index) override;
const DataTypes::ISceneNodeSelectionList& GetSceneNodeSelectionList(size_t index) const override;
size_t GetLodCount() const override;
void AddLod();
static void Reflect(ReflectContext* context);
//The engine supports 6 total lods. 1 for the base model then 5 more lods.
//The rule only captures lods past level 0 so this is set to 5.
static const size_t m_maxLods = 5;
protected:
AZStd::fixed_vector<SceneNodeSelectionList, m_maxLods> m_nodeSelectionLists;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,68 @@
/*
* 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/MaterialRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(MaterialRule, SystemAllocator, 0)
MaterialRule::MaterialRule()
: m_removeMaterials(false)
, m_updateMaterials(false)
{
}
bool MaterialRule::RemoveUnusedMaterials() const
{
return m_removeMaterials;
}
bool MaterialRule::UpdateMaterials() const
{
return m_updateMaterials;
}
void MaterialRule::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<MaterialRule, DataTypes::IMaterialRule>()->Version(2)
->Field("updateMaterials", &MaterialRule::m_updateMaterials)
->Field("removeMaterials", &MaterialRule::m_removeMaterials);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<MaterialRule>("Material", "Determine whether to accept material updates from the source files.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(Edit::UIHandlers::Default, &MaterialRule::m_updateMaterials, "Update materials", "Checking this box will accept changes made in the source file into the Lumberyard asset.")
->DataElement(Edit::UIHandlers::Default, &MaterialRule::m_removeMaterials, "Remove unused materials","Detects and removes material files from the game project that are not present in the source file.");
}
}
} // namespace SceneData
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,51 @@
#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/IMaterialRule.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace SceneData
{
class MaterialRule
: public DataTypes::IMaterialRule
{
public:
AZ_RTTI(MaterialRule, "{35620013-A27C-4F6D-87BF-72F11688ACAD}", DataTypes::IMaterialRule);
AZ_CLASS_ALLOCATOR_DECL
MaterialRule();
~MaterialRule() override = default;
bool RemoveUnusedMaterials() const override;
bool UpdateMaterials() const override;
static void Reflect(ReflectContext* context);
protected:
bool m_removeMaterials;
bool m_updateMaterials;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,119 @@
/*
* 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
@@ -0,0 +1,66 @@
#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,52 @@
/*
* 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/ScriptProcessorRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
const AZStd::string& ScriptProcessorRule::GetScriptFilename() const
{
return m_scriptFilename;
}
void ScriptProcessorRule::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<ScriptProcessorRule, DataTypes::IScriptProcessorRule>()->Version(1)
->Field("scriptFilename", &ScriptProcessorRule::m_scriptFilename);
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<ScriptProcessorRule>("ScriptProcessorRule", "Script rule settings to process a scene asset file")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(0, &ScriptProcessorRule::m_scriptFilename, "scriptFilename",
"Relative path to scene processor Python script.");
}
}
}
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,49 @@
/*
* 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 <AzCore/Memory/Memory.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IScriptProcessorRule.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace SceneData
{
class ScriptProcessorRule
: public DataTypes::IScriptProcessorRule
{
public:
AZ_RTTI(ScriptProcessorRule, "{E61EDCBC-867A-4A6A-B49D-C87E60D3EC33}", DataTypes::IScriptProcessorRule);
AZ_CLASS_ALLOCATOR(ScriptProcessorRule, AZ::SystemAllocator, 0)
~ScriptProcessorRule() override = default;
const AZStd::string& GetScriptFilename() const override;
inline void SetScriptFilename(AZStd::string scriptFilename)
{
m_scriptFilename = AZStd::move(scriptFilename);
}
static void Reflect(ReflectContext* context);
protected:
AZStd::string m_scriptFilename;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,108 @@
/*
* 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/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <SceneAPI/SceneData/Rules/SkeletonProxyRule.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
void SkeletonProxy::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<SkeletonProxy>()->Version(1)
->Field("jointName", &SkeletonProxy::m_jointName)
->Field("proxyName", &SkeletonProxy::m_proxyName);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<SkeletonProxy>("Skeleton proxy", "Select the physics mesh for ragdoll or for hit detection.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(Edit::UIHandlers::Default, &SkeletonProxy::m_jointName, "Joint name", "Select the skeleton joint for this proxy.")
->DataElement(Edit::UIHandlers::Default, &SkeletonProxy::m_proxyName, "Proxy name", "Pick the physics mesh.");
}
}
AZ_CLASS_ALLOCATOR_IMPL(SkeletonProxyGroup, SystemAllocator, 0)
void SkeletonProxyGroup::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<SkeletonProxyGroup>()->Version(1)
->Field("proxyMaterial", &SkeletonProxyGroup::m_proxyMaterialName)
->Field("skeletonProxies", &SkeletonProxyGroup::m_skeletonProxies);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<SkeletonProxyGroup>("Skeleton proxy group", "Related group of skeleton physics proxies.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(Edit::UIHandlers::Default, &SkeletonProxyGroup::m_proxyMaterialName, "Proxy material name", "Name the material for the physics mesh.")
->DataElement(Edit::UIHandlers::Default, &SkeletonProxyGroup::m_skeletonProxies, "Skeleton proxies", "Select the physics mesh for ragdoll or for hit detection.");
}
}
AZ_CLASS_ALLOCATOR_IMPL(SkeletonProxyRule, SystemAllocator, 0)
size_t SkeletonProxyRule::GetProxyGroupCount() const
{
return m_proxyGroups.size();
}
void SkeletonProxyRule::Reflect(ReflectContext* context)
{
SkeletonProxyGroup::Reflect(context);
SkeletonProxy::Reflect(context);
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<SkeletonProxyRule, DataTypes::ISkeletonProxyRule>()->Version(1)
->Field("skeletonProxyGroups", &SkeletonProxyRule::m_proxyGroups);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<SkeletonProxyRule>("Skeleton proxies", "Select the physics mesh for ragdoll or for hit detection.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(Edit::UIHandlers::Default, &SkeletonProxyRule::m_proxyGroups, "Proxy groups", "Proxy groups");
}
}
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,75 @@
#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/std/containers/fixed_vector.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/ISkeletonProxyRule.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace SceneData
{
struct SkeletonProxy
{
AZ_RTTI(SkeletonProxy, "{49E188A9-CA04-4B85-9AD8-A0262796EA27}");
virtual ~SkeletonProxy() = default;
AZStd::string m_jointName;
AZStd::string m_proxyName;
static void Reflect(ReflectContext* context);
};
struct SkeletonProxyGroup
{
AZ_RTTI(SkeletonProxyGroup, "{243B8186-EDDB-48C7-BCE7-FC2D1974B58A}");
AZ_CLASS_ALLOCATOR_DECL
virtual ~SkeletonProxyGroup() = default;
AZStd::string m_proxyMaterialName;
AZStd::vector<SkeletonProxy> m_skeletonProxies;
static void Reflect(ReflectContext* context);
};
class SkeletonProxyRule
: public DataTypes::ISkeletonProxyRule
{
public:
AZ_RTTI(SkeletonProxyRule, "{142CF206-FC12-4138-B30C-FFA64EC3BB4E}", DataTypes::ISkeletonProxyRule);
AZ_CLASS_ALLOCATOR_DECL
~SkeletonProxyRule() override = default;
size_t GetProxyGroupCount() const override;
const SkeletonProxyGroup& GetProxyGroup() const;
static void Reflect(ReflectContext* context);
protected:
AZStd::vector<SkeletonProxyGroup> m_proxyGroups;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,121 @@
/*
* 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/SkinMeshAdvancedRule.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexUVData.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(SkinMeshAdvancedRule, SystemAllocator, 0)
SkinMeshAdvancedRule::SkinMeshAdvancedRule()
: m_use32bitVertices(false)
, m_useCustomNormals(true)
{
AZ::SceneAPI::Events::AssetImportRequestBus::Broadcast(&AZ::SceneAPI::Events::AssetImportRequestBus::Events::AreCustomNormalsUsed, m_useCustomNormals);
}
void SkinMeshAdvancedRule::SetUse32bitVertices(bool value)
{
m_use32bitVertices = value;
}
bool SkinMeshAdvancedRule::Use32bitVertices() const
{
return m_use32bitVertices;
}
bool SkinMeshAdvancedRule::MergeMeshes() const
{
return true;
}
void SkinMeshAdvancedRule::SetUseCustomNormals(bool value)
{
m_useCustomNormals = value;
}
bool SkinMeshAdvancedRule::UseCustomNormals() const
{
return m_useCustomNormals;
}
void SkinMeshAdvancedRule::SetVertexColorStreamName(const AZStd::string& name)
{
m_vertexColorStreamName = name;
}
void SkinMeshAdvancedRule::SetVertexColorStreamName(AZStd::string&& name)
{
m_vertexColorStreamName = AZStd::move(name);
}
const AZStd::string& SkinMeshAdvancedRule::GetVertexColorStreamName() const
{
return m_vertexColorStreamName;
}
bool SkinMeshAdvancedRule::IsVertexColorStreamDisabled() const
{
return m_vertexColorStreamName == DataTypes::s_advancedDisabledString;
}
void SkinMeshAdvancedRule::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<SkinMeshAdvancedRule, DataTypes::IMeshAdvancedRule>()->Version(6)
->Field("use32bitVertices", &SkinMeshAdvancedRule::m_use32bitVertices)
->Field("useCustomNormals", &SkinMeshAdvancedRule::m_useCustomNormals)
->Field("vertexColorStreamName", &SkinMeshAdvancedRule::m_vertexColorStreamName);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<SkinMeshAdvancedRule>("Skin (Advanced)", "Configure advanced properties for this skin group.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(AZ::Edit::UIHandlers::RadioButton, &SkinMeshAdvancedRule::m_use32bitVertices, "Vertex Precision",
"Selecting 32-bits of precision increases the accuracy of the position of each vertex which can be useful when the skin is located far from its pivot.\n\n"
"Please note that not all platforms support 32-bit vertices. For more details please see documentation."
)
->Attribute(AZ::Edit::Attributes::FalseText, "16-bit")
->Attribute(AZ::Edit::Attributes::TrueText, "32-bit")
->DataElement(Edit::UIHandlers::Default, &SkinMeshAdvancedRule::m_useCustomNormals, "Use Custom Normals", "Use custom normals from DCC data or average them.")
->DataElement("NodeListSelection", &SkinMeshAdvancedRule::m_vertexColorStreamName, "Vertex Color Stream",
"Select a vertex color stream to enable Vertex Coloring or 'Disable' to turn Vertex Coloring off.\n\n"
"Vertex Coloring works in conjunction with materials. If a material was previously generated,\n"
"changing vertex coloring will require the material to be reset or the material editor to be used\n"
"to enable 'Vertex Coloring'.")
->Attribute("ClassTypeIdFilter", DataTypes::IMeshVertexColorData::TYPEINFO_Uuid())
->Attribute("DisabledOption", DataTypes::s_advancedDisabledString)
->Attribute("UseShortNames", true);
}
}
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,64 @@
#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/std/containers/fixed_vector.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IMeshAdvancedRule.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace SceneData
{
class SkinMeshAdvancedRule
: public DataTypes::IMeshAdvancedRule
{
public:
AZ_RTTI(SkinMeshAdvancedRule, "{0116376D-1E3E-472A-A173-112B317E96AD}", DataTypes::IMeshAdvancedRule);
AZ_CLASS_ALLOCATOR_DECL
SkinMeshAdvancedRule();
~SkinMeshAdvancedRule() override = default;
void SetUse32bitVertices(bool value);
bool Use32bitVertices() const override;
bool MergeMeshes() const override;
void SetUseCustomNormals(bool value);
bool UseCustomNormals() const override;
void SetVertexColorStreamName(const AZStd::string& name);
void SetVertexColorStreamName(AZStd::string&& name);
const AZStd::string& GetVertexColorStreamName() const override;
bool IsVertexColorStreamDisabled() const override;
static void Reflect(ReflectContext* context);
protected:
AZStd::string m_vertexColorStreamName;
bool m_use32bitVertices;
bool m_useCustomNormals;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,130 @@
/*
* 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/StaticMeshAdvancedRule.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexUVData.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
AZ_CLASS_ALLOCATOR_IMPL(StaticMeshAdvancedRule, SystemAllocator, 0)
StaticMeshAdvancedRule::StaticMeshAdvancedRule()
: m_use32bitVertices(false)
, m_mergeMeshes(true)
, m_useCustomNormals(true)
{
AZ::SceneAPI::Events::AssetImportRequestBus::Broadcast(&AZ::SceneAPI::Events::AssetImportRequestBus::Events::AreCustomNormalsUsed, m_useCustomNormals);
}
void StaticMeshAdvancedRule::SetUse32bitVertices(bool value)
{
m_use32bitVertices = value;
}
bool StaticMeshAdvancedRule::Use32bitVertices() const
{
return m_use32bitVertices;
}
void StaticMeshAdvancedRule::SetMergeMeshes(bool value)
{
m_mergeMeshes = value;
}
bool StaticMeshAdvancedRule::MergeMeshes() const
{
return m_mergeMeshes;
}
void StaticMeshAdvancedRule::SetUseCustomNormals(bool value)
{
m_useCustomNormals = value;
}
bool StaticMeshAdvancedRule::UseCustomNormals() const
{
return m_useCustomNormals;
}
void StaticMeshAdvancedRule::SetVertexColorStreamName(const AZStd::string& name)
{
m_vertexColorStreamName = name;
}
void StaticMeshAdvancedRule::SetVertexColorStreamName(AZStd::string&& name)
{
m_vertexColorStreamName = AZStd::move(name);
}
const AZStd::string& StaticMeshAdvancedRule::GetVertexColorStreamName() const
{
return m_vertexColorStreamName;
}
bool StaticMeshAdvancedRule::IsVertexColorStreamDisabled() const
{
return m_vertexColorStreamName == DataTypes::s_advancedDisabledString;
}
void StaticMeshAdvancedRule::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<StaticMeshAdvancedRule, DataTypes::IMeshAdvancedRule>()->Version(6)
->Field("use32bitVertices", &StaticMeshAdvancedRule::m_use32bitVertices)
->Field("mergeMeshes", &StaticMeshAdvancedRule::m_mergeMeshes)
->Field("useCustomNormals", &StaticMeshAdvancedRule::m_useCustomNormals)
->Field("vertexColorStreamName", &StaticMeshAdvancedRule::m_vertexColorStreamName);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<StaticMeshAdvancedRule>("Mesh (Advanced)", "Configure advanced properties for this mesh group.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(AZ::Edit::UIHandlers::RadioButton, &StaticMeshAdvancedRule::m_use32bitVertices, "Vertex Precision",
"Selecting 32-bits of precision increases the accuracy of the position of each vertex which can be useful when the mesh is located far from its pivot.\n\n"
"Please note that not all platforms support 32-bit vertices. For more details please see documentation."
)
->Attribute(AZ::Edit::Attributes::FalseText, "16-bit")
->Attribute(AZ::Edit::Attributes::TrueText, "32-bit")
->DataElement(Edit::UIHandlers::Default, &StaticMeshAdvancedRule::m_mergeMeshes, "Merge Meshes", "Merge all meshes into one single mesh.")
->DataElement(Edit::UIHandlers::Default, &StaticMeshAdvancedRule::m_useCustomNormals, "Use Custom Normals", "Use custom normals from DCC data or average them.")
->DataElement("NodeListSelection", &StaticMeshAdvancedRule::m_vertexColorStreamName, "Vertex Color Stream",
"Select a vertex color stream to enable Vertex Coloring or 'Disable' to turn Vertex Coloring off.\n\n"
"Vertex Coloring works in conjunction with materials. If a material was previously generated,\n"
"changing vertex coloring will require the material to be reset or the material editor to be used\n"
"to enable 'Vertex Coloring'.")
->Attribute("ClassTypeIdFilter", DataTypes::IMeshVertexColorData::TYPEINFO_Uuid())
->Attribute("DisabledOption", DataTypes::s_advancedDisabledString)
->Attribute("UseShortNames", true);
}
}
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,66 @@
#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/std/containers/fixed_vector.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IMeshAdvancedRule.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace SceneData
{
class StaticMeshAdvancedRule
: public DataTypes::IMeshAdvancedRule
{
public:
AZ_RTTI(StaticMeshAdvancedRule, "{AE82749D-A68A-4FE7-A8BA-0F4CE67607AC}", DataTypes::IMeshAdvancedRule);
AZ_CLASS_ALLOCATOR_DECL
StaticMeshAdvancedRule();
~StaticMeshAdvancedRule() override = default;
void SetUse32bitVertices(bool value);
bool Use32bitVertices() const override;
void SetMergeMeshes(bool value);
bool MergeMeshes() const override;
void SetUseCustomNormals(bool value);
bool UseCustomNormals() const override;
void SetVertexColorStreamName(const AZStd::string& name);
void SetVertexColorStreamName(AZStd::string&& name);
const AZStd::string& GetVertexColorStreamName() const override;
bool IsVertexColorStreamDisabled() const override;
static void Reflect(ReflectContext* context);
protected:
AZStd::string m_vertexColorStreamName;
bool m_use32bitVertices;
bool m_mergeMeshes;
bool m_useCustomNormals;
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,182 @@
/*
* 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/TangentsRule.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexUVData.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexTangentData.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexBitangentData.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphChildIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneData
{
TangentsRule::TangentsRule()
: DataTypes::IRule()
, m_tangentSpace(AZ::SceneAPI::DataTypes::TangentSpace::MikkT)
, m_bitangentMethod(AZ::SceneAPI::DataTypes::BitangentMethod::Orthogonal)
, m_uvSetIndex(0)
, m_normalize(true)
{
}
AZ::SceneAPI::DataTypes::TangentSpace TangentsRule::GetTangentSpace() const
{
return m_tangentSpace;
}
AZ::SceneAPI::DataTypes::BitangentMethod TangentsRule::GetBitangentMethod() const
{
return m_bitangentMethod;
}
AZ::u64 TangentsRule::GetUVSetIndex() const
{
return m_uvSetIndex;
}
bool TangentsRule::GetNormalizeVectors() const
{
return m_normalize;
}
// Find UV data.
AZ::SceneAPI::DataTypes::IMeshVertexUVData* TangentsRule::FindUVData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 uvSet)
{
const auto nameContentView = AZ::SceneAPI::Containers::Views::MakePairView(graph.GetNameStorage(), graph.GetContentStorage());
AZ::u64 uvSetIndex = 0;
auto meshChildView = AZ::SceneAPI::Containers::Views::MakeSceneGraphChildView<AZ::SceneAPI::Containers::Views::AcceptEndPointsOnly>(graph, nodeIndex, nameContentView.begin(), true);
for (auto child = meshChildView.begin(); child != meshChildView.end(); ++child)
{
AZ::SceneAPI::DataTypes::IMeshVertexUVData* data = azrtti_cast<AZ::SceneAPI::DataTypes::IMeshVertexUVData*>(child->second.get());
if (data)
{
if (uvSetIndex == uvSet)
{
return data;
}
uvSetIndex++;
}
}
return nullptr;
}
// Find tangent data.
AZ::SceneAPI::DataTypes::IMeshVertexTangentData* TangentsRule::FindTangentData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 setIndex, AZ::SceneAPI::DataTypes::TangentSpace tangentSpace)
{
const auto nameContentView = AZ::SceneAPI::Containers::Views::MakePairView(graph.GetNameStorage(), graph.GetContentStorage());
auto meshChildView = AZ::SceneAPI::Containers::Views::MakeSceneGraphChildView<AZ::SceneAPI::Containers::Views::AcceptEndPointsOnly>(graph, nodeIndex, nameContentView.begin(), true);
for (auto child = meshChildView.begin(); child != meshChildView.end(); ++child)
{
AZ::SceneAPI::DataTypes::IMeshVertexTangentData* data = azrtti_cast<AZ::SceneAPI::DataTypes::IMeshVertexTangentData*>(child->second.get());
if (data)
{
if (setIndex == data->GetTangentSetIndex() && tangentSpace == data->GetTangentSpace())
{
return data;
}
}
}
return nullptr;
}
// Find bitangent data.
AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* TangentsRule::FindBitangentData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 setIndex, AZ::SceneAPI::DataTypes::TangentSpace tangentSpace)
{
const auto nameContentView = AZ::SceneAPI::Containers::Views::MakePairView(graph.GetNameStorage(), graph.GetContentStorage());
auto meshChildView = AZ::SceneAPI::Containers::Views::MakeSceneGraphChildView<AZ::SceneAPI::Containers::Views::AcceptEndPointsOnly>(graph, nodeIndex, nameContentView.begin(), true);
for (auto child = meshChildView.begin(); child != meshChildView.end(); ++child)
{
AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* data = azrtti_cast<AZ::SceneAPI::DataTypes::IMeshVertexBitangentData*>(child->second.get());
if (data)
{
if (setIndex == data->GetBitangentSetIndex() && tangentSpace == data->GetTangentSpace())
{
return data;
}
}
}
return nullptr;
}
AZ::Crc32 TangentsRule::GetNormalizeVisibility() const
{
return (m_tangentSpace == AZ::SceneAPI::DataTypes::TangentSpace::EMotionFX) ? AZ::Edit::PropertyVisibility::Hide : AZ::Edit::PropertyVisibility::Show;
}
AZ::Crc32 TangentsRule::GetOrthogonalVisibility() const
{
return (m_tangentSpace == AZ::SceneAPI::DataTypes::TangentSpace::EMotionFX) ? AZ::Edit::PropertyVisibility::Hide : AZ::Edit::PropertyVisibility::Show;
}
void TangentsRule::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<TangentsRule, DataTypes::IRule>()->Version(1)
->Field("tangentSpace", &TangentsRule::m_tangentSpace)
->Field("bitangentMethod", &TangentsRule::m_bitangentMethod)
->Field("normalize", &TangentsRule::m_normalize)
->Field("uvSetIndex", &TangentsRule::m_uvSetIndex);
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<TangentsRule>("Tangents", "Specify how tangents are imported or generated.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute("AutoExpand", true)
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->DataElement(AZ::Edit::UIHandlers::ComboBox, &AZ::SceneAPI::SceneData::TangentsRule::m_tangentSpace, "Tangent space", "Specify the tangent space used for normal map baking. Choose 'From Fbx' to extract the tangents and bitangents directly from the Fbx file. When there is no tangents rule or the Fbx has no tangents stored inside it, the 'MikkT' option will be used with orthogonal tangents of unit length, so with the normalize option enabled, using the first UV set.")
->EnumAttribute(AZ::SceneAPI::DataTypes::TangentSpace::FromFbx, "From Fbx")
->EnumAttribute(AZ::SceneAPI::DataTypes::TangentSpace::MikkT, "MikkT")
->EnumAttribute(AZ::SceneAPI::DataTypes::TangentSpace::EMotionFX, "EMotion FX")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
->DataElement(AZ::Edit::UIHandlers::ComboBox, &AZ::SceneAPI::SceneData::TangentsRule::m_bitangentMethod, "Bitangents", "Set to 'use from tangent space' to use the bitangents generated by the algorithm used or inside the fbx file. This can result in non-orthogonal tangents. Set to 'orthogonal' to skip storing the bitangents and let the engine calculate the bitangents in a way it will be perpendicular to both the normal and tangent.")
->EnumAttribute(AZ::SceneAPI::DataTypes::BitangentMethod::UseFromTangentSpace, "Use from tangent space")
->EnumAttribute(AZ::SceneAPI::DataTypes::BitangentMethod::Orthogonal, "Orthogonal")
->Attribute(AZ::Edit::Attributes::Visibility, &TangentsRule::GetOrthogonalVisibility)
->DataElement(AZ::Edit::UIHandlers::Default, &TangentsRule::m_uvSetIndex, "Uv set", "The UV set index to generate the tangents from. A value of 0 means the first uv set, while 1 means the second uv set.")
->Attribute(AZ::Edit::Attributes::Min, 0)
->Attribute(AZ::Edit::Attributes::Max, 1)
->DataElement(AZ::Edit::UIHandlers::Default, &TangentsRule::m_normalize, "Normalize", "Normalize the tangents and bitangents? When disabled the vectors might no be unit length, which can be useful for relief mapping.")
->Attribute(AZ::Edit::Attributes::Visibility, &TangentsRule::GetNormalizeVisibility)
;
}
}
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,74 @@
/*
* 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 <AzCore/Memory/Memory.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IRule.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexTangentData.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace DataTypes
{
class IMeshVertexUVData;
class IMeshVertexTangentData;
class IMeshVertexBitangentData;
}
namespace SceneData
{
class SCENE_DATA_CLASS TangentsRule
: public DataTypes::IRule
{
public:
AZ_RTTI(TangentsRule, "{4BD1CE13-D2EB-4CCF-AB21-4877EF69DE7D}", DataTypes::IRule);
AZ_CLASS_ALLOCATOR(TangentsRule, AZ::SystemAllocator, 0)
SCENE_DATA_API TangentsRule();
SCENE_DATA_API ~TangentsRule() override = default;
SCENE_DATA_API AZ::SceneAPI::DataTypes::TangentSpace GetTangentSpace() const;
SCENE_DATA_API AZ::SceneAPI::DataTypes::BitangentMethod GetBitangentMethod() const;
SCENE_DATA_API AZ::u64 GetUVSetIndex() const;
SCENE_DATA_API bool GetNormalizeVectors() const;
SCENE_DATA_API static AZ::SceneAPI::DataTypes::IMeshVertexUVData* FindUVData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 uvSet);
SCENE_DATA_API static AZ::SceneAPI::DataTypes::IMeshVertexTangentData* FindTangentData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 setIndex, AZ::SceneAPI::DataTypes::TangentSpace tangentSpace);
SCENE_DATA_API static AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* FindBitangentData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 setIndex, AZ::SceneAPI::DataTypes::TangentSpace tangentSpace);
static void Reflect(ReflectContext* context);
protected:
AZ::Crc32 GetNormalizeVisibility() const;
AZ::Crc32 GetOrthogonalVisibility() const;
AZ::SceneAPI::DataTypes::TangentSpace m_tangentSpace; /**< Specifies how to handle tangents. Either generate them, or import them. */
AZ::SceneAPI::DataTypes::BitangentMethod m_bitangentMethod; /**< Grab the bitangents from the generator/source or use an orthogonal basis by always calculating them? */
AZ::u64 m_uvSetIndex; /**< Generate the tangents from this UV set. */
bool m_normalize; /**< Normalize the tangent and bitangents? */
};
} // SceneData
} // SceneAPI
} // AZ
@@ -0,0 +1,41 @@
#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/PlatformDef.h>
#if defined(AZ_PLATFORM_WINDOWS)
#define SCENE_DATA_CLASS
#if defined(AZ_MONOLITHIC_BUILD)
#define SCENE_DATA_API
#else
#if defined(SCENE_DATA_EXPORTS)
#define SCENE_DATA_API AZ_DLL_EXPORT
#else
#define SCENE_DATA_API AZ_DLL_IMPORT
#endif
#endif
#else
#if defined(AZ_MONOLITHIC_BUILD)
#define SCENE_DATA_CLASS
#define SCENE_DATA_API
#else
#if defined(SCENE_DATA_EXPORTS)
#define SCENE_DATA_CLASS AZ_DLL_EXPORT
#define SCENE_DATA_API AZ_DLL_EXPORT
#else
#define SCENE_DATA_CLASS AZ_DLL_IMPORT
#define SCENE_DATA_API AZ_DLL_IMPORT
#endif
#endif
#endif
@@ -0,0 +1,42 @@
/*
* 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/SystemAllocator.h>
#include <SceneAPI/SceneData/SceneDataStandaloneAllocator.h>
namespace AZ
{
namespace SceneAPI
{
bool SceneDataStandaloneAllocator::m_allocatorInitialized = false;
void SceneDataStandaloneAllocator::Initialize(AZ::EnvironmentInstance environment)
{
AZ::Environment::Attach(environment);
if (!AZ::AllocatorInstance<AZ::SystemAllocator>().IsReady())
{
AZ::AllocatorInstance<AZ::SystemAllocator>().Create();
m_allocatorInitialized = true;
}
}
void SceneDataStandaloneAllocator::TearDown()
{
if (m_allocatorInitialized)
{
AZ::AllocatorInstance<AZ::SystemAllocator>().Destroy();
}
AZ::Environment::Detach();
}
}
}
@@ -0,0 +1,31 @@
#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 <SceneAPI/SceneData/SceneDataConfiguration.h>
namespace AZ
{
namespace SceneAPI
{
class SceneDataStandaloneAllocator
{
public:
SCENE_DATA_API static void Initialize(AZ::EnvironmentInstance environment);
SCENE_DATA_API static void TearDown();
private:
static bool m_allocatorInitialized;
};
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,22 @@
#
# 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.
#
set(FILES
../SceneCore/Containers/SceneManifest.h
../SceneCore/Containers/SceneManifest.inl
../SceneCore/Containers/SceneManifest.cpp
../SceneCore/Events/AssetImportRequest.cpp
../SceneCore/Events/AssetImportRequest.h
../SceneCore/Events/ManifestMetaInfoBus.cpp
../SceneCore/Events/ManifestMetaInfoBus.h
../SceneCore/Events/GraphMetaInfoBus.cpp
../SceneCore/Events/GraphMetaInfoBus.h
)
@@ -0,0 +1,98 @@
#
# 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.
#
set(FILES
SceneDataConfiguration.h
DllMain.cpp
ManifestMetaInfoHandler.h
ManifestMetaInfoHandler.cpp
SceneDataStandaloneAllocator.h
SceneDataStandaloneAllocator.cpp
ReflectionRegistrar.h
ReflectionRegistrar.cpp
Behaviors/BehaviorsMeshGroup.cpp
Behaviors/BehaviorsSkeletonGroup.cpp
Behaviors/BehaviorsSkinGroup.cpp
Behaviors/Registry.h
Behaviors/Registry.cpp
Behaviors/MeshGroup.h
Behaviors/SkeletonGroup.h
Behaviors/SkinGroup.h
Behaviors/AnimationGroup.h
Behaviors/BehaviorsAnimationGroup.cpp
Behaviors/MeshAdvancedRule.h
Behaviors/MeshAdvancedRule.cpp
Behaviors/MaterialRuleBehavior.h
Behaviors/MaterialRuleBehavior.cpp
Behaviors/LodRuleBehavior.h
Behaviors/LodRuleBehavior.cpp
Behaviors/BlendShapeRuleBehavior.h
Behaviors/BlendShapeRuleBehavior.cpp
Behaviors/ScriptProcessorRuleBehavior.h
Behaviors/ScriptProcessorRuleBehavior.cpp
Groups/MeshGroup.h
Groups/MeshGroup.cpp
Groups/SkeletonGroup.h
Groups/SkeletonGroup.cpp
Groups/SkinGroup.h
Groups/SkinGroup.cpp
Groups/AnimationGroup.h
Groups/AnimationGroup.cpp
ManifestBase/SceneNodeSelectionList.h
ManifestBase/SceneNodeSelectionList.cpp
Rules/BlendShapeRule.h
Rules/BlendShapeRule.cpp
Rules/CommentRule.h
Rules/CommentRule.cpp
Rules/LodRule.h
Rules/LodRule.cpp
Rules/StaticMeshAdvancedRule.h
Rules/StaticMeshAdvancedRule.cpp
Rules/OriginRule.h
Rules/OriginRule.cpp
Rules/MaterialRule.h
Rules/MaterialRule.cpp
Rules/ScriptProcessorRule.h
Rules/ScriptProcessorRule.cpp
Rules/SkeletonProxyRule.h
Rules/SkeletonProxyRule.cpp
Rules/SkinMeshAdvancedRule.h
Rules/SkinMeshAdvancedRule.cpp
Rules/TangentsRule.h
Rules/TangentsRule.cpp
GraphData/MeshData.h
GraphData/MeshData.cpp
GraphData/MeshVertexColorData.h
GraphData/MeshVertexColorData.cpp
GraphData/MeshVertexUVData.h
GraphData/MeshVertexUVData.cpp
GraphData/MeshVertexTangentData.h
GraphData/MeshVertexTangentData.cpp
GraphData/MeshVertexBitangentData.h
GraphData/MeshVertexBitangentData.cpp
GraphData/MaterialData.h
GraphData/MaterialData.cpp
GraphData/TransformData.h
GraphData/TransformData.cpp
GraphData/MeshDataPrimitiveUtils.h
GraphData/MeshDataPrimitiveUtils.cpp
GraphData/BoneData.h
GraphData/BoneData.cpp
GraphData/RootBoneData.h
GraphData/RootBoneData.cpp
GraphData/SkinMeshData.h
GraphData/SkinWeightData.h
GraphData/SkinWeightData.cpp
GraphData/AnimationData.h
GraphData/AnimationData.cpp
GraphData/BlendShapeData.h
GraphData/BlendShapeData.cpp
)
@@ -0,0 +1,16 @@
#
# 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.
#
set(FILES
Tests/TestsMain.cpp
Tests/GraphData/MeshDataTests.cpp
Tests/GraphData/MeshDataPrimitiveUtilsTests.cpp
)
@@ -0,0 +1,160 @@
/*
* 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 <memory>
#include <AzTest/AzTest.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <SceneAPI/SceneData/GraphData/MeshDataPrimitiveUtils.h>
#include <SceneAPI/SceneData/GraphData/MeshData.h>
#include <float.h>
namespace AZ
{
namespace SceneData
{
// ===================================================
// == MeshDataPrimitiveUtilTests ==
// ===================================================
bool FaceWindingPointsDirection(const AZ::SceneAPI::DataTypes::IMeshData::Face& face, const std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData>& mesh, const AZ::Vector3 expectedNormal)
{
AZ::Vector3 v0 = mesh->GetPosition(face.vertexIndex[0]);
AZ::Vector3 v1 = mesh->GetPosition(face.vertexIndex[1]);
AZ::Vector3 v2 = mesh->GetPosition(face.vertexIndex[2]);
AZ::Vector3 dir1 = v1 - v0;
AZ::Vector3 dir2 = v2 - v0;
AZ::Vector3 normal = dir1.Cross(dir2);
return normal.Dot(expectedNormal) >= (1.0f - FLT_EPSILON);
}
bool PointsMatch(const AZ::Vector3& orig, const AZ::Vector3& testPosition)
{
if (orig.GetX() != testPosition.GetX())
{
return false;
}
if (orig.GetY() != testPosition.GetY())
{
return false;
}
if (orig.GetZ() != testPosition.GetZ())
{
return false;
}
return true;
}
TEST(MeshDataPrimitiveUtils, CreateBox_BasicValues_BoxHasCorrectTopology)
{
std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData> mesh
= AZ::SceneData::GraphData::MeshDataPrimitiveUtils::CreateBox(1.0f, 2.0f, 3.0f);
ASSERT_NE(nullptr, mesh);
EXPECT_EQ(8, mesh->GetVertexCount());
EXPECT_EQ(12, mesh->GetFaceCount());
}
TEST(MeshDataPrimitiveUtils, CreateBox_BasicVectorValues_BoxHasCorrectTopology)
{
AZ::Vector3 dims(1.0f, 2.0f, 3.0f);
std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData> mesh
= AZ::SceneData::GraphData::MeshDataPrimitiveUtils::CreateBox(dims);
ASSERT_NE(nullptr, mesh);
EXPECT_EQ(8, mesh->GetVertexCount());
EXPECT_EQ(12, mesh->GetFaceCount());
}
TEST(MeshDataPrimitiveUtils, CreateBox_BasicValues_XFacesPointCorrectDirection)
{
std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData> mesh
= AZ::SceneData::GraphData::MeshDataPrimitiveUtils::CreateBox(1.0f, 2.0f, 3.0f);
AZ::SceneAPI::DataTypes::IMeshData::Face face = mesh->GetFaceInfo(0);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(-1.0f, 0.0f, 0.0f)));
face = mesh->GetFaceInfo(1);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(-1.0f, 0.0f, 0.0f)));
face = mesh->GetFaceInfo(2);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(1.0f, 0.0f, 0.0f)));
face = mesh->GetFaceInfo(3);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(1.0f, 0.0f, 0.0f)));
}
TEST(MeshDataPrimitiveUtils, CreateBox_BasicValues_YFacesPointCorrectDirection)
{
std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData> mesh
= AZ::SceneData::GraphData::MeshDataPrimitiveUtils::CreateBox(1.0f, 2.0f, 3.0f);
AZ::SceneAPI::DataTypes::IMeshData::Face face = mesh->GetFaceInfo(4);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(0.0f, -1.0f, 0.0f)));
face = mesh->GetFaceInfo(5);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(0.0f, -1.0f, 0.0f)));
face = mesh->GetFaceInfo(6);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(0.0f, 1.0f, 0.0f)));
face = mesh->GetFaceInfo(7);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(0.0f, 1.0f, 0.0f)));
}
TEST(MeshDataPrimitiveUtils, CreateBox_BasicValues_ZFacesPointCorrectDirection)
{
std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData> mesh
= AZ::SceneData::GraphData::MeshDataPrimitiveUtils::CreateBox(1.0f, 2.0f, 3.0f);
AZ::SceneAPI::DataTypes::IMeshData::Face face = mesh->GetFaceInfo(8);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(0.0f, 0.0f, -1.0f)));
face = mesh->GetFaceInfo(9);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(0.0f, 0.0f, -1.0f)));
face = mesh->GetFaceInfo(10);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(0.0f, 0.0f, 1.0f)));
face = mesh->GetFaceInfo(11);
EXPECT_TRUE(FaceWindingPointsDirection(face, mesh, AZ::Vector3(0.0f, 0.0f, 1.0f)));
}
TEST(MeshDataPrimitiveUtils, CreateBox_BasicValues_VertexPositionsValid)
{
AZ::Vector3 dims(1.0f, 2.0f, 3.0f);
std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData> mesh
= AZ::SceneData::GraphData::MeshDataPrimitiveUtils::CreateBox(dims);
dims /= 2.0f;
AZ::Vector3 position = mesh->GetPosition(0);
EXPECT_TRUE(PointsMatch(Vector3(-dims.GetX(), -dims.GetY(), -dims.GetZ()), position));
position = mesh->GetPosition(1);
EXPECT_TRUE(PointsMatch(Vector3(-dims.GetX(), -dims.GetY(), dims.GetZ()), position));
position = mesh->GetPosition(2);
EXPECT_TRUE(PointsMatch(Vector3(-dims.GetX(), dims.GetY(), dims.GetZ()), position));
position = mesh->GetPosition(3);
EXPECT_TRUE(PointsMatch(Vector3(-dims.GetX(), dims.GetY(), -dims.GetZ()), position));
position = mesh->GetPosition(4);
EXPECT_TRUE(PointsMatch(Vector3(dims.GetX(), -dims.GetY(), -dims.GetZ()), position));
position = mesh->GetPosition(5);
EXPECT_TRUE(PointsMatch(Vector3(dims.GetX(), dims.GetY(), -dims.GetZ()), position));
position = mesh->GetPosition(6);
EXPECT_TRUE(PointsMatch(Vector3(dims.GetX(), dims.GetY(), dims.GetZ()), position));
position = mesh->GetPosition(7);
EXPECT_TRUE(PointsMatch(Vector3(dims.GetX(), -dims.GetY(), dims.GetZ()), position));
}
}
}
@@ -0,0 +1,125 @@
/*
* 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 <memory>
#include <AzTest/AzTest.h>
#include <SceneAPI/SceneData/GraphData/MeshData.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
namespace AZ
{
namespace SceneData
{
// ===================================================
// == MeshData Construction ==
// ===================================================
TEST(MeshData_Construction, Constructor_DefaultConstruction_PositionCountEqualsZero)
{
AZ::SceneData::GraphData::MeshData meshData;
EXPECT_EQ(0, meshData.GetVertexCount());
}
TEST(MeshData_Construction, Constructor_DefaultConstruction_HasNoNormalData)
{
AZ::SceneData::GraphData::MeshData meshData;
EXPECT_FALSE(meshData.HasNormalData());
}
TEST(MeshData_Construction, AddPosition_AddVector3_GetVertexCountEqualsOne)
{
AZ::SceneData::GraphData::MeshData meshData;
AZ::Vector3 position(1, 0, 0);
meshData.AddPosition(position);
EXPECT_EQ(1, meshData.GetVertexCount());
}
TEST(MeshData_Construction, AddPosition_AddVector3_GetPositionEqual)
{
AZ::SceneData::GraphData::MeshData meshData;
AZ::Vector3 position(0.1f, 0.2f, 0.3f);
meshData.AddPosition(position);
const AZ::Vector3& storedPosition = meshData.GetPosition(0);
EXPECT_FLOAT_EQ(position.GetX(), storedPosition.GetX());
EXPECT_FLOAT_EQ(position.GetY(), storedPosition.GetY());
EXPECT_FLOAT_EQ(position.GetZ(), storedPosition.GetZ());
}
TEST(MeshData_Construction, AddNormal_AddVector3_HasNormalData)
{
AZ::SceneData::GraphData::MeshData meshData;
AZ::Vector3 normal(1, 0, 0);
meshData.AddNormal(normal);
EXPECT_TRUE(meshData.HasNormalData());
}
TEST(MeshData_Construction, AddNormal_AddVector3_GetNormalEqual)
{
AZ::SceneData::GraphData::MeshData meshData;
AZ::Vector3 normal(0.1f, 0.2f, 0.3f);
meshData.AddNormal(normal);
const AZ::Vector3& storedNormal = meshData.GetNormal(0);
EXPECT_FLOAT_EQ(normal.GetX(), storedNormal.GetX());
EXPECT_FLOAT_EQ(normal.GetY(), storedNormal.GetY());
EXPECT_FLOAT_EQ(normal.GetZ(), storedNormal.GetZ());
}
TEST(MeshData_Construction, AddFace_AddValidFace_GetFaceEqual)
{
AZ::SceneData::GraphData::MeshData meshData;
AZ::SceneAPI::DataTypes::IMeshData::Face face;
face.vertexIndex[0] = 0;
face.vertexIndex[1] = 1;
face.vertexIndex[2] = 2;
meshData.AddFace(face);
EXPECT_EQ(1, meshData.GetFaceCount());
const AZ::SceneAPI::DataTypes::IMeshData::Face& testValue = meshData.GetFaceInfo(0);
EXPECT_EQ(testValue.vertexIndex[0], face.vertexIndex[0]);
EXPECT_EQ(testValue.vertexIndex[1], face.vertexIndex[1]);
EXPECT_EQ(testValue.vertexIndex[2], face.vertexIndex[2]);
}
TEST(MeshData_Construction, AddFace_AddValidFaceIndexes_GetFaceEqual)
{
AZ::SceneData::GraphData::MeshData meshData;
meshData.AddFace(0, 1, 2);
EXPECT_EQ(1, meshData.GetFaceCount());
const AZ::SceneAPI::DataTypes::IMeshData::Face& testValue = meshData.GetFaceInfo(0);
EXPECT_EQ(testValue.vertexIndex[0], 0);
EXPECT_EQ(testValue.vertexIndex[1], 1);
EXPECT_EQ(testValue.vertexIndex[2], 2);
}
TEST(MeshData_Construction, AddFace_AddValidFace_GetFaceMaterialEqual)
{
AZ::SceneData::GraphData::MeshData meshData;
AZ::SceneAPI::DataTypes::IMeshData::Face face;
face.vertexIndex[0] = 0;
face.vertexIndex[1] = 1;
face.vertexIndex[2] = 2;
meshData.AddFace(face);
EXPECT_EQ(0, meshData.GetFaceMaterialId(0));
}
}
}
@@ -0,0 +1,54 @@
/*
* 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 <AzTest/AzTest.h>
#include <AzCore/Module/DynamicModuleHandle.h>
#include <SceneAPI/SceneData/SceneDataStandaloneAllocator.h>
class SceneDataTestEnvironment
: public AZ::Test::ITestEnvironment
{
public:
virtual ~SceneDataTestEnvironment()
{}
protected:
void SetupEnvironment() override
{
AZ::Environment::Create(nullptr);
AZ::SceneAPI::SceneDataStandaloneAllocator::Initialize(AZ::Environment::GetInstance());
sceneCoreModule = AZ::DynamicModuleHandle::Create("SceneCore");
AZ_Assert(sceneCoreModule, "SceneData unit tests failed to create SceneCore module.");
bool loaded = sceneCoreModule->Load(false);
AZ_Assert(loaded, "SceneData unit tests failed to load SceneCore module.");
auto init = sceneCoreModule->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
AZ_Assert(init, "SceneData unit tests failed to find the initialization function the SceneCore module.");
(*init)(AZ::Environment::GetInstance());
}
void TeardownEnvironment() override
{
auto uninit = sceneCoreModule->GetFunction<AZ::UninitializeDynamicModuleFunction>(AZ::UninitializeDynamicModuleFunctionName);
AZ_Assert(uninit, "SceneData unit tests failed to find the uninitialization function the SceneCore module.");
(*uninit)();
sceneCoreModule.reset();
AZ::SceneAPI::SceneDataStandaloneAllocator::TearDown();
AZ::Environment::Destroy();
}
private:
AZStd::unique_ptr<AZ::DynamicModuleHandle> sceneCoreModule;
};
AZ_UNIT_TEST_HOOK(new SceneDataTestEnvironment);