/* * 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 #include #include #include #include #include #include #include #include #include #include #include #include struct ImGuiContext; namespace AtomSampleViewer { class SecondWindowedScene : public AZ::TickBus::Handler , public AzFramework::WindowNotificationBus::Handler { using ModelChangedHandler = AZ::Render::MeshFeatureProcessorInterface::ModelChangedEvent::Handler; using PointLightHandle = AZ::Render::PointLightFeatureProcessorInterface::LightHandle; using SpotLightHandle = AZ::Render::SpotLightFeatureProcessorInterface::LightHandle; using DirectionalLightHandle = AZ::Render::DirectionalLightFeatureProcessorInterface::LightHandle; using ReflectinoProbeHandle = AZ::Render::ReflectionProbeHandle; static constexpr uint32_t ShaderBallCount = 12u; public: SecondWindowedScene(AZStd::string_view sceneName, class MultiSceneExampleComponent* parent); ~SecondWindowedScene(); AzFramework::NativeWindowHandle GetNativeWindowHandle(); void MoveCamera(bool enabled); // AZ::TickBus::Handler overrides ... void OnTick(float deltaTime, AZ::ScriptTimePoint timePoint) override; // AzFramework::WindowNotificationBus::Handler overrides ... void OnWindowClosed() override; private: AZStd::unique_ptr m_nativeWindow; AZStd::shared_ptr m_windowContext; AZStd::unique_ptr m_entityContext; AZStd::string m_sceneName; AzFramework::Scene* m_frameworkScene = nullptr; AZ::RPI::ScenePtr m_scene; AZ::RPI::RenderPipelinePtr m_pipeline; // Entities AZ::Entity* m_cameraEntity = nullptr; AZ::Entity* m_depthOfFieldEntity = nullptr; // Feature Settings AZ::Render::DepthOfFieldSettingsInterface* m_depthOfFieldSettings = nullptr; // FeatureProcessors AZ::Render::MeshFeatureProcessorInterface* m_meshFeatureProcessor = nullptr; AZ::Render::SkyBoxFeatureProcessorInterface* m_skyBoxFeatureProcessor = nullptr; AZ::Render::PointLightFeatureProcessorInterface* m_pointLightFeatureProcessor = nullptr; AZ::Render::SpotLightFeatureProcessorInterface* m_spotLightFeatureProcessor = nullptr; AZ::Render::DirectionalLightFeatureProcessorInterface* m_directionalLightFeatureProcessor = nullptr; AZ::Render::PostProcessFeatureProcessorInterface* m_postProcessFeatureProcessor = nullptr; AZ::Render::ReflectionProbeFeatureProcessorInterface* m_reflectionProbeFeatureProcessor = nullptr; // Meshes AZStd::vector m_shaderBallMeshHandles; AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_floorMeshHandle; // Model change handlers AZStd::vector m_shaderBallChangedHandles; // Various FeatureProcessor handles PointLightHandle m_pointLightHandle; SpotLightHandle m_spotLightHandle; DirectionalLightHandle m_directionalLightHandle; ReflectinoProbeHandle m_reflectionProbeHandle; double m_simulateTime = 0.0f; float m_deltaTime = 0.0f; MultiSceneExampleComponent* m_parent = nullptr; const AZ::Vector3 m_cameraOffset{ 0.0f, -4.0f, 2.0f }; AZ::Vector3 m_dynamicCameraOffset{ 3.73f, 0.0f, 0.0f }; bool m_moveCamera = false; Utils::DefaultIBL m_defaultIbl; }; //! A sample component to demonstrate multiple scenes. class MultiSceneExampleComponent final : public CommonSampleComponentBase , public AZ::TickBus::Handler { public: AZ_COMPONENT(MultiSceneExampleComponent, "{FB0F55AE-6708-47BE-87EB-DD1EB3EF5CD1}", CommonSampleComponentBase); static void Reflect(AZ::ReflectContext* context); MultiSceneExampleComponent(); ~MultiSceneExampleComponent() override = default; // AZ::Component void Activate() override; void Deactivate() override; void OnChildWindowClosed(); private: // AZ::TickBus::Handler overrides ... void OnTick(float deltaTime, AZ::ScriptTimePoint timePoint) override; void OpenSecondSceneWindow(); AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle; AZ::Component* m_mainCameraControlComponent = nullptr; AZStd::unique_ptr m_windowedScene; // Lights Utils::DefaultIBL m_defaultIbl; }; } // namespace AtomSampleViewer