Camera C# interface

This commit is contained in:
maverickdgg 2022-11-01 14:20:03 +08:00
parent a5e1862649
commit d82bc8833f
3 changed files with 198 additions and 0 deletions

120
SHADE_Managed/Camera.cxx Normal file
View File

@ -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<SHCameraSystem>();
system->SetMainCamera(GetNativeComponent()->GetEID(), directorIndex);
}
void Camera::SetMainCamera()
{
SetMainCamera(0);
}
void Camera::LookAt(Vector3 targetPosition)
{
auto system = SHSystemManager::GetSystem<SHCameraSystem>();
system->CameraLookAt(*GetNativeComponent(), Convert::ToNative(targetPosition));
}
}

69
SHADE_Managed/Camera.hxx Normal file
View File

@ -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<SHCameraComponent>
{
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);
};
}

View File

@ -0,0 +1,9 @@
using System;
using SHADE;
namespace SHADE_Scripting
{
class CameraTest :Script
{
}
}