You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/LmbrCentral/Code/Source/Shape/TubeShapeComponent.h

75 lines
2.7 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include "Rendering/EntityDebugDisplayComponent.h"
#include "TubeShape.h"
namespace LmbrCentral
{
/// Provide a Component interface for TubeShape functionality.
class TubeShapeComponent
: public AZ::Component
{
public:
AZ_COMPONENT(TubeShapeComponent, TubeShapeComponentTypeId);
static void Reflect(AZ::ReflectContext* context);
TubeShapeComponent() = default;
explicit TubeShapeComponent(const TubeShape& tubeShape);
// AZ::Component
void Activate() override;
void Deactivate() override;
private:
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
TubeShape m_tubeShape;
};
/// Concrete EntityDebugDisplay implementation for TubeShape.
class TubeShapeDebugDisplayComponent
: public EntityDebugDisplayComponent
, public ShapeComponentNotificationsBus::Handler
{
public:
AZ_COMPONENT(TubeShapeDebugDisplayComponent, "{FC8D0C5A-FEED-4C79-A4C6-E18A966EE8CE}", EntityDebugDisplayComponent)
static void Reflect(AZ::ReflectContext* context);
TubeShapeDebugDisplayComponent() = default;
explicit TubeShapeDebugDisplayComponent(const TubeShapeMeshConfig& tubeShapeMeshConfig)
: m_tubeShapeMeshConfig(tubeShapeMeshConfig) {}
// AZ::Component
void Activate() override;
void Deactivate() override;
// EntityDebugDisplayComponent
void Draw(AzFramework::DebugDisplayRequests& debugDisplay) override;
private:
AZ_DISABLE_COPY_MOVE(TubeShapeDebugDisplayComponent)
// ShapeComponentNotificationsBus
void OnShapeChanged(ShapeChangeReasons changeReason) override;
void GenerateVertices();
ShapeMesh m_tubeShapeMesh; ///< Buffer to hold index and vertex data for the TubeShape when drawing.
TubeShapeMeshConfig m_tubeShapeMeshConfig; ///< Configuration to control how the TubeShape should look.
AZ::SplinePtr m_spline = nullptr; ///< Reference to the Spline.
SplineAttribute<float> m_radiusAttribute; ///< Radius Attribute.
float m_radius = 0.0f; ///< Global radius for the Tube.
};
} // namespace LmbrCentral