GetMainCamera exposed to scripts.

This commit is contained in:
maverickdgg 2023-02-24 16:31:53 +08:00
parent 6045214b13
commit 4690fa5f91
4 changed files with 15 additions and 4 deletions

View File

@ -590,9 +590,9 @@ namespace SHADE
#endif #endif
} }
SHCameraComponent* SHCameraSystem::GetMainCamera() const noexcept EntityID SHCameraSystem::GetMainCameraEID() const noexcept
{ {
return SHComponentManager::GetComponent_s<SHCameraComponent>(directorHandleList[0]->mainCameraEID); return directorHandleList[0]->mainCameraEID;
} }
} }

View File

@ -65,7 +65,7 @@ namespace SHADE
void SetCameraViewMatrix(SHCameraComponent& camera, SHMatrix const& viewMatrix, bool takePos) noexcept; void SetCameraViewMatrix(SHCameraComponent& camera, SHMatrix const& viewMatrix, bool takePos) noexcept;
void CameraLookAt(SHCameraComponent& camera, SHVec3 target) noexcept; void CameraLookAt(SHCameraComponent& camera, SHVec3 target) noexcept;
void UpdateEditorArm(double dt,bool active ,SHVec3 const& targetPos) noexcept; void UpdateEditorArm(double dt,bool active ,SHVec3 const& targetPos) noexcept;
SHCameraComponent* GetMainCamera() const noexcept; EntityID GetMainCameraEID() const noexcept;
SHVec2 GetCameraWidthHeight(size_t index) noexcept; SHVec2 GetCameraWidthHeight(size_t index) noexcept;
}; };

View File

@ -13,7 +13,6 @@ namespace SHADE
} }
float Camera::Pitch::get() float Camera::Pitch::get()
{ {
return (GetNativeComponent()->GetPitch()); return (GetNativeComponent()->GetPitch());
@ -126,4 +125,10 @@ namespace SHADE
} }
Camera^ Camera::GetMainCamera()
{
auto system = SHSystemManager::GetSystem<SHCameraSystem>();
return ECS::GetComponent<Camera^>(system->GetMainCameraEID());
}
} }

View File

@ -15,6 +15,9 @@ namespace SHADE
Camera(Entity entity); Camera(Entity entity);
public: public:
property float Pitch property float Pitch
{ {
float get(); float get();
@ -65,5 +68,8 @@ namespace SHADE
Vector3 GetForward(); Vector3 GetForward();
Vector3 GetRight(); Vector3 GetRight();
static Camera^ GetMainCamera();
}; };
} }