diff --git a/SHADE_Engine/src/Camera/SHCameraComponent.cpp b/SHADE_Engine/src/Camera/SHCameraComponent.cpp index f2cb4ead..402175dd 100644 --- a/SHADE_Engine/src/Camera/SHCameraComponent.cpp +++ b/SHADE_Engine/src/Camera/SHCameraComponent.cpp @@ -146,6 +146,17 @@ namespace SHADE dirtyProj = true; } + void SHCameraComponent::SetIsPerspective(bool persp) noexcept + { + this->perspProj = persp; + dirtyProj = true; + } + + SHVec3 const& SHCameraComponent::GetPosition() const noexcept + { + return position; + } + float SHCameraComponent::GetYaw() const noexcept { return yaw; @@ -159,6 +170,27 @@ namespace SHADE { return roll; } + + float SHCameraComponent::GetWidth() const noexcept + { + return width; + } + + float SHCameraComponent::GetHeight() const noexcept + { + return height; + } + + float SHCameraComponent::GetNear() const noexcept + { + return zNear; + } + + float SHCameraComponent::GetFar() const noexcept + { + return zFar; + } + float SHCameraComponent::GetAspectRatio() const noexcept { return width/height; @@ -169,6 +201,11 @@ namespace SHADE return fov; } + bool SHCameraComponent::GetIsPerspective() const noexcept + { + return perspProj; + } + const SHMatrix& SHCameraComponent::GetViewMatrix() const noexcept { return viewMatrix; @@ -179,12 +216,32 @@ namespace SHADE return projMatrix; } - void SHCameraComponent::SetMainCamera(size_t directorCameraIndex) noexcept - { - auto system = SHSystemManager::GetSystem(); - system->GetDirector(directorCameraIndex)->SetMainCamera(*this); - } + //void SHCameraComponent::SetMainCamera(size_t directorCameraIndex) noexcept + //{ + // auto system = SHSystemManager::GetSystem(); + // system->GetDirector(directorCameraIndex)->SetMainCamera(*this); + //} +}//namespace SHADE + + +RTTR_REGISTRATION +{ + using namespace SHADE; + using namespace rttr; + + registration::class_("Camera Component") + .property("Position", &SHCameraComponent::GetPosition, select_overload(&SHCameraComponent::SetPosition)) + .property("Pitch", &SHCameraComponent::GetPitch, &SHCameraComponent::SetPitch) + .property("Yaw", &SHCameraComponent::GetYaw, &SHCameraComponent::SetYaw) + .property("Roll", &SHCameraComponent::GetRoll, &SHCameraComponent::SetRoll) + .property("Width", &SHCameraComponent::GetWidth, &SHCameraComponent::SetWidth) + .property("Height", &SHCameraComponent::GetHeight, &SHCameraComponent::SetHeight) + .property("Near", &SHCameraComponent::GetNear, &SHCameraComponent::SetNear) + .property("Far", &SHCameraComponent::GetFar, &SHCameraComponent::SetFar) + .property("Perspective", &SHCameraComponent::GetIsPerspective, &SHCameraComponent::SetIsPerspective); + + } diff --git a/SHADE_Engine/src/Camera/SHCameraComponent.h b/SHADE_Engine/src/Camera/SHCameraComponent.h index 1149b1e1..19ce4232 100644 --- a/SHADE_Engine/src/Camera/SHCameraComponent.h +++ b/SHADE_Engine/src/Camera/SHCameraComponent.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "ECS_Base/Components/SHComponent.h" #include "Math/Vector/SHVec3.h" #include "Math/SHMatrix.h" @@ -57,20 +59,27 @@ namespace SHADE void SetNear(float znear) noexcept; void SetFar(float zfar) noexcept; void SetFOV(float fov) noexcept; + void SetIsPerspective(bool persp) noexcept; - + SHVec3 const& GetPosition() const noexcept; float GetYaw() const noexcept; float GetPitch() const noexcept; float GetRoll() const noexcept; + float GetWidth() const noexcept; + float GetHeight() const noexcept; + float GetNear() const noexcept; + float GetFar() const noexcept; + float GetAspectRatio() const noexcept; float GetFOV() const noexcept; + bool GetIsPerspective() const noexcept; const SHMatrix& GetViewMatrix() const noexcept; const SHMatrix& GetProjMatrix() const noexcept; - void SetMainCamera(size_t cameraDirectorIndex = 0) noexcept; + //void SetMainCamera(size_t cameraDirectorIndex = 0) noexcept; float movementSpeed; @@ -80,7 +89,7 @@ namespace SHADE - + RTTR_ENABLE() }; diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp index d9b235e5..42b516aa 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp @@ -20,6 +20,7 @@ #include "AudioSystem/SHAudioSystem.h" #include "Physics/Components/SHRigidBodyComponent.h" #include "Physics/Components/SHColliderComponent.h" +#include "Camera/SHCameraComponent.h" namespace SHADE { @@ -99,6 +100,10 @@ namespace SHADE { DrawComponent(rigidbodyComponent); } + if (auto cameraComponent = SHComponentManager::GetComponent_s(eid)) + { + DrawComponent(cameraComponent); + } ImGui::Separator(); // Render Scripts SHScriptEngine* scriptEngine = static_cast(SHSystemManager::GetSystem()); @@ -107,12 +112,14 @@ namespace SHADE if(ImGui::BeginMenu(std::format("{} Add Component", ICON_MD_LIBRARY_ADD).data())) { DrawAddComponentButton(eid); + DrawAddComponentButton(eid); // Components that require Transforms DrawAddComponentWithEnforcedComponentButton(eid); DrawAddComponentWithEnforcedComponentButton(eid); DrawAddComponentWithEnforcedComponentButton(eid); + ImGui::EndMenu(); }