From a556b45abf18f1bd509daaf63b66b7d55e9fd291 Mon Sep 17 00:00:00 2001 From: jjesswan Date: Mon, 22 Apr 2024 21:56:26 -0400 Subject: add engine version --- engine-ocean/Game/Systems/drawsystem.cpp | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 engine-ocean/Game/Systems/drawsystem.cpp (limited to 'engine-ocean/Game/Systems/drawsystem.cpp') diff --git a/engine-ocean/Game/Systems/drawsystem.cpp b/engine-ocean/Game/Systems/drawsystem.cpp new file mode 100644 index 0000000..ad6e17b --- /dev/null +++ b/engine-ocean/Game/Systems/drawsystem.cpp @@ -0,0 +1,60 @@ +#include "drawsystem.h" +#include "Game/Components/DrawComponent.h" +#include "Game/Components/TransformComponent.h" + +DrawSystem::DrawSystem(std::map>& gameobjects): + m_gameobjects(gameobjects) +{ + + +} + +void DrawSystem::update(double deltaTime){} +// store all game objects and get draw components, draw + +void DrawSystem::draw(){ + Global::graphics.bindShader("phong"); + //std::cout << "IN DRAW SYSTEM" << std::endl; + + for (auto &pair: m_gameobjects){ + if (pair.second->hasComponent()){ + + DrawComponent *draw_comp = pair.second->getComponent(); + TransformComponent *transform_comp = pair.second->getComponent(); + if (transform_comp->hasMultipleMT()){ + if (draw_comp->objHasMaterial()){ + for (const std::shared_ptr &mt : transform_comp->getAllMT()){ + Global::graphics.drawShape(draw_comp->getShape(), mt, draw_comp->getMaterial()); + } + } else { + for (const std::shared_ptr &mt : transform_comp->getAllMT()){ + Global::graphics.drawShape(draw_comp->getShape(), mt); + } + } + } else { + // case: object is seperated by material + if (draw_comp->objHasMultipleShapes()){ + for (auto &shape : draw_comp->getShapesWithMaterials()){ + if (shape->hasMaterial()){ + Global::graphics.drawShape(shape, transform_comp->getMT(), shape->getShapeMaterial()); + } else { + Global::graphics.drawShape(shape, transform_comp->getMT()); + } + } + + } else { + if (draw_comp->objHasMaterial()){ + Global::graphics.drawShape(draw_comp->getShape(), transform_comp->getMT(), draw_comp->getMaterial()); + } else { + //std::cout << "draw shape: " << pair.first << std::endl; + Global::graphics.drawShape(draw_comp->getShape(), transform_comp->getMT()); + } + } + } + } + } + +} + +void DrawSystem::scrollEvent(double distance){} +void DrawSystem::mousePosEvent(double xpos, double ypos){} -- cgit v1.2.3-70-g09d2