mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-03 10:26:29 +00:00
Merge branch 'develop' of github.com:AnonymusRaccoon/Bomberman into bonus
# Conflicts: # CMakeLists.txt # sources/Map/Map.cpp
This commit is contained in:
@@ -10,21 +10,23 @@
|
||||
#include <unordered_map>
|
||||
|
||||
|
||||
namespace RAY::Drawables::Drawables3D {
|
||||
namespace RAY::Drawables::Drawables3D
|
||||
{
|
||||
|
||||
RAY::Cache<::Model> Model::_modelsCache(LoadModel, UnloadModel);
|
||||
|
||||
Model::Model(const std::string &filename,
|
||||
std::optional<std::pair<MaterialType, std::string>> texture,
|
||||
const RAY::Vector3 &scale,
|
||||
const RAY::Vector3 &position,
|
||||
const RAY::Vector3 &rotationAxis,
|
||||
float rotationAngle, bool lonely)
|
||||
bool lonely,
|
||||
std::optional<std::pair<MaterialType, std::string>> texture,
|
||||
const RAY::Vector3 &scale,
|
||||
const RAY::Vector3 &position,
|
||||
const RAY::Vector3 &rotationAxis,
|
||||
float rotationAngle)
|
||||
: ADrawable3D(position, WHITE),
|
||||
_model(_modelsCache.fetch(filename, lonely)),
|
||||
_rotationAxis(rotationAxis),
|
||||
_rotationAngle(rotationAngle),
|
||||
_scale(scale)
|
||||
_model(_modelsCache.fetch(filename, lonely)),
|
||||
_rotationAxis(rotationAxis),
|
||||
_rotationAngle(rotationAngle),
|
||||
_scale(scale)
|
||||
{
|
||||
if (texture.has_value())
|
||||
this->setTextureToMaterial(texture->first, texture->second);
|
||||
@@ -32,7 +34,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
|
||||
Model::Model(const Mesh &mesh)
|
||||
: ADrawable3D({0, 0, 0}, WHITE),
|
||||
_model(std::make_shared<::Model>(LoadModelFromMesh(mesh)))
|
||||
_model(std::make_shared<::Model>(LoadModelFromMesh(mesh)))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -54,8 +56,8 @@ namespace RAY::Drawables::Drawables3D {
|
||||
{
|
||||
this->_textureList.emplace(materialType, texturePath);
|
||||
SetMaterialTexture(&this->_model->materials[materialType],
|
||||
materialType,
|
||||
this->_textureList.at(materialType));
|
||||
materialType,
|
||||
this->_textureList.at(materialType));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -104,6 +106,22 @@ namespace RAY::Drawables::Drawables3D {
|
||||
|
||||
void Model::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawModelEx(*this->_model, this->_position, this->_rotationAxis, this->_rotationAngle, this->_scale, this->_color);
|
||||
DrawModelEx(*this->_model,
|
||||
this->_position,
|
||||
this->_rotationAxis,
|
||||
this->_rotationAngle,
|
||||
this->_scale,
|
||||
this->_color);
|
||||
}
|
||||
|
||||
void Model::setShader(const RAY::Shader &shader)
|
||||
{
|
||||
this->_originalShader = this->_model->materials[0].shader;
|
||||
this->_model->materials[0].shader = *shader.getShaderPtr();
|
||||
}
|
||||
|
||||
void Model::resetShader()
|
||||
{
|
||||
this->_model->materials[0].shader = this->_originalShader;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "Drawables/Texture.hpp"
|
||||
#include "Drawables/ADrawable3D.hpp"
|
||||
#include "Model/ModelAnimation.hpp"
|
||||
#include "Shaders/Shaders.hpp"
|
||||
#include <raylib.h>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
@@ -26,12 +27,12 @@ namespace RAY::Drawables::Drawables3D {
|
||||
//! @brief Create an model, loading a file
|
||||
//! @param filePath: path to file to load
|
||||
//! @param lonely: should be set to true if the entity's loaded data must be independant from others
|
||||
Model(const std::string &filePath,
|
||||
Model(const std::string &filePath, bool lonely = false,
|
||||
std::optional<std::pair<MaterialType, std::string>> texture = std::nullopt,
|
||||
const RAY::Vector3 &scale = RAY::Vector3(1, 1, 1),
|
||||
const RAY::Vector3 &position = {0, 0, 0},
|
||||
const RAY::Vector3 &rotationAxis = RAY::Vector3(0, 1, 0),
|
||||
float rotationAngle = 0, bool lonely = false);
|
||||
float rotationAngle = 0);
|
||||
|
||||
//! @brief Create an model, loading a file
|
||||
//! @param mesh: mesh to load
|
||||
@@ -78,6 +79,12 @@ namespace RAY::Drawables::Drawables3D {
|
||||
//! @return Scale
|
||||
const RAY::Vector3 & getScale(void);
|
||||
|
||||
//! @brief Set a shader on the model
|
||||
void setShader(const RAY::Shader &shader);
|
||||
|
||||
//! @brief Set the original shader (used to disable a shader)
|
||||
void resetShader();
|
||||
|
||||
void drawOn(RAY::Window &) override;
|
||||
|
||||
private:
|
||||
@@ -91,6 +98,8 @@ namespace RAY::Drawables::Drawables3D {
|
||||
float _rotationAngle;
|
||||
//! @brief Scale of the shape
|
||||
RAY::Vector3 _scale;
|
||||
//! @brief The original shaderId used to disable a shader effect
|
||||
::Shader _originalShader = {};
|
||||
|
||||
static RAY::Cache<::Model> _modelsCache;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user