diff --git a/lib/Ray/CMakeLists.txt b/lib/Ray/CMakeLists.txt index 9a55f6be..958d17c7 100644 --- a/lib/Ray/CMakeLists.txt +++ b/lib/Ray/CMakeLists.txt @@ -97,7 +97,7 @@ set(SRC sources/Model/ModelAnimations.cpp sources/Vector/Vector2.cpp sources/Vector/Vector3.cpp - sources/Shaders/Shaders.cpp sources/Shaders/Shaders.hpp) + sources/Shaders/Shaders.cpp sources/Shaders/Shaders.hpp sources/Meshes/MeshSphere.cpp sources/Meshes/MeshSphere.hpp sources/Meshes/AMesh.cpp sources/Meshes/AMesh.hpp) find_package(raylib QUIET) if (NOT raylib_FOUND) diff --git a/lib/Ray/sources/Meshes/AMesh.cpp b/lib/Ray/sources/Meshes/AMesh.cpp new file mode 100644 index 00000000..9a76e90e --- /dev/null +++ b/lib/Ray/sources/Meshes/AMesh.cpp @@ -0,0 +1,13 @@ +// +// Created by cbihan on 16/06/2021. +// + +#include "AMesh.hpp" + +namespace RAY::Mesh +{ + std::shared_ptr<::Mesh> RAY::Mesh::AMesh::getRaylibMesh() const + { + return this->_raylibMesh; + } +} \ No newline at end of file diff --git a/lib/Ray/sources/Meshes/AMesh.hpp b/lib/Ray/sources/Meshes/AMesh.hpp new file mode 100644 index 00000000..278552ec --- /dev/null +++ b/lib/Ray/sources/Meshes/AMesh.hpp @@ -0,0 +1,28 @@ +// +// Created by cbihan on 16/06/2021. +// + +#pragma once + +#include +#include + +namespace RAY::Mesh +{ + class AMesh + { + protected: + std::shared_ptr<::Mesh> _raylibMesh; + + INTERNAL: + //! @brief getter for _raylibMesh + std::shared_ptr<::Mesh> getRaylibMesh() const; + + public: + + //! @brief dtor + virtual ~AMesh() = default; + + }; + +} \ No newline at end of file diff --git a/lib/Ray/sources/Meshes/MeshSphere.cpp b/lib/Ray/sources/Meshes/MeshSphere.cpp new file mode 100644 index 00000000..349787c0 --- /dev/null +++ b/lib/Ray/sources/Meshes/MeshSphere.cpp @@ -0,0 +1,16 @@ +// +// Created by cbihan on 16/06/2021. +// + +#include "MeshSphere.hpp" + +namespace RAY::Mesh +{ + MeshSphere::MeshSphere(float radius_arg, int rings_arg, int slices_arg) : + radius(radius_arg), + rings(rings_arg), + slices(slices_arg) + { + this->_raylibMesh = std::make_shared<::Mesh>(GenMeshSphere(radius_arg, rings_arg, slices_arg)); + } +} \ No newline at end of file diff --git a/lib/Ray/sources/Meshes/MeshSphere.hpp b/lib/Ray/sources/Meshes/MeshSphere.hpp new file mode 100644 index 00000000..b8aa1c75 --- /dev/null +++ b/lib/Ray/sources/Meshes/MeshSphere.hpp @@ -0,0 +1,35 @@ +// +// Created by cbihan on 16/06/2021. +// + +#pragma once + +#include +#include "AMesh.hpp" +#include + +namespace RAY::Mesh +{ + class MeshSphere : public AMesh + { + public: + //! @brief radius + float radius; + //! @brief rings + int rings; + //! @brief slices + int slices; + + + //! @brief ctor + MeshSphere(float radius_arg, int rings_arg, int slices_arg); + //! @brief copy ctor + MeshSphere(const MeshSphere &) = default; + //! @brief dtor + ~MeshSphere() = default; + //! @brief assignment operator + MeshSphere &operator=(const MeshSphere &) = default; + + }; + +} diff --git a/lib/Ray/sources/Model/Model.cpp b/lib/Ray/sources/Model/Model.cpp index f1c4a958..b694fb4d 100644 --- a/lib/Ray/sources/Model/Model.cpp +++ b/lib/Ray/sources/Model/Model.cpp @@ -32,14 +32,14 @@ namespace RAY::Drawables::Drawables3D this->setTextureToMaterial(texture->first, texture->second); } - Model::Model(const Mesh &mesh, + Model::Model(const Mesh::AMesh &mesh, std::optional> texture, const RAY::Vector3 &scale, const RAY::Vector3 &position, const RAY::Vector3 &rotationAxis, float rotationAngle) : ADrawable3D(position, WHITE), - _model(std::make_shared<::Model>(LoadModelFromMesh(mesh))), + _model(std::make_shared<::Model>(LoadModelFromMesh(*mesh.getRaylibMesh()))), _rotationAxis(rotationAxis), _rotationAngle(rotationAngle), _scale(scale) diff --git a/lib/Ray/sources/Model/Model.hpp b/lib/Ray/sources/Model/Model.hpp index a7327182..1d44352e 100644 --- a/lib/Ray/sources/Model/Model.hpp +++ b/lib/Ray/sources/Model/Model.hpp @@ -13,6 +13,7 @@ #include "Model/ModelAnimation.hpp" #include "Shaders/Shaders.hpp" #include +#include "Meshes/AMesh.hpp" #include #include #include "Utils/Cache.hpp" @@ -36,7 +37,7 @@ namespace RAY::Drawables::Drawables3D { //! @brief Create an model, loading a file //! @param mesh: mesh to load - Model(const Mesh &mesh, + Model(const Mesh::AMesh &mesh, std::optional> texture = std::nullopt, const RAY::Vector3 &scale = RAY::Vector3(1, 1, 1), const RAY::Vector3 &position = {0, 0, 0}, diff --git a/sources/System/BombHolder/BombHolderSystem.cpp b/sources/System/BombHolder/BombHolderSystem.cpp index e8496b8e..0a69c435 100644 --- a/sources/System/BombHolder/BombHolderSystem.cpp +++ b/sources/System/BombHolder/BombHolderSystem.cpp @@ -11,6 +11,7 @@ #include "Component/Health/HealthComponent.hpp" #include #include +#include #include "Component/Shaders/Items/BombExplosionShaderComponent.hpp" #include #include "Component/Shaders/ShaderComponent.hpp" @@ -72,7 +73,7 @@ namespace BBM .addComponent(500ms, [](WAL::Entity &explosion, WAL::Wal &wal) { explosion.scheduleDeletion(); }) - .addComponent(GenMeshSphere(0.5, 16, 16), + .addComponent(RAY::Mesh::MeshSphere(0.5, 16, 16), std::make_pair( MAP_DIFFUSE, "assets/bombs/explosion/blast.png"