From d82bc8833fa26ae870f9c9c24a53809fb6a887d1 Mon Sep 17 00:00:00 2001 From: maverickdgg Date: Tue, 1 Nov 2022 14:20:03 +0800 Subject: [PATCH] Camera C# interface --- SHADE_Managed/Camera.cxx | 120 ++++++++++++++++++++++++++++++++ SHADE_Managed/Camera.hxx | 69 ++++++++++++++++++ TempScriptsFolder/CameraTest.cs | 9 +++ 3 files changed, 198 insertions(+) create mode 100644 SHADE_Managed/Camera.cxx create mode 100644 SHADE_Managed/Camera.hxx create mode 100644 TempScriptsFolder/CameraTest.cs diff --git a/SHADE_Managed/Camera.cxx b/SHADE_Managed/Camera.cxx new file mode 100644 index 00000000..f90e2bfe --- /dev/null +++ b/SHADE_Managed/Camera.cxx @@ -0,0 +1,120 @@ +#include "SHpch.h" + +#include "Camera.hxx" +#include "ECS_Base/Managers/SHSystemManager.h" +#include "Camera/SHCameraSystem.h" + + +namespace SHADE +{ + Camera::Camera(Entity entity) + :Component(entity) + { + + } + + + float Camera::Pitch::get() + { + return (GetNativeComponent()->GetPitch()); + } + + void Camera::Pitch::set(float val) + { + GetNativeComponent()->SetPitch(val); + } + float Camera::Yaw::get() + { + return (GetNativeComponent()->GetYaw()); + } + + void Camera::Yaw::set(float val) + { + GetNativeComponent()->SetYaw(val); + } + float Camera::Roll::get() + { + return (GetNativeComponent()->GetRoll()); + } + + void Camera::Roll::set(float val) + { + GetNativeComponent()->SetRoll(val); + } + float Camera::Width::get() + { + return (GetNativeComponent()->GetWidth()); + } + + void Camera::Width::set(float val) + { + GetNativeComponent()->SetWidth(val); + } + float Camera::Height::get() + { + return (GetNativeComponent()->GetHeight()); + } + + void Camera::Height::set(float val) + { + GetNativeComponent()->SetHeight(val); + } + float Camera::Near::get() + { + return (GetNativeComponent()->GetNear()); + } + + void Camera::Near::set(float val) + { + GetNativeComponent()->SetNear(val); + } + float Camera::Far::get() + { + return (GetNativeComponent()->GetFar()); + } + + void Camera::Far::set(float val) + { + GetNativeComponent()->SetFar(val); + } + float Camera::FOV::get() + { + return (GetNativeComponent()->GetFOV()); + } + + void Camera::FOV::set(float val) + { + GetNativeComponent()->SetFOV(val); + } + + Vector3 Camera::Position::get() + { + return Convert::ToCLI(GetNativeComponent()->GetPosition()); + } + + void Camera::Position::set(Vector3 val) + { + GetNativeComponent()->SetPosition(Convert::ToNative(val)); + } + + void Camera::SetMainCamera(size_t directorIndex) + { + auto system = SHSystemManager::GetSystem(); + system->SetMainCamera(GetNativeComponent()->GetEID(), directorIndex); + } + + void Camera::SetMainCamera() + { + SetMainCamera(0); + } + + void Camera::LookAt(Vector3 targetPosition) + { + auto system = SHSystemManager::GetSystem(); + system->CameraLookAt(*GetNativeComponent(), Convert::ToNative(targetPosition)); + } + + + + +} \ No newline at end of file diff --git a/SHADE_Managed/Camera.hxx b/SHADE_Managed/Camera.hxx new file mode 100644 index 00000000..e5a017b3 --- /dev/null +++ b/SHADE_Managed/Camera.hxx @@ -0,0 +1,69 @@ +#pragma once + +// Project Includes +#include "Components/Component.hxx" +#include "Math/Vector3.hxx" +#include "Math/Quaternion.hxx" +// External Dependencies +#include "Camera/SHCameraComponent.h" + +namespace SHADE +{ + public ref class Camera : public Component + { + internal: + Camera(Entity entity); + + public: + property float Pitch + { + float get(); + void set(float val); + } + property float Yaw + { + float get(); + void set(float val); + } + property float Roll + { + float get(); + void set(float val); + } + property float Width + { + float get(); + void set(float val); + } + property float Height + { + float get(); + void set(float val); + } + property float Near + { + float get(); + void set(float val); + } + property float Far + { + float get(); + void set(float val); + } + property float FOV + { + float get(); + void set(float val); + } + property Vector3 Position + { + Vector3 get(); + void set(Vector3 val); + } + + + void SetMainCamera(size_t directorIndex); + void SetMainCamera(); + void LookAt(Vector3 targetPosition); + }; +} \ No newline at end of file diff --git a/TempScriptsFolder/CameraTest.cs b/TempScriptsFolder/CameraTest.cs new file mode 100644 index 00000000..867f3dcc --- /dev/null +++ b/TempScriptsFolder/CameraTest.cs @@ -0,0 +1,9 @@ +using System; +using SHADE; + +namespace SHADE_Scripting +{ + class CameraTest :Script + { + } +}