mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-03 10:26:29 +00:00
ressources are not reloadable, ressource interface deleted
This commit is contained in:
+83
-103
@@ -8,122 +8,102 @@
|
||||
#include "Model/Model.hpp"
|
||||
#include "Exceptions/RayError.hpp"
|
||||
|
||||
RAY::Drawables::Drawables3D::Model::Model(const std::string &filename,
|
||||
std::optional<std::pair<MaterialType, std::string>> texture,
|
||||
const RAY::Vector3 &position,
|
||||
const RAY::Vector3 &rotationAxis,
|
||||
float rotationAngle,
|
||||
const RAY::Vector3 &scale)
|
||||
: ADrawable3D(position, WHITE),
|
||||
_model(LoadModel(filename.c_str())),
|
||||
_rotationAxis(rotationAxis),
|
||||
_rotationAngle(rotationAngle),
|
||||
_scale(scale)
|
||||
{
|
||||
if (texture.has_value())
|
||||
this->setTextureToMaterial(texture->first, texture->second);
|
||||
}
|
||||
namespace RAY::Drawables::Drawables3D {
|
||||
|
||||
RAY::Drawables::Drawables3D::Model::Model(const Mesh &mesh)
|
||||
: ADrawable3D({0, 0, 0}, WHITE), _model(LoadModelFromMesh(mesh))
|
||||
{
|
||||
}
|
||||
Model::Model(const std::string &filename,
|
||||
std::optional<std::pair<MaterialType, std::string>> texture,
|
||||
const RAY::Vector3 &position,
|
||||
const RAY::Vector3 &rotationAxis,
|
||||
float rotationAngle,
|
||||
const RAY::Vector3 &scale)
|
||||
: ADrawable3D(position, WHITE),
|
||||
_model(LoadModel(filename.c_str())),
|
||||
_rotationAxis(rotationAxis),
|
||||
_rotationAngle(rotationAngle),
|
||||
_scale(scale)
|
||||
{
|
||||
if (texture.has_value())
|
||||
this->setTextureToMaterial(texture->first, texture->second);
|
||||
}
|
||||
|
||||
RAY::Drawables::Drawables3D::Model::~Model()
|
||||
{
|
||||
this->unload();
|
||||
}
|
||||
Model::Model(const Mesh &mesh)
|
||||
: ADrawable3D({0, 0, 0}, WHITE), _model(LoadModelFromMesh(mesh))
|
||||
{
|
||||
}
|
||||
|
||||
bool RAY::Drawables::Drawables3D::Model::load(const std::string &filename)
|
||||
{
|
||||
this->_model = LoadModel(filename.c_str());
|
||||
return true;
|
||||
}
|
||||
Model::~Model()
|
||||
{
|
||||
UnloadModel(this->_model);
|
||||
}
|
||||
|
||||
bool RAY::Drawables::Drawables3D::Model::load(const Mesh &mesh)
|
||||
{
|
||||
this->_model = LoadModelFromMesh(mesh);
|
||||
return true;
|
||||
}
|
||||
bool Model::unloadKeepMeshes()
|
||||
{
|
||||
UnloadModelKeepMeshes(_model);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Drawables::Drawables3D::Model::unload()
|
||||
{
|
||||
UnloadModel(this->_model);
|
||||
return true;
|
||||
}
|
||||
bool Model::setAnimation(const RAY::ModelAnimation &animation)
|
||||
{
|
||||
if (!IsModelAnimationValid(this->_model, animation))
|
||||
throw RAY::Exception::NotCompatibleError("The animation is not compatible with the model");
|
||||
UpdateModelAnimation(this->_model, animation, animation.getFrameCounter());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Drawables::Drawables3D::Model::unloadKeepMeshes()
|
||||
{
|
||||
UnloadModelKeepMeshes(_model);
|
||||
return true;
|
||||
}
|
||||
bool Model::setTextureToMaterial(Model::MaterialType materialType, const std::string &texturePath)
|
||||
{
|
||||
this->_textureList.emplace(materialType, texturePath);
|
||||
SetMaterialTexture(&this->_model.materials[materialType],
|
||||
materialType,
|
||||
this->_textureList.at(materialType));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Drawables::Drawables3D::Model::setAnimation(const RAY::ModelAnimation &animation)
|
||||
{
|
||||
if (!IsModelAnimationValid(this->_model, animation))
|
||||
throw RAY::Exception::NotCompatibleError("The animation is not compatible with the model");
|
||||
UpdateModelAnimation(this->_model, animation, animation.getFrameCounter());
|
||||
return true;
|
||||
}
|
||||
Model::operator ::Model() const
|
||||
{
|
||||
return this->_model;
|
||||
}
|
||||
|
||||
bool RAY::Drawables::Drawables3D::Model::setTextureToMaterial(RAY::Drawables::Drawables3D::Model::MaterialType materialType, const RAY::Texture &texture)
|
||||
{
|
||||
this->_textureList[materialType] = texture;
|
||||
SetMaterialTexture(&this->_model.materials[materialType], materialType, this->_textureList[materialType]);
|
||||
return true;
|
||||
}
|
||||
int Model::getBoneCount() const
|
||||
{
|
||||
return this->_model.boneCount;
|
||||
}
|
||||
|
||||
bool RAY::Drawables::Drawables3D::Model::setTextureToMaterial(RAY::Drawables::Drawables3D::Model::MaterialType materialType, const std::string &texturePath)
|
||||
{
|
||||
this->_textureList.emplace(materialType, texturePath);
|
||||
SetMaterialTexture(&this->_model.materials[materialType], materialType, this->_textureList[materialType]);
|
||||
return true;
|
||||
}
|
||||
Model &Model::setRotationAngle(float rotationAngle)
|
||||
{
|
||||
this->_rotationAngle = rotationAngle;
|
||||
return *this;
|
||||
}
|
||||
|
||||
RAY::Drawables::Drawables3D::Model::operator ::Model() const
|
||||
{
|
||||
return this->_model;
|
||||
}
|
||||
float Model::getRotationAngle(void)
|
||||
{
|
||||
return this->_rotationAngle;
|
||||
}
|
||||
|
||||
int RAY::Drawables::Drawables3D::Model::getBoneCount() const
|
||||
{
|
||||
return this->_model.boneCount;
|
||||
}
|
||||
Model &Model::setRotationAxis(const RAY::Vector3 &scale)
|
||||
{
|
||||
this->_scale = scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
RAY::Drawables::Drawables3D::Model &RAY::Drawables::Drawables3D::Model::setRotationAngle(float rotationAngle)
|
||||
{
|
||||
this->_rotationAngle = rotationAngle;
|
||||
return *this;
|
||||
}
|
||||
const RAY::Vector3 &Model::getRotationAxis(void)
|
||||
{
|
||||
return this->_rotationAxis;
|
||||
}
|
||||
|
||||
float RAY::Drawables::Drawables3D::Model::getRotationAngle(void)
|
||||
{
|
||||
return this->_rotationAngle;
|
||||
}
|
||||
Model &Model::setScale(const RAY::Vector3 &scale)
|
||||
{
|
||||
this->_scale = scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
RAY::Drawables::Drawables3D::Model &RAY::Drawables::Drawables3D::Model::setRotationAxis(const RAY::Vector3 &scale)
|
||||
{
|
||||
this->_scale = scale;
|
||||
return *this;
|
||||
}
|
||||
const RAY::Vector3 &Model::getScale(void)
|
||||
{
|
||||
return this->_scale;
|
||||
}
|
||||
|
||||
const RAY::Vector3 &RAY::Drawables::Drawables3D::Model::getRotationAxis(void)
|
||||
{
|
||||
return this->_rotationAxis;
|
||||
}
|
||||
|
||||
RAY::Drawables::Drawables3D::Model &RAY::Drawables::Drawables3D::Model::setScale(const RAY::Vector3 &scale)
|
||||
{
|
||||
this->_scale = scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const RAY::Vector3 &RAY::Drawables::Drawables3D::Model::getScale(void)
|
||||
{
|
||||
return this->_scale;
|
||||
}
|
||||
|
||||
void RAY::Drawables::Drawables3D::Model::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawModelEx(this->_model, this->_position, this->_rotationAxis, this->_rotationAngle, this->_scale, this->_color);
|
||||
void Model::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawModelEx(this->_model, this->_position, this->_rotationAxis, this->_rotationAngle, this->_scale, this->_color);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
#ifndef MODEL_HPP_
|
||||
#define MODEL_HPP_
|
||||
|
||||
#include "IRessource.hpp"
|
||||
#include "Drawables/Texture.hpp"
|
||||
#include "Drawables/ADrawable3D.hpp"
|
||||
#include "Model/ModelAnimation.hpp"
|
||||
@@ -19,7 +18,7 @@
|
||||
|
||||
namespace RAY::Drawables::Drawables3D {
|
||||
//! @brief Basic 3D Model type
|
||||
class Model: public IRessource, public Drawables::ADrawable3D {
|
||||
class Model: public Drawables::ADrawable3D {
|
||||
public:
|
||||
|
||||
typedef ::MaterialMapIndex MaterialType;
|
||||
@@ -46,15 +45,6 @@ namespace RAY::Drawables::Drawables3D {
|
||||
//! @brief Model destructor, unloads all related data
|
||||
~Model();
|
||||
|
||||
//! @brief Load model from file (meshes and materials)
|
||||
bool load(const std::string &filePath);
|
||||
|
||||
//! @brief Load model from mesh (default materials)
|
||||
bool load(const Mesh &mesh);
|
||||
|
||||
//! @brief Unload model (including meshes) from memory (RAM and/or VRAM)
|
||||
bool unload() override;
|
||||
|
||||
//! @brief Unload model (excluding meshes) from memory (RAM and/or VRAM)
|
||||
bool unloadKeepMeshes();
|
||||
|
||||
@@ -64,7 +54,6 @@ namespace RAY::Drawables::Drawables3D {
|
||||
//! @brief Sets a texture to the Nth material
|
||||
//! @param materielIndex The type of material to apply the texture to (serves as an index)
|
||||
//! @param texture the texture to apply
|
||||
bool setTextureToMaterial(MaterialType materialType, const RAY::Texture &texture);
|
||||
bool setTextureToMaterial(MaterialType materialType, const std::string &texture);
|
||||
|
||||
//! @return The number of bones in the model
|
||||
|
||||
Reference in New Issue
Block a user