SkinMeshAdvancedRule.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/RTTI/ReflectContext.h>
  9. #include <AzCore/Memory/SystemAllocator.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <AzCore/Serialization/EditContext.h>
  12. #include <SceneAPI/SceneData/Rules/SkinMeshAdvancedRule.h>
  13. #include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexUVData.h>
  14. #include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h>
  15. #include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
  16. namespace AZ
  17. {
  18. namespace SceneAPI
  19. {
  20. namespace SceneData
  21. {
  22. AZ_CLASS_ALLOCATOR_IMPL(SkinMeshAdvancedRule, SystemAllocator);
  23. SkinMeshAdvancedRule::SkinMeshAdvancedRule()
  24. : m_use32bitVertices(false)
  25. , m_useCustomNormals(true)
  26. {
  27. AZ::SceneAPI::Events::AssetImportRequestBus::Broadcast(&AZ::SceneAPI::Events::AssetImportRequestBus::Events::AreCustomNormalsUsed, m_useCustomNormals);
  28. }
  29. void SkinMeshAdvancedRule::SetUse32bitVertices(bool value)
  30. {
  31. m_use32bitVertices = value;
  32. }
  33. bool SkinMeshAdvancedRule::Use32bitVertices() const
  34. {
  35. return m_use32bitVertices;
  36. }
  37. bool SkinMeshAdvancedRule::MergeMeshes() const
  38. {
  39. return true;
  40. }
  41. void SkinMeshAdvancedRule::SetUseCustomNormals(bool value)
  42. {
  43. m_useCustomNormals = value;
  44. }
  45. bool SkinMeshAdvancedRule::UseCustomNormals() const
  46. {
  47. return m_useCustomNormals;
  48. }
  49. void SkinMeshAdvancedRule::SetVertexColorStreamName(const AZStd::string& name)
  50. {
  51. m_vertexColorStreamName = name;
  52. }
  53. void SkinMeshAdvancedRule::SetVertexColorStreamName(AZStd::string&& name)
  54. {
  55. m_vertexColorStreamName = AZStd::move(name);
  56. }
  57. const AZStd::string& SkinMeshAdvancedRule::GetVertexColorStreamName() const
  58. {
  59. return m_vertexColorStreamName;
  60. }
  61. bool SkinMeshAdvancedRule::IsVertexColorStreamDisabled() const
  62. {
  63. return m_vertexColorStreamName == DataTypes::s_advancedDisabledString;
  64. }
  65. void SkinMeshAdvancedRule::Reflect(ReflectContext* context)
  66. {
  67. SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
  68. if (!serializeContext)
  69. {
  70. return;
  71. }
  72. serializeContext->Class<SkinMeshAdvancedRule, DataTypes::IMeshAdvancedRule>()->Version(6)
  73. ->Field("use32bitVertices", &SkinMeshAdvancedRule::m_use32bitVertices)
  74. ->Field("useCustomNormals", &SkinMeshAdvancedRule::m_useCustomNormals)
  75. ->Field("vertexColorStreamName", &SkinMeshAdvancedRule::m_vertexColorStreamName);
  76. EditContext* editContext = serializeContext->GetEditContext();
  77. if (editContext)
  78. {
  79. editContext->Class<SkinMeshAdvancedRule>("Skin (Advanced)", "Configure advanced properties for this skin group.")
  80. ->ClassElement(Edit::ClassElements::EditorData, "")
  81. ->Attribute("AutoExpand", true)
  82. ->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
  83. ->DataElement(AZ::Edit::UIHandlers::RadioButton, &SkinMeshAdvancedRule::m_use32bitVertices, "Vertex Precision",
  84. "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"
  85. "Please note that not all platforms support 32-bit vertices. For more details please see documentation."
  86. )
  87. ->Attribute(AZ::Edit::Attributes::FalseText, "16-bit")
  88. ->Attribute(AZ::Edit::Attributes::TrueText, "32-bit")
  89. ->DataElement(Edit::UIHandlers::Default, &SkinMeshAdvancedRule::m_useCustomNormals, "Use Custom Normals", "Use custom normals from DCC data or average them.")
  90. ->DataElement("NodeListSelection", &SkinMeshAdvancedRule::m_vertexColorStreamName, "Vertex Color Stream",
  91. "Select a vertex color stream to enable Vertex Coloring or 'Disable' to turn Vertex Coloring off.\n\n"
  92. "Vertex Coloring works in conjunction with materials. If a material was previously generated,\n"
  93. "changing vertex coloring will require the material to be reset or the material editor to be used\n"
  94. "to enable 'Vertex Coloring'.")
  95. ->Attribute("ClassTypeIdFilter", DataTypes::IMeshVertexColorData::TYPEINFO_Uuid())
  96. ->Attribute("DisabledOption", DataTypes::s_advancedDisabledString)
  97. ->Attribute("UseShortNames", true);
  98. }
  99. }
  100. } // SceneData
  101. } // SceneAPI
  102. } // AZ