Merge branch 'main' into SP3-6-c-scripting
This commit is contained in:
commit
cd04132fd7
|
@ -4,6 +4,7 @@
|
||||||
#include "SHCameraSystem.h"
|
#include "SHCameraSystem.h"
|
||||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
#include "Math/Transform/SHTransformComponent.h"
|
#include "Math/Transform/SHTransformComponent.h"
|
||||||
|
#include "Math/SHMath.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -28,7 +29,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(GetEID());
|
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(GetEID());
|
||||||
SHVec3 rotation = transform->GetWorldRotation();
|
SHVec3 rotation = transform->GetWorldRotation();
|
||||||
transform->SetWorldRotation(SHVec3{rotation.x,yaw, rotation.z});
|
transform->SetWorldRotation(SHVec3{rotation.x,SHMath::DegreesToRadians(yaw), rotation.z});
|
||||||
}
|
}
|
||||||
dirtyView = true;
|
dirtyView = true;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +41,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(GetEID());
|
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(GetEID());
|
||||||
SHVec3 rotation = transform->GetWorldRotation();
|
SHVec3 rotation = transform->GetWorldRotation();
|
||||||
transform->SetWorldRotation(SHVec3{ pitch,rotation.y, rotation.z });
|
transform->SetWorldRotation(SHVec3{ SHMath::DegreesToRadians(pitch),rotation.y, rotation.z });
|
||||||
}
|
}
|
||||||
dirtyView = true;
|
dirtyView = true;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +53,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(GetEID());
|
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(GetEID());
|
||||||
SHVec3 rotation = transform->GetWorldRotation();
|
SHVec3 rotation = transform->GetWorldRotation();
|
||||||
transform->SetWorldRotation(SHVec3{ rotation.x,rotation.y, roll});
|
transform->SetWorldRotation(SHVec3{ rotation.x,rotation.y, SHMath::DegreesToRadians(roll)});
|
||||||
}
|
}
|
||||||
dirtyView = true;
|
dirtyView = true;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +103,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
dirtyView = true;
|
dirtyView = true;
|
||||||
}
|
}
|
||||||
void SHCameraComponent::SetPosition(SHVec3& pos) noexcept
|
void SHCameraComponent::SetPosition(SHVec3 pos) noexcept
|
||||||
{
|
{
|
||||||
this->position = pos;
|
this->position = pos;
|
||||||
if (SHComponentManager::HasComponent<SHTransformComponent>(GetEID()))
|
if (SHComponentManager::HasComponent<SHTransformComponent>(GetEID()))
|
||||||
|
@ -145,6 +146,17 @@ namespace SHADE
|
||||||
dirtyProj = true;
|
dirtyProj = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHCameraComponent::SetIsPerspective(bool persp) noexcept
|
||||||
|
{
|
||||||
|
this->perspProj = persp;
|
||||||
|
dirtyProj = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHVec3 SHCameraComponent::GetPosition() const noexcept
|
||||||
|
{
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
float SHCameraComponent::GetYaw() const noexcept
|
float SHCameraComponent::GetYaw() const noexcept
|
||||||
{
|
{
|
||||||
return yaw;
|
return yaw;
|
||||||
|
@ -158,6 +170,27 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
return roll;
|
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
|
float SHCameraComponent::GetAspectRatio() const noexcept
|
||||||
{
|
{
|
||||||
return width/height;
|
return width/height;
|
||||||
|
@ -168,6 +201,11 @@ namespace SHADE
|
||||||
return fov;
|
return fov;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SHCameraComponent::GetIsPerspective() const noexcept
|
||||||
|
{
|
||||||
|
return perspProj;
|
||||||
|
}
|
||||||
|
|
||||||
const SHMatrix& SHCameraComponent::GetViewMatrix() const noexcept
|
const SHMatrix& SHCameraComponent::GetViewMatrix() const noexcept
|
||||||
{
|
{
|
||||||
return viewMatrix;
|
return viewMatrix;
|
||||||
|
@ -178,12 +216,32 @@ namespace SHADE
|
||||||
return projMatrix;
|
return projMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHCameraComponent::SetMainCamera(size_t directorCameraIndex) noexcept
|
//void SHCameraComponent::SetMainCamera(size_t directorCameraIndex) noexcept
|
||||||
{
|
//{
|
||||||
auto system = SHSystemManager::GetSystem<SHCameraSystem>();
|
// auto system = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
system->GetDirector(directorCameraIndex)->SetMainCamera(*this);
|
// system->GetDirector(directorCameraIndex)->SetMainCamera(*this);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}//namespace SHADE
|
||||||
|
|
||||||
|
|
||||||
|
RTTR_REGISTRATION
|
||||||
|
{
|
||||||
|
using namespace SHADE;
|
||||||
|
using namespace rttr;
|
||||||
|
|
||||||
|
registration::class_<SHCameraComponent>("Camera Component")
|
||||||
|
.property("Position", &SHCameraComponent::GetPosition, select_overload<void(SHVec3)>(&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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <rttr/registration>
|
||||||
|
|
||||||
#include "ECS_Base/Components/SHComponent.h"
|
#include "ECS_Base/Components/SHComponent.h"
|
||||||
#include "Math/Vector/SHVec3.h"
|
#include "Math/Vector/SHVec3.h"
|
||||||
#include "Math/SHMatrix.h"
|
#include "Math/SHMatrix.h"
|
||||||
|
@ -50,32 +52,39 @@ namespace SHADE
|
||||||
void SetPositionY(float y) noexcept;
|
void SetPositionY(float y) noexcept;
|
||||||
void SetPositionZ(float z) noexcept;
|
void SetPositionZ(float z) noexcept;
|
||||||
void SetPosition(float x, float y, float z) noexcept;
|
void SetPosition(float x, float y, float z) noexcept;
|
||||||
void SetPosition(SHVec3& pos) noexcept;
|
void SetPosition(SHVec3 pos) noexcept;
|
||||||
|
|
||||||
void SetWidth(float width) noexcept;
|
void SetWidth(float width) noexcept;
|
||||||
void SetHeight(float height) noexcept;
|
void SetHeight(float height) noexcept;
|
||||||
void SetNear(float znear) noexcept;
|
void SetNear(float znear) noexcept;
|
||||||
void SetFar(float zfar) noexcept;
|
void SetFar(float zfar) noexcept;
|
||||||
void SetFOV(float fov) noexcept;
|
void SetFOV(float fov) noexcept;
|
||||||
|
void SetIsPerspective(bool persp) noexcept;
|
||||||
|
|
||||||
|
|
||||||
|
SHVec3 GetPosition() const noexcept;
|
||||||
float GetYaw() const noexcept;
|
float GetYaw() const noexcept;
|
||||||
float GetPitch() const noexcept;
|
float GetPitch() const noexcept;
|
||||||
float GetRoll() 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 GetAspectRatio() const noexcept;
|
||||||
float GetFOV() const noexcept;
|
float GetFOV() const noexcept;
|
||||||
|
bool GetIsPerspective() const noexcept;
|
||||||
|
|
||||||
const SHMatrix& GetViewMatrix() const noexcept;
|
const SHMatrix& GetViewMatrix() const noexcept;
|
||||||
const SHMatrix& GetProjMatrix() const noexcept;
|
const SHMatrix& GetProjMatrix() const noexcept;
|
||||||
|
|
||||||
void SetMainCamera(size_t cameraDirectorIndex = 0) noexcept;
|
//void SetMainCamera(size_t cameraDirectorIndex = 0) noexcept;
|
||||||
|
|
||||||
|
|
||||||
float movementSpeed;
|
float movementSpeed;
|
||||||
SHVec3 turnSpeed;
|
SHVec3 turnSpeed;
|
||||||
|
RTTR_ENABLE()
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ namespace SHADE
|
||||||
SHVec3 view, right, UP;
|
SHVec3 view, right, UP;
|
||||||
|
|
||||||
|
|
||||||
//ClampCameraRotation(camera);
|
ClampCameraRotation(camera);
|
||||||
|
|
||||||
GetCameraAxis(camera, view, right, UP);
|
GetCameraAxis(camera, view, right, UP);
|
||||||
|
|
||||||
|
@ -221,8 +221,8 @@ namespace SHADE
|
||||||
SHVec3 up = { 0.0f,1.0f,0.0f };
|
SHVec3 up = { 0.0f,1.0f,0.0f };
|
||||||
|
|
||||||
|
|
||||||
|
target = SHVec3::RotateX(target, SHMath::DegreesToRadians(camera.pitch));
|
||||||
target = SHVec3::RotateY(target, SHMath::DegreesToRadians(camera.yaw));
|
target = SHVec3::RotateY(target, SHMath::DegreesToRadians(camera.yaw));
|
||||||
target =SHVec3::RotateX(target, SHMath::DegreesToRadians(camera.pitch));
|
|
||||||
target += camera.position;
|
target += camera.position;
|
||||||
////SHVec3::RotateZ(target, SHMath::DegreesToRadians(camera.roll));
|
////SHVec3::RotateZ(target, SHMath::DegreesToRadians(camera.roll));
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "AudioSystem/SHAudioSystem.h"
|
#include "AudioSystem/SHAudioSystem.h"
|
||||||
#include "Physics/Components/SHRigidBodyComponent.h"
|
#include "Physics/Components/SHRigidBodyComponent.h"
|
||||||
#include "Physics/Components/SHColliderComponent.h"
|
#include "Physics/Components/SHColliderComponent.h"
|
||||||
|
#include "Camera/SHCameraComponent.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -99,6 +100,10 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
DrawComponent(rigidbodyComponent);
|
DrawComponent(rigidbodyComponent);
|
||||||
}
|
}
|
||||||
|
if (auto cameraComponent = SHComponentManager::GetComponent_s<SHCameraComponent>(eid))
|
||||||
|
{
|
||||||
|
DrawComponent(cameraComponent);
|
||||||
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
// Render Scripts
|
// Render Scripts
|
||||||
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
||||||
|
@ -107,6 +112,7 @@ namespace SHADE
|
||||||
if(ImGui::BeginMenu(std::format("{} Add Component", ICON_MD_LIBRARY_ADD).data()))
|
if(ImGui::BeginMenu(std::format("{} Add Component", ICON_MD_LIBRARY_ADD).data()))
|
||||||
{
|
{
|
||||||
DrawAddComponentButton<SHTransformComponent>(eid);
|
DrawAddComponentButton<SHTransformComponent>(eid);
|
||||||
|
DrawAddComponentButton<SHCameraComponent>(eid);
|
||||||
|
|
||||||
// Components that require Transforms
|
// Components that require Transforms
|
||||||
|
|
||||||
|
@ -114,6 +120,7 @@ namespace SHADE
|
||||||
DrawAddComponentWithEnforcedComponentButton<SHRigidBodyComponent, SHTransformComponent>(eid);
|
DrawAddComponentWithEnforcedComponentButton<SHRigidBodyComponent, SHTransformComponent>(eid);
|
||||||
DrawAddComponentWithEnforcedComponentButton<SHColliderComponent, SHTransformComponent>(eid);
|
DrawAddComponentWithEnforcedComponentButton<SHColliderComponent, SHTransformComponent>(eid);
|
||||||
|
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue