2
0

VisualsMaker.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #pragma once
  9. #include "UrdfParser.h"
  10. #include <AzCore/Component/EntityId.h>
  11. #include <AzCore/IO/Path/Path.h>
  12. #include <AzCore/Math/Vector3.h>
  13. #include <AzCore/std/containers/unordered_map.h>
  14. #include <AzCore/std/smart_ptr/shared_ptr.h>
  15. #include <RobotImporter/Utils/SourceAssetsStorage.h>
  16. namespace ROS2RobotImporter
  17. {
  18. //! Populates a given entity with all the contents of the <visual> tag in robot description
  19. class VisualsMaker
  20. {
  21. public:
  22. VisualsMaker();
  23. VisualsMaker(const AZStd::shared_ptr<Utils::UrdfAssetMap>& urdfAssetsMapping);
  24. //! Add zero, one or many visual elements to a given entity (depending on link content).
  25. //! Note that a sub-entity will be added to hold each visual (since they can have different transforms).
  26. //! @param link A parsed URDF tree link node which could hold information about visuals.
  27. //! @param entityId A non-active entity which will be affected.
  28. //! @return List containing any entities created.
  29. AZStd::vector<AZ::EntityId> AddVisuals(const sdf::Link* link, AZ::EntityId entityId) const;
  30. private:
  31. AZ::EntityId AddVisual(const sdf::Visual* visual, AZ::EntityId entityId, const AZStd::string& generatedName) const;
  32. AZ::Data::AssetId AddVisualToEntity(const sdf::Visual* visual, AZ::EntityId entityId) const;
  33. void AddVisualAssetToEntity(AZ::EntityId entityId, const AZ::Data::AssetId& assetId, const AZ::Vector3& scale) const;
  34. void AddMaterialForVisual(const sdf::Visual* visual, AZ::EntityId entityId, const AZ::Data::AssetId& assetId) const;
  35. AZStd::shared_ptr<Utils::UrdfAssetMap> m_urdfAssetsMapping;
  36. };
  37. } // namespace ROS2RobotImporter