From e8aec2b7ef71f313b07f72c65a96b67a73e0bd88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Tue, 25 May 2021 12:14:24 +0200 Subject: [PATCH] fixing some issues in Drawables components and Render systems --- sources/Component/Drawable/Drawable2DComponent.hpp | 5 +++++ sources/Component/Drawable/Drawable3DComponent.hpp | 5 +++++ sources/System/Renderer/Renderer2DSystem.hpp | 6 +++--- sources/System/Renderer/Renderer3DSystem.hpp | 2 +- sources/main.cpp | 6 +++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/sources/Component/Drawable/Drawable2DComponent.hpp b/sources/Component/Drawable/Drawable2DComponent.hpp index 45537d8a..e9a031f3 100644 --- a/sources/Component/Drawable/Drawable2DComponent.hpp +++ b/sources/Component/Drawable/Drawable2DComponent.hpp @@ -19,5 +19,10 @@ namespace BBM : WAL::Component(entity) { } + + WAL::Component *clone(WAL::Entity &entity) const override + { + return new Drawable2DComponent(entity); + } }; } \ No newline at end of file diff --git a/sources/Component/Drawable/Drawable3DComponent.hpp b/sources/Component/Drawable/Drawable3DComponent.hpp index 80814549..bfe631db 100644 --- a/sources/Component/Drawable/Drawable3DComponent.hpp +++ b/sources/Component/Drawable/Drawable3DComponent.hpp @@ -19,5 +19,10 @@ namespace BBM : WAL::Component(entity) { } + + WAL::Component *clone(WAL::Entity &entity) const override + { + return new Drawable3DComponent(entity); + } }; } \ No newline at end of file diff --git a/sources/System/Renderer/Renderer2DSystem.hpp b/sources/System/Renderer/Renderer2DSystem.hpp index a0ceea2d..187996bd 100644 --- a/sources/System/Renderer/Renderer2DSystem.hpp +++ b/sources/System/Renderer/Renderer2DSystem.hpp @@ -21,17 +21,17 @@ namespace BBM RAY::Window &_window; public: explicit Renderer2DSystem(RAY::Window &window) - : WAL::System({typeid(PositionComponent), typeid(Drawable3DComponent)}), + : WAL::System({typeid(PositionComponent), typeid(Drawable2DComponent)}), _window(window) { } void onUpdate(WAL::Entity &entity, std::chrono::nanoseconds dtime) override { - auto &comp = entity.getComponent>(); + auto &comp = entity.getComponent>(); auto &pos = entity.getComponent(); - // TODO update drawable pos with pos + comp.setPosition({pos.getX(), pos.getY()}); comp.member.drawOn(this->_window); } diff --git a/sources/System/Renderer/Renderer3DSystem.hpp b/sources/System/Renderer/Renderer3DSystem.hpp index 36c49aa4..ce7ba279 100644 --- a/sources/System/Renderer/Renderer3DSystem.hpp +++ b/sources/System/Renderer/Renderer3DSystem.hpp @@ -31,7 +31,7 @@ namespace BBM auto &comp = entity.getComponent>(); auto &pos = entity.getComponent(); - // TODO update drawable pos with pos + comp.setPosition(pos); comp.member.drawOn(this->_window); } diff --git a/sources/main.cpp b/sources/main.cpp index 7cfe404d..f4768227 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -14,6 +14,8 @@ #include "Drawables/Texture.hpp" #include "Model/Model.hpp" #include "Model/ModelAnimations.hpp" +#include "System/Renderer/Renderer2DSystem.hpp" +#include "Component/Drawable/Drawable2DComponent.hpp" #include "Vector/Vector3.hpp" #include "Window.hpp" #include "TraceLog.hpp" @@ -21,6 +23,7 @@ int main() { SetTraceLogLevel(LOG_WARNING); + // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; @@ -29,9 +32,10 @@ int main() RAY::Window &window = RAY::Window::getInstance(screenWidth, screenHeight, "Bidibidibop", FLAG_WINDOW_RESIZABLE); RAY::Camera::Camera3D camera(RAY::Vector3(10.0f, 10.0f, 10.0f), RAY::Vector3(0.0f, 0.0f, 0.0f), - RAY::Vector3(0.0f, 1.0f, 0.0f), + RAY::Vector3(0.0f, 1.0f, 0.0f), 45.0f, CAMERA_PERSPECTIVE ); + BBM::Renderer2DSystem textSystem(window); RAY::Model model("assets/guy.iqm"); RAY::Texture texture("assets/guytex.png"); RAY::ModelAnimations animations("assets/guy.iqm");