diff --git a/lib/Ray/sources/Model/Model.cpp b/lib/Ray/sources/Model/Model.cpp index 5ce18d71..a611995a 100644 --- a/lib/Ray/sources/Model/Model.cpp +++ b/lib/Ray/sources/Model/Model.cpp @@ -8,8 +8,8 @@ #include "Model/Model.hpp" #include "Exceptions/RayError.hpp" -RAY::Model::Model(const std::string &filename): - _model(LoadModel(filename.c_str())) +RAY::Model::Model(const std::string &filePath, const RAY::Vector3 &position, const RAY::Vector3 &rotationAxis, float rotationAngle, const RAY::Vector3 &scale): + ADrawable3D(position, WHITE), _model(LoadModel(filename.c_str()), position, rotationAxis, rotationAngle, scale) { } @@ -69,4 +69,42 @@ RAY::Model::operator ::Model() const int RAY::Model::getBoneCount() const { return this->_model.boneCount; +} + +RAY::Model &RAY::Model::setRotationAngle(float rotationAngle) +{ + this->_rotationAngle = rotationAngle; + return *this; +} + +float RAY::Model::getRotationAngle(void) +{ + return this->_rotationAngle; +} + +RAY::Model &RAY::Model::setRotationAxix(const RAY::Vector3 &scale) +{ + this->_scale = scale; + return *this; +} + +const RAY::Vector3 &RAY::Model::getRotationAxix(void) +{ + return this->_rotationAxis; +} + +RAY::Model &RAY::Model::setScale(const RAY::Vector3 &scale) +{ + this->_scale = scale; + return *this; +} + +const RAY::Vector3 &RAY::Model::getScale(void) +{ + return this->_scale; +} + +void RAY::Model::drawOn(RAY::Window &) +{ + DrawModelEx(this->_model, this->_position, this->_rotationAxis, this->_rotationAngle, this->_scale, this->_color); } \ No newline at end of file diff --git a/lib/Ray/sources/Model/Model.hpp b/lib/Ray/sources/Model/Model.hpp index 50ee4bc8..f57300f2 100644 --- a/lib/Ray/sources/Model/Model.hpp +++ b/lib/Ray/sources/Model/Model.hpp @@ -10,21 +10,21 @@ #include "IRessource.hpp" #include "Drawables/Texture.hpp" -#include "Drawables/IDrawable.hpp" +#include "Drawables/ADrawable3D.hpp" #include "Model/ModelAnimation.hpp" #include #include namespace RAY { //! @brief Basic 3D Model type - class Model: public IRessource { + class Model: public IRessource, public Drawables::ADrawable3D { public: typedef ::MaterialMapIndex MaterialType; //! @brief Create an model, loading a file //! @param filePath: path to file to load - Model(const std::string &filePath); + Model(const std::string &filePath, const RAY::Vector3 &position, const RAY::Vector3 &rotationAxis = RAY::Vector3(0, 1, 0), float rotationAngle = 0, const RAY::Vector3 &scale = RAY::Vector3(1, 1, 1)); //! @brief Create an model, loading a file //! @param mesh: mesh to load @@ -61,9 +61,34 @@ namespace RAY { //! @return The number of bones in the model int getBoneCount() const; + + //! @brief Set rotation angle + Model &setRotationAngle(float roationAngle); + + //! @return rotation angle + float getRotationAngle(void); + + //! @brief Set Rotation Axis + Model &setRotationAxix(const RAY::Vector3 &scale); + + //! @return rotation axis + const RAY::Vector3 & getRotationAxix(void); + + //! @brief Set Scale + Model &setScale(const RAY::Vector3 &scale); + + //! @return Scale + const RAY::Vector3 & getScale(void); + private: //! @brief Raw data from raylib ::Model _model; + //! @brief Rotation property + RAY::Vector3 _rotationAxis; + //! @brief Rotation property + float _rotationAngle; + //! @brief Scale of the shape + RAY::Vector3 _scale; INTERNAL: //! @brief A RAY Model is cast-able in libray's model diff --git a/lib/Ray/sources/Window.cpp b/lib/Ray/sources/Window.cpp index 2f9d2dd6..a372c7df 100644 --- a/lib/Ray/sources/Window.cpp +++ b/lib/Ray/sources/Window.cpp @@ -166,11 +166,6 @@ void RAY::Window::draw(const Mesh &mesh, const Material &material, const Matrix DrawMesh(mesh, material, transform); } -void RAY::Window::draw(const RAY::Model &model, const RAY::Vector3 &position, const RAY::Vector3 &rotationAxis, float rotationAngle, const RAY::Vector3 &scale, const RAY::Color &tint) -{ - DrawModelEx(model, position, rotationAxis, rotationAngle, scale, tint); -} - void RAY::Window::setIcon(RAY::Image &img) { SetWindowIcon(img); diff --git a/lib/Ray/sources/Window.hpp b/lib/Ray/sources/Window.hpp index d9e86053..b8508167 100644 --- a/lib/Ray/sources/Window.hpp +++ b/lib/Ray/sources/Window.hpp @@ -17,7 +17,6 @@ #include "Camera/Camera3D.hpp" #include "Color.hpp" #include "Drawables/Texture.hpp" -#include "Model/Model.hpp" namespace RAY { class Model; @@ -129,10 +128,6 @@ namespace RAY { //! @brief Draw a 3d mesh with material and transform void draw(const Mesh &mesh, const Material &material, const Matrix &transform); - //! @brief Draw a model - void draw(const Model &model, const Vector3 &position, const Vector3 &rotationAxis = Vector3(0, 0, 0), - float rotationAngle = 0, const Vector3 &scale = Vector3(1, 1, 1), const Color &tint = WHITE); - private: //! @brief Creates window, and opens it if openNow is set to true