adding red color for collisions boxes

This commit is contained in:
Clément Le Bihan
2021-06-14 14:41:04 +02:00
parent a36ab11b6d
commit a229452dc4
4 changed files with 22 additions and 4 deletions

View File

@@ -39,4 +39,15 @@ namespace RAY::Drawables
void ADrawable3D::drawWiresOn(RAY::Window &) void ADrawable3D::drawWiresOn(RAY::Window &)
{} {}
const RAY::Color &ADrawable3D::getDebugColor(void) const
{
return this->_debugColor;
}
ADrawable3D &ADrawable3D::setDebugColor(const Color &debugColor)
{
this->_debugColor = debugColor;
return *this;
}
} }

View File

@@ -35,10 +35,16 @@ namespace RAY::Drawables {
//! @return the color of the ADrawable //! @return the color of the ADrawable
const RAY::Color &getColor(void) const; const RAY::Color &getColor(void) const;
//! @brief set color //! @brief set color
ADrawable3D &setColor(const RAY::Color &color); ADrawable3D &setColor(const RAY::Color &color);
//! @return the debug color of the ADrawable
const RAY::Color &getDebugColor(void) const;
//! @brief set the debug color
ADrawable3D &setDebugColor(const RAY::Color &debugColor);
//! @return the position of the ADrawable //! @return the position of the ADrawable
virtual const RAY::Vector3 &getPosition(void) const; virtual const RAY::Vector3 &getPosition(void) const;

View File

@@ -165,7 +165,7 @@ namespace BBM
for (int i = 0; i < width + 1; i++) { for (int i = 0; i < width + 1; i++) {
for (int j = 0; j < height + 1; j++) { for (int j = 0; j < height + 1; j++) {
if (map[std::make_tuple(i, 0, j)] != HOLE && map[std::make_tuple(i, -1, j)] != BUMPER) if (map[std::make_tuple(i, 0, j)] != HOLE && map[std::make_tuple(i, -1, j)] != BUMPER)
scene->addEntity("Unbreakable Wall") scene->addEntity("Floor")
.addComponent<PositionComponent>(Vector3f(i, -1, j)) .addComponent<PositionComponent>(Vector3f(i, -1, j))
.addComponent<Drawable3DComponent, RAY3D::Model>(floorObj, false, .addComponent<Drawable3DComponent, RAY3D::Model>(floorObj, false,
std::make_pair(MAP_DIFFUSE, floorPng)); std::make_pair(MAP_DIFFUSE, floorPng));

View File

@@ -33,6 +33,7 @@ namespace BBM
//draws hitbox //draws hitbox
if (dimsComponent) { if (dimsComponent) {
RAY::Drawables::Drawables3D::Cube boundingBox(posComponent.position, dimsComponent->bound, WHITE); RAY::Drawables::Drawables3D::Cube boundingBox(posComponent.position, dimsComponent->bound, WHITE);
boundingBox.setDebugColor(RED);
boundingBox.drawWiresOn(this->_window); boundingBox.drawWiresOn(this->_window);
} }
//draws models contours //draws models contours
@@ -52,11 +53,11 @@ namespace BBM
if (modelShader) if (modelShader)
modelShader->model->setShader(modelShader->getShader()); modelShader->model->setShader(modelShader->getShader());
drawable.drawable->setPosition(pos.position); drawable.drawable->setPosition(pos.position);
if (this->_debugMode)
this->drawBoundingBox(entity, pos, drawable);
drawable.drawable->drawOn(this->_window); drawable.drawable->drawOn(this->_window);
if (modelShader) if (modelShader)
modelShader->model->resetShader(); modelShader->model->resetShader();
if (this->_debugMode)
this->drawBoundingBox(entity, pos, drawable);
} }
this->_window.unuseCamera(); this->_window.unuseCamera();