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.
121 lines
5.1 KiB
C++
121 lines
5.1 KiB
C++
/*
|
|
* 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/Asset/AssetCommon.h>
|
|
#include <AzCore/Component/Component.h>
|
|
#include <AzCore/Component/TransformBus.h>
|
|
#include <AzFramework/Visibility/BoundsBus.h>
|
|
#include <Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h>
|
|
#include <Atom/RPI.Public/Model/Model.h>
|
|
#include <LmbrCentral/Shape/BoxShapeComponentBus.h>
|
|
|
|
namespace AZ
|
|
{
|
|
namespace Render
|
|
{
|
|
class ReflectionProbeComponentConfig final
|
|
: public AZ::ComponentConfig
|
|
{
|
|
public:
|
|
AZ_RTTI(AZ::Render::ReflectionProbeComponentConfig, "{D61730A1-CAF5-448C-B2A3-50D5DC909F31}", ComponentConfig);
|
|
AZ_CLASS_ALLOCATOR(ReflectionProbeComponentConfig, SystemAllocator, 0);
|
|
static void Reflect(AZ::ReflectContext* context);
|
|
|
|
float m_outerHeight = 20.0f;
|
|
float m_outerLength = 20.0f;
|
|
float m_outerWidth = 20.0f;
|
|
float m_innerHeight = 20.0f;
|
|
float m_innerLength = 20.0f;
|
|
float m_innerWidth = 20.0f;
|
|
|
|
bool m_useParallaxCorrection = true;
|
|
bool m_showVisualization = true;
|
|
bool m_useBakedCubemap = true;
|
|
|
|
AZStd::string m_bakedCubeMapRelativePath;
|
|
Data::Asset<RPI::StreamingImageAsset> m_bakedCubeMapAsset;
|
|
Data::Asset<RPI::StreamingImageAsset> m_authoredCubeMapAsset;
|
|
AZ::u64 m_entityId{ EntityId::InvalidEntityId };
|
|
};
|
|
|
|
class ReflectionProbeComponentController final
|
|
: public Data::AssetBus::MultiHandler
|
|
, private TransformNotificationBus::Handler
|
|
, private LmbrCentral::ShapeComponentNotificationsBus::Handler
|
|
, public AzFramework::BoundsRequestBus::Handler
|
|
{
|
|
public:
|
|
friend class EditorReflectionProbeComponent;
|
|
|
|
AZ_CLASS_ALLOCATOR(ReflectionProbeComponentController, AZ::SystemAllocator, 0);
|
|
AZ_RTTI(AZ::Render::ReflectionProbeComponentController, "{EFFA88F1-7ED2-4552-B6F6-5E6B2B6D9311}");
|
|
|
|
static void Reflect(AZ::ReflectContext* context);
|
|
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
|
|
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
|
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
|
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
|
|
|
ReflectionProbeComponentController() = default;
|
|
ReflectionProbeComponentController(const ReflectionProbeComponentConfig& config);
|
|
|
|
void Activate(AZ::EntityId entityId);
|
|
void Deactivate();
|
|
void SetConfiguration(const ReflectionProbeComponentConfig& config);
|
|
const ReflectionProbeComponentConfig& GetConfiguration() const;
|
|
|
|
// returns the outer extent Aabb for this reflection
|
|
AZ::Aabb GetAabb() const;
|
|
|
|
// initiate the reflection probe bake, invokes callback when complete
|
|
void BakeReflectionProbe(BuildCubeMapCallback callback);
|
|
|
|
// update the currently rendering cubemap asset for this probe
|
|
void UpdateCubeMap();
|
|
|
|
// BoundsRequestBus overrides ...
|
|
AZ::Aabb GetWorldBounds() override;
|
|
AZ::Aabb GetLocalBounds() override;
|
|
|
|
private:
|
|
|
|
AZ_DISABLE_COPY(ReflectionProbeComponentController);
|
|
|
|
// Data::AssetBus overrides ...
|
|
void OnAssetReady(Data::Asset<Data::AssetData> asset) override;
|
|
|
|
// TransformNotificationBus overrides ...
|
|
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
|
|
|
// ShapeComponentNotificationsBus overrides ...
|
|
void OnShapeChanged(ShapeChangeReasons changeReason) override;
|
|
|
|
// update the feature processor and configuration outer extents
|
|
void UpdateOuterExtents();
|
|
|
|
// box shape component, used for defining the outer extents of the probe area
|
|
LmbrCentral::BoxShapeComponentRequests* m_boxShapeInterface = nullptr;
|
|
LmbrCentral::ShapeComponentRequests* m_shapeBus = nullptr;
|
|
|
|
// handle for this probe in the feature processor
|
|
ReflectionProbeHandle m_handle;
|
|
|
|
ReflectionProbeFeatureProcessorInterface* m_featureProcessor = nullptr;
|
|
TransformInterface* m_transformInterface = nullptr;
|
|
AZ::EntityId m_entityId;
|
|
ReflectionProbeComponentConfig m_configuration;
|
|
};
|
|
} // namespace Render
|
|
} // namespace AZ
|