TubeShapeComponent.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 <AzCore/Component/Component.h>
  10. #include "Rendering/EntityDebugDisplayComponent.h"
  11. #include "TubeShape.h"
  12. namespace LmbrCentral
  13. {
  14. /// Provide a Component interface for TubeShape functionality.
  15. class TubeShapeComponent
  16. : public AZ::Component
  17. {
  18. public:
  19. AZ_COMPONENT(TubeShapeComponent, TubeShapeComponentTypeId);
  20. static void Reflect(AZ::ReflectContext* context);
  21. TubeShapeComponent() = default;
  22. explicit TubeShapeComponent(const TubeShape& tubeShape);
  23. // AZ::Component
  24. void Activate() override;
  25. void Deactivate() override;
  26. private:
  27. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  28. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  29. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  30. TubeShape m_tubeShape;
  31. };
  32. /// Concrete EntityDebugDisplay implementation for TubeShape.
  33. class TubeShapeDebugDisplayComponent
  34. : public EntityDebugDisplayComponent
  35. , public ShapeComponentNotificationsBus::Handler
  36. {
  37. public:
  38. AZ_COMPONENT(TubeShapeDebugDisplayComponent, "{FC8D0C5A-FEED-4C79-A4C6-E18A966EE8CE}", EntityDebugDisplayComponent)
  39. static void Reflect(AZ::ReflectContext* context);
  40. TubeShapeDebugDisplayComponent() = default;
  41. explicit TubeShapeDebugDisplayComponent(const TubeShapeMeshConfig& tubeShapeMeshConfig)
  42. : m_tubeShapeMeshConfig(tubeShapeMeshConfig) {}
  43. // AZ::Component
  44. void Activate() override;
  45. void Deactivate() override;
  46. // EntityDebugDisplayComponent
  47. void Draw(AzFramework::DebugDisplayRequests& debugDisplay) override;
  48. private:
  49. AZ_DISABLE_COPY_MOVE(TubeShapeDebugDisplayComponent)
  50. // ShapeComponentNotificationsBus
  51. void OnShapeChanged(ShapeChangeReasons changeReason) override;
  52. void GenerateVertices();
  53. ShapeMesh m_tubeShapeMesh; ///< Buffer to hold index and vertex data for the TubeShape when drawing.
  54. TubeShapeMeshConfig m_tubeShapeMeshConfig; ///< Configuration to control how the TubeShape should look.
  55. AZ::SplinePtr m_spline = nullptr; ///< Reference to the Spline.
  56. SplineAttribute<float> m_radiusAttribute; ///< Radius Attribute.
  57. float m_radius = 0.0f; ///< Global radius for the Tube.
  58. };
  59. } // namespace LmbrCentral