fixing some issues in Drawables components and Render systems

This commit is contained in:
Clément Le Bihan
2021-05-25 12:14:24 +02:00
parent 43f1f6ad1f
commit e8aec2b7ef
5 changed files with 19 additions and 5 deletions
@@ -19,5 +19,10 @@ namespace BBM
: WAL::Component(entity) : WAL::Component(entity)
{ {
} }
WAL::Component *clone(WAL::Entity &entity) const override
{
return new Drawable2DComponent(entity);
}
}; };
} }
@@ -19,5 +19,10 @@ namespace BBM
: WAL::Component(entity) : WAL::Component(entity)
{ {
} }
WAL::Component *clone(WAL::Entity &entity) const override
{
return new Drawable3DComponent(entity);
}
}; };
} }
+3 -3
View File
@@ -21,17 +21,17 @@ namespace BBM
RAY::Window &_window; RAY::Window &_window;
public: public:
explicit Renderer2DSystem(RAY::Window &window) explicit Renderer2DSystem(RAY::Window &window)
: WAL::System({typeid(PositionComponent), typeid(Drawable3DComponent<T>)}), : WAL::System({typeid(PositionComponent), typeid(Drawable2DComponent<T>)}),
_window(window) _window(window)
{ {
} }
void onUpdate(WAL::Entity &entity, std::chrono::nanoseconds dtime) override void onUpdate(WAL::Entity &entity, std::chrono::nanoseconds dtime) override
{ {
auto &comp = entity.getComponent<Drawable3DComponent<T>>(); auto &comp = entity.getComponent<Drawable2DComponent<T>>();
auto &pos = entity.getComponent<PositionComponent>(); auto &pos = entity.getComponent<PositionComponent>();
// TODO update drawable pos with pos comp.setPosition({pos.getX(), pos.getY()});
comp.member.drawOn(this->_window); comp.member.drawOn(this->_window);
} }
+1 -1
View File
@@ -31,7 +31,7 @@ namespace BBM
auto &comp = entity.getComponent<Drawable3DComponent<T>>(); auto &comp = entity.getComponent<Drawable3DComponent<T>>();
auto &pos = entity.getComponent<PositionComponent>(); auto &pos = entity.getComponent<PositionComponent>();
// TODO update drawable pos with pos comp.setPosition(pos);
comp.member.drawOn(this->_window); comp.member.drawOn(this->_window);
} }
+5 -1
View File
@@ -14,6 +14,8 @@
#include "Drawables/Texture.hpp" #include "Drawables/Texture.hpp"
#include "Model/Model.hpp" #include "Model/Model.hpp"
#include "Model/ModelAnimations.hpp" #include "Model/ModelAnimations.hpp"
#include "System/Renderer/Renderer2DSystem.hpp"
#include "Component/Drawable/Drawable2DComponent.hpp"
#include "Vector/Vector3.hpp" #include "Vector/Vector3.hpp"
#include "Window.hpp" #include "Window.hpp"
#include "TraceLog.hpp" #include "TraceLog.hpp"
@@ -21,6 +23,7 @@
int main() int main()
{ {
SetTraceLogLevel(LOG_WARNING); SetTraceLogLevel(LOG_WARNING);
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
const int screenWidth = 800; const int screenWidth = 800;
@@ -29,9 +32,10 @@ int main()
RAY::Window &window = RAY::Window::getInstance(screenWidth, screenHeight, "Bidibidibop", FLAG_WINDOW_RESIZABLE); 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::Camera::Camera3D camera(RAY::Vector3(10.0f, 10.0f, 10.0f),
RAY::Vector3(0.0f, 0.0f, 0.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 45.0f, CAMERA_PERSPECTIVE
); );
BBM::Renderer2DSystem<RAY::Drawables::Drawables2D::Text> textSystem(window);
RAY::Model model("assets/guy.iqm"); RAY::Model model("assets/guy.iqm");
RAY::Texture texture("assets/guytex.png"); RAY::Texture texture("assets/guytex.png");
RAY::ModelAnimations animations("assets/guy.iqm"); RAY::ModelAnimations animations("assets/guy.iqm");