diff options
author | jjesswan <jessica_wan@brown.edu> | 2024-04-22 21:56:26 -0400 |
---|---|---|
committer | jjesswan <jessica_wan@brown.edu> | 2024-04-22 21:56:26 -0400 |
commit | a556b45abf18f1bd509daaf63b66b7d55e9fd291 (patch) | |
tree | bc9b8a2d184c12aee236e7f9f276a34b84ca552d /engine-ocean/Game/Systems/drawsystem.cpp | |
parent | cd7c76017a12bb548036571c1ff13e551369d06d (diff) |
add engine version
Diffstat (limited to 'engine-ocean/Game/Systems/drawsystem.cpp')
-rw-r--r-- | engine-ocean/Game/Systems/drawsystem.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
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<std::string, std::shared_ptr<GameObject>>& 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>()){ + + DrawComponent *draw_comp = pair.second->getComponent<DrawComponent>(); + TransformComponent *transform_comp = pair.second->getComponent<TransformComponent>(); + if (transform_comp->hasMultipleMT()){ + if (draw_comp->objHasMaterial()){ + for (const std::shared_ptr<ModelTransform> &mt : transform_comp->getAllMT()){ + Global::graphics.drawShape(draw_comp->getShape(), mt, draw_comp->getMaterial()); + } + } else { + for (const std::shared_ptr<ModelTransform> &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){} |