7f84a4318c
* Add an Orthogonal Projection option to the Camera Gem This adds a check-box to opt into an ortho projection along with a half-width parameter to adjust the size of the visible area. Includes some light tweaks to ensure debug rendering looks OK and that we generate a correct camera state for these non-perspective views. Known issue: while in "Be this camera" mode in the Editor using an ortho projection manipulators aren't working correctly. This appears to be a downstream issue with CameraState consumers not actually checking the ortho flag. Signed-off-by: nvsickle <nvsickle@amazon.com> * Fix some typos Signed-off-by: nvsickle <nvsickle@amazon.com> * Account for reversed depth buffer Signed-off-by: nvsickle <nvsickle@amazon.com> * Clarify depth reversal for MakeOrthographicMatrixRH Signed-off-by: nvsickle <nvsickle@amazon.com>
75 lines
3.0 KiB
C++
75 lines
3.0 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 <AzToolsFramework/ToolsComponents/EditorComponentAdapter.h>
|
|
#include <AzCore/Math/Color.h>
|
|
|
|
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
|
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
|
|
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
|
#include <AzToolsFramework/API/EditorCameraBus.h>
|
|
#include <AzFramework/Viewport/ViewportColors.h>
|
|
#include <AzFramework/Components/CameraBus.h>
|
|
|
|
#include <AzFramework/Components/EditorEntityEvents.h>
|
|
#include "CameraComponent.h"
|
|
#include "CameraComponentController.h"
|
|
#include <IViewSystem.h>
|
|
#include <Cry_Camera.h>
|
|
|
|
#include <Atom/RPI.Public/Base.h>
|
|
|
|
namespace Camera
|
|
{
|
|
//////////////////////////////////////////////////////////////////////////
|
|
/// The CameraComponent holds all of the data necessary for a camera.
|
|
/// Get and set data through the CameraRequestBus or TransformBus
|
|
//////////////////////////////////////////////////////////////////////////
|
|
using EditorCameraComponentBase = AzToolsFramework::Components::EditorComponentAdapter<CameraComponentController, CameraComponent, CameraComponentConfig>;
|
|
class EditorCameraComponent
|
|
: public EditorCameraComponentBase
|
|
, public EditorCameraViewRequestBus::Handler
|
|
, private AzFramework::EntityDebugDisplayEventBus::Handler
|
|
, private EditorCameraNotificationBus::Handler
|
|
{
|
|
public:
|
|
AZ_EDITOR_COMPONENT(EditorCameraComponent, EditorCameraComponentTypeId, AzToolsFramework::Components::EditorComponentBase);
|
|
virtual ~EditorCameraComponent() = default;
|
|
|
|
static void Reflect(AZ::ReflectContext* reflection);
|
|
|
|
// AZ::Component interface
|
|
void Activate() override;
|
|
void Deactivate() override;
|
|
AZ::u32 OnConfigurationChanged() override;
|
|
|
|
// AzFramework::DebugDisplayRequestBus::Handler interface
|
|
void DisplayEntityViewport(
|
|
const AzFramework::ViewportInfo& viewportInfo,
|
|
AzFramework::DebugDisplayRequests& debugDisplay) override;
|
|
|
|
/// EditorCameraNotificationBus::Handler interface
|
|
void OnViewportViewEntityChanged(const AZ::EntityId& newViewId) override;
|
|
|
|
/// EditorCameraViewRequestBus::Handler interface
|
|
void ToggleCameraAsActiveView() override { OnPossessCameraButtonClicked(); }
|
|
bool GetCameraState(AzFramework::CameraState& cameraState) override;
|
|
|
|
protected:
|
|
void EditorDisplay(AzFramework::DebugDisplayRequests& displayInterface, const AZ::Transform& world);
|
|
AZ::Crc32 OnPossessCameraButtonClicked();
|
|
AZStd::string GetCameraViewButtonText() const;
|
|
|
|
bool m_isActiveEditorCamera = false;
|
|
float m_frustumViewPercentLength = 1.f;
|
|
AZ::Color m_frustumDrawColor = AzFramework::ViewportColors::HoverColor;
|
|
};
|
|
} // Camera
|