diff --git a/lib/Ray/sources/Drawables/3D/Cube.cpp b/lib/Ray/sources/Drawables/3D/Cube.cpp index 6f651a15..7875e99a 100644 --- a/lib/Ray/sources/Drawables/3D/Cube.cpp +++ b/lib/Ray/sources/Drawables/3D/Cube.cpp @@ -30,4 +30,9 @@ namespace RAY::Drawables::Drawables3D { DrawCubeV(this->_position, this->_dimensions, this->_color); } + + void Cube::drawWiresOn(RAY::Window &) + { + DrawCubeWiresV(this->_position, this->_dimensions, GREEN); + } } \ No newline at end of file diff --git a/lib/Ray/sources/Drawables/3D/Cube.hpp b/lib/Ray/sources/Drawables/3D/Cube.hpp index d1fff6f9..96347a95 100644 --- a/lib/Ray/sources/Drawables/3D/Cube.hpp +++ b/lib/Ray/sources/Drawables/3D/Cube.hpp @@ -41,6 +41,9 @@ namespace RAY::Drawables::Drawables3D { //! @brief Draw circle on window void drawOn(RAY::Window &) override; + + //! @brief Draw cube's wires on window + void drawWiresOn(RAY::Window &) override; private: //! @brief Dimensions of the cube Vector3 _dimensions; diff --git a/lib/Ray/sources/Drawables/3D/Cylinder.cpp b/lib/Ray/sources/Drawables/3D/Cylinder.cpp index 64db931d..6dfb2a1f 100644 --- a/lib/Ray/sources/Drawables/3D/Cylinder.cpp +++ b/lib/Ray/sources/Drawables/3D/Cylinder.cpp @@ -52,4 +52,9 @@ namespace RAY::Drawables::Drawables3D { DrawCylinder(this->_position, this->_topRadius, this->_bottomRadius, this->_height, 0, this->_color); } + + void Cylinder::drawWiresOn(RAY::Window &) + { + DrawCylinderWires(this->_position, this->_topRadius, this->_bottomRadius, this->_height, 0, GREEN); + } } \ No newline at end of file diff --git a/lib/Ray/sources/Drawables/3D/Cylinder.hpp b/lib/Ray/sources/Drawables/3D/Cylinder.hpp index dc09fb5d..32871514 100644 --- a/lib/Ray/sources/Drawables/3D/Cylinder.hpp +++ b/lib/Ray/sources/Drawables/3D/Cylinder.hpp @@ -55,6 +55,8 @@ namespace RAY::Drawables::Drawables3D { //! @brief Draw point on window void drawOn(RAY::Window &) override; + //! @brief Draw cylinder's wires on window + void drawWiresOn(RAY::Window &) override; private: //! @brief Radius of the cylinder float _topRadius; diff --git a/lib/Ray/sources/Drawables/3D/Sphere.cpp b/lib/Ray/sources/Drawables/3D/Sphere.cpp index 7d23fc48..2949606e 100644 --- a/lib/Ray/sources/Drawables/3D/Sphere.cpp +++ b/lib/Ray/sources/Drawables/3D/Sphere.cpp @@ -30,4 +30,9 @@ namespace RAY::Drawables::Drawables3D { DrawSphere(this->_position, this->_radius, this->_color); } + + void Sphere::drawWiresOn(RAY::Window &) + { + DrawSphereWires(this->_position, this->_radius, 10, 10, GREEN); + } } \ No newline at end of file diff --git a/lib/Ray/sources/Drawables/3D/Sphere.hpp b/lib/Ray/sources/Drawables/3D/Sphere.hpp index d053ccf9..24c31a8b 100644 --- a/lib/Ray/sources/Drawables/3D/Sphere.hpp +++ b/lib/Ray/sources/Drawables/3D/Sphere.hpp @@ -40,6 +40,9 @@ namespace RAY::Drawables::Drawables3D { //! @brief Draw point on window void drawOn(RAY::Window &) override; + //! @brief Draw sphere's wires on window + void drawWiresOn(RAY::Window &) override; + private: //! @brief Radius of the sphere int _radius; diff --git a/lib/Ray/sources/Drawables/ADrawable3D.cpp b/lib/Ray/sources/Drawables/ADrawable3D.cpp index 0fff69f8..fabc12fd 100644 --- a/lib/Ray/sources/Drawables/ADrawable3D.cpp +++ b/lib/Ray/sources/Drawables/ADrawable3D.cpp @@ -36,4 +36,7 @@ namespace RAY::Drawables this->_position = position; return *this; } + + void ADrawable3D::drawWiresOn(RAY::Window &) + {} } \ No newline at end of file diff --git a/lib/Ray/sources/Drawables/ADrawable3D.hpp b/lib/Ray/sources/Drawables/ADrawable3D.hpp index cc989fed..4c82ded6 100644 --- a/lib/Ray/sources/Drawables/ADrawable3D.hpp +++ b/lib/Ray/sources/Drawables/ADrawable3D.hpp @@ -30,6 +30,9 @@ namespace RAY::Drawables { //! @brief Draw drawble on window void drawOn(RAY::Window &) override = 0; + //! @brief Draw drawble's wires on window + virtual void drawWiresOn(RAY::Window &); + //! @return the color of the ADrawable const RAY::Color &getColor(void) const; diff --git a/lib/Ray/sources/Model/Model.cpp b/lib/Ray/sources/Model/Model.cpp index 9fd5b31e..2239c359 100644 --- a/lib/Ray/sources/Model/Model.cpp +++ b/lib/Ray/sources/Model/Model.cpp @@ -114,6 +114,20 @@ namespace RAY::Drawables::Drawables3D this->_color); } + void Model::drawWiresOn(RAY::Window &) + { + if (this->_model->meshCount) { + ::BoundingBox box = GetMeshBoundingBox(*this->_model->meshes); + box.min.x += this->_position.x; + box.min.y += this->_position.y; + box.min.z += this->_position.z; + box.max.x += this->_position.x; + box.max.y += this->_position.y; + box.max.z += this->_position.z; + DrawBoundingBox(box, GREEN); + } + } + void Model::setShader(const RAY::Shader &shader) { this->_originalShader = this->_model->materials[0].shader; diff --git a/lib/Ray/sources/Model/Model.hpp b/lib/Ray/sources/Model/Model.hpp index d67706be..2bf6cf47 100644 --- a/lib/Ray/sources/Model/Model.hpp +++ b/lib/Ray/sources/Model/Model.hpp @@ -87,6 +87,9 @@ namespace RAY::Drawables::Drawables3D { void drawOn(RAY::Window &) override; + //! @brief Draw model's wires on window + void drawWiresOn(RAY::Window &) override; + private: //! @brief Raw data from raylib std::shared_ptr<::Model> _model; diff --git a/sources/System/Renderer/RenderSystem.cpp b/sources/System/Renderer/RenderSystem.cpp index 07b64134..d901b115 100644 --- a/sources/System/Renderer/RenderSystem.cpp +++ b/sources/System/Renderer/RenderSystem.cpp @@ -40,6 +40,8 @@ namespace BBM modelShader->model->setShader(modelShader->getShader()); drawable.drawable->setPosition(pos.position); drawable.drawable->drawOn(this->_window); + if (this->_debugMode) + drawable.drawable->drawWiresOn(this->_window); if (modelShader) modelShader->model->resetShader(); } @@ -59,7 +61,7 @@ namespace BBM } } if (this->_debugMode) - this->_window.drawFPS(Vector2f()); + this->_window.drawFPS(Vector2f(10, 10)); this->_window.endDrawing(); }