mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-06 03:12:01 +00:00
draws bounding box + contours
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
#include <Model/Model.hpp>
|
||||
#include "Drawables/ADrawable3D.hpp"
|
||||
#include "Component/Shaders/ShaderComponent.hpp"
|
||||
|
||||
|
||||
#include <Drawables/3D/Cube.hpp>
|
||||
#include "Models/Vector3.hpp"
|
||||
#include "Component/Collision/CollisionComponent.hpp"
|
||||
|
||||
namespace BBM
|
||||
@@ -26,6 +26,19 @@ namespace BBM
|
||||
this->_window.setFPS(this->FPS);
|
||||
}
|
||||
|
||||
void RenderSystem::drawBoundingBox(const WAL::Entity &entity, const PositionComponent &posComponent, const Drawable3DComponent &drawable) const
|
||||
{
|
||||
auto *dimsComponent = entity.tryGetComponent<CollisionComponent>();
|
||||
|
||||
//draws hitbox
|
||||
if (dimsComponent) {
|
||||
RAY::Drawables::Drawables3D::Cube boundingBox(posComponent.position, dimsComponent->bound, WHITE);
|
||||
boundingBox.drawWiresOn(this->_window);
|
||||
}
|
||||
//draws models contours
|
||||
drawable.drawable->drawWiresOn(this->_window);
|
||||
}
|
||||
|
||||
void RenderSystem::onSelfUpdate()
|
||||
{
|
||||
this->_camera.update();
|
||||
@@ -39,9 +52,9 @@ namespace BBM
|
||||
if (modelShader)
|
||||
modelShader->model->setShader(modelShader->getShader());
|
||||
drawable.drawable->setPosition(pos.position);
|
||||
drawable.drawable->drawOn(this->_window);
|
||||
if (this->_debugMode)
|
||||
drawable.drawable->drawWiresOn(this->_window);
|
||||
this->drawBoundingBox(entity, pos, drawable);
|
||||
drawable.drawable->drawOn(this->_window);
|
||||
if (modelShader)
|
||||
modelShader->model->resetShader();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "Component/Renderer/CameraComponent.hpp"
|
||||
#include "Component/Position/PositionComponent.hpp"
|
||||
#include "Component/Renderer/Drawable3DComponent.hpp"
|
||||
#include "System/System.hpp"
|
||||
#include "Camera/Camera2D.hpp"
|
||||
#include "Window.hpp"
|
||||
@@ -39,6 +40,9 @@ namespace BBM
|
||||
//! @param debug true if debug mode should be enabled
|
||||
void setDebug(bool debug);
|
||||
|
||||
//! @param entity entity to draw bounding box of
|
||||
void drawBoundingBox(const WAL::Entity &entity, const PositionComponent &posComponent, const Drawable3DComponent &drawable) const;
|
||||
|
||||
//! @brief ctor
|
||||
RenderSystem(WAL::Wal &wal, RAY::Window &window, bool debugMode = false);
|
||||
//! @brief Default copy ctor
|
||||
|
||||
Reference in New Issue
Block a user